test(fleet): resolve raw position ownership through its balance
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user