修正进销存报表商品编码范围 (#218)
This commit is contained in:
parent
135a54619d
commit
4e0dcc7f2b
@ -268,6 +268,7 @@ class ThirdPartyWarehouseStorageMirrorRepository
|
||||
->select('wms_co_id')->selectRaw('MAX(Id) AS Id');
|
||||
$inventoryPairs = $this->connection->table(self::INVENTORY_TABLE)
|
||||
->where('generation', $inventoryGeneration)
|
||||
->where('qty', '!=', 0)
|
||||
->whereNotNull('sku_code')->where('sku_code', '!=', '')
|
||||
->select(['wms_co_id', 'sku_code']);
|
||||
$candidates = $this->connection->query()->fromSub($inventoryPairs, 'pairs')
|
||||
@ -334,14 +335,8 @@ class ThirdPartyWarehouseStorageMirrorRepository
|
||||
$movements = $this->confirmedMovements($headerGeneration, $itemGeneration, null)
|
||||
->where('h.occurred_at', '>=', $rangeStart)
|
||||
->where('h.occurred_at', '<', $rangeEnd)
|
||||
->where(function (Builder $pairs) use ($pairRows): void {
|
||||
foreach ($pairRows as $pair) {
|
||||
$pairs->orWhere(function (Builder $candidate) use ($pair): void {
|
||||
$candidate->where('h.wms_co_id', (int) $pair->wms_co_id)
|
||||
->where('i.sku_code', (string) $pair->sku_code);
|
||||
});
|
||||
}
|
||||
})
|
||||
->whereIn('h.wms_co_id', $pairRows->pluck('wms_co_id')->unique()->values()->all())
|
||||
->whereIn('i.sku_code', $pairRows->pluck('sku_code')->unique()->values()->all())
|
||||
->select([
|
||||
'h.wms_co_id', 'h.io_type', 'h.occurred_at', 'i.sku_code',
|
||||
'i.qty as movement_qty', 'i.qty_type as movement_qty_type',
|
||||
|
||||
@ -194,6 +194,25 @@ class ThirdPartyWarehouseStorageMirrorRepositoryTest extends TestCase
|
||||
$this->assertSame(-20.0, (float) $result['data'][0]->sales_out);
|
||||
}
|
||||
|
||||
public function test_inventory_report_excludes_zero_only_dirty_product_codes(): void
|
||||
{
|
||||
$this->markReady();
|
||||
$this->insertInventory('SKU-STOCK', 2, '2026-09-01 00:00:00');
|
||||
$this->insertInventory('【商品描述不是商品编码】', 0, '2026-09-01 00:00:00');
|
||||
|
||||
$result = $this->repository->paginateMonthlyInventoryReport([
|
||||
'month' => '2026-08',
|
||||
'product_code' => '',
|
||||
'warehouse_provider' => '',
|
||||
'category' => '',
|
||||
], 1, 25);
|
||||
$codes = collect($result['data'])->pluck('product_code')->all();
|
||||
|
||||
$this->assertSame(1, $result['total']);
|
||||
$this->assertSame(['SKU-STOCK'], $codes);
|
||||
$this->assertNotContains('【商品描述不是商品编码】', $codes);
|
||||
}
|
||||
|
||||
public function test_third_party_page_remains_ready_when_only_the_all_warehouse_dimension_is_missing(): void
|
||||
{
|
||||
$this->markReady();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user