From 299287197547448a6e73a64bc1692b5a4c5584b4 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 3 Oct 2026 07:44:17 +0800 Subject: [PATCH] test(fleet): resolve raw position ownership through its balance --- .../fleet-cross-customer-fixture-contract.test.mjs | 2 ++ .../admin-test-env-modules/fleet-cross-customer-fixture.mjs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/admin-test-env-modules/fleet-cross-customer-fixture-contract.test.mjs b/scripts/admin-test-env-modules/fleet-cross-customer-fixture-contract.test.mjs index 1aaef496c..6ad5a84cf 100644 --- a/scripts/admin-test-env-modules/fleet-cross-customer-fixture-contract.test.mjs +++ b/scripts/admin-test-env-modules/fleet-cross-customer-fixture-contract.test.mjs @@ -152,6 +152,8 @@ function model(fault = '') { assert.equal(scope.marker, context.marker); assert.equal(scope.warehouseId, options.warehouseId) const facts = stock(transfers.find(row => row.customerId === scope.customerId)) const raw = { scope: { ...scope, coverage: 'CUSTOMER_WAREHOUSE_COMPLETE' }, balances: [facts.balance], positions: facts.positions, ledger: facts.ledger } + // The physical position table links to its inbound through balance_id; only the public joined DTO has inboundCode. + for (const position of raw.positions) delete position.inboundCode if (fault === 'wrong raw scope') raw.scope.marker = 'OLD' if (fault === 'wrong raw ledger position') raw.ledger[0].positionId = 'OTHER' if (fault === 'wrong raw ledger balance') raw.ledger[0].balanceId = 'OTHER' diff --git a/scripts/admin-test-env-modules/fleet-cross-customer-fixture.mjs b/scripts/admin-test-env-modules/fleet-cross-customer-fixture.mjs index cbfd4812c..0a345ce51 100644 --- a/scripts/admin-test-env-modules/fleet-cross-customer-fixture.mjs +++ b/scripts/admin-test-env-modules/fleet-cross-customer-fixture.mjs @@ -83,7 +83,9 @@ export async function createFleetCrossCustomerFixture(context, { execute = false && raw.scope.customerId === scope.customerId && raw.scope.warehouseId === scope.warehouseId && raw.scope.coverage === 'CUSTOMER_WAREHOUSE_COMPLETE') for (const collection of ['balances', 'positions', 'ledger']) check(`Fresh customer raw ${collection} has exactly one original receipt row`, - Array.isArray(raw[collection]) && raw[collection].length === 1 && id(raw[collection][0].id) && sourceMatches(raw[collection][0])) + Array.isArray(raw[collection]) && raw[collection].length === 1 && id(raw[collection][0].id) + && id(raw[collection][0].customerId) === member.customerId && id(raw[collection][0].overseasWarehouseId) === id(warehouseId) + && (collection === 'positions' || raw[collection][0].inboundCode === member.incomingNo)) const rawBalance = raw.balances[0], rawPosition = raw.positions[0], rawMovement = raw.ledger[0] check('Raw receipt identities and quantities match the public evidence', id(rawBalance.id) === id(balance.id) && id(rawPosition.id) === id(positions[0].id) && id(rawPosition.balanceId) === id(balance.id)