优化
This commit is contained in:
@@ -11,7 +11,8 @@ const financePermissions = [
|
||||
'platform:finance:reconciliation:create', 'platform:finance:reconciliation:review',
|
||||
'platform:finance:reconciliation:issue', 'platform:finance:reconciliation:adjust',
|
||||
'platform:finance:reconciliation:void', 'platform:finance:settlement-ar:create',
|
||||
'platform:finance:settlement-ap:create',
|
||||
'platform:finance:settlement-ar:view', 'platform:finance:settlement-ap:create',
|
||||
'platform:finance:settlement-ap:view',
|
||||
]
|
||||
|
||||
function ok(data) {
|
||||
@@ -116,18 +117,26 @@ function fakeContext(withFixture = true, permissions = financePermissions, denyF
|
||||
const statement = statements.get(String(body.reconciliationStatementId))
|
||||
assert.equal(statement.status, 'ISSUED')
|
||||
const settlement = { settlementId: String(++settlementSequence), direction: 'RECEIVABLE',
|
||||
reconciliationStatementId: body.reconciliationStatementId, status: 'OPEN',
|
||||
paymentStatus: 'UNPAID', version: 0 }
|
||||
customerId: '11', reconciliationStatementId: body.reconciliationStatementId, status: 'OPEN',
|
||||
paymentStatus: 'UNPAID', totalAmount: 100, paidAmount: 0, outstandingAmount: 100, version: 0 }
|
||||
settlements.set(settlement.settlementId, settlement)
|
||||
if (idem) idempotency.set(idem, settlement)
|
||||
return ok(structuredClone(settlement))
|
||||
}
|
||||
if (method === 'POST' && requestPath.endsWith('/payable-settlements')) {
|
||||
const settlement = { settlementId: String(++settlementSequence), direction: 'PAYABLE',
|
||||
supplierId: String(body.supplierId), status: 'OPEN', paymentStatus: 'UNPAID', version: 0 }
|
||||
customerId: String(body.customerId), supplierId: String(body.supplierId), status: 'OPEN',
|
||||
paymentStatus: 'UNPAID', totalAmount: 100, paidAmount: 0, outstandingAmount: 100, version: 0 }
|
||||
settlements.set(settlement.settlementId, settlement)
|
||||
if (idem) idempotency.set(idem, settlement)
|
||||
return ok(structuredClone(settlement))
|
||||
}
|
||||
if (method === 'GET' && requestPath.startsWith('/api/platform/finance/v1/receivable-settlements?')) {
|
||||
return ok([...settlements.values()].filter((item) => item.direction === 'RECEIVABLE'))
|
||||
}
|
||||
if (method === 'GET' && requestPath.startsWith('/api/platform/finance/v1/payable-settlements?')) {
|
||||
return ok([...settlements.values()].filter((item) => item.direction === 'PAYABLE'))
|
||||
}
|
||||
throw new Error(`Unexpected request: ${method} ${requestPath}`)
|
||||
},
|
||||
addStep(module, name, response, passed, evidence = '', options = {}) {
|
||||
@@ -160,6 +169,10 @@ test('静态契约覆盖日期、SELECTED、三 AR、AP、状态机和数组输
|
||||
assert.match(source, /receivables\.length < 4/)
|
||||
assert.match(source, /const groups = \[cutoffSources/)
|
||||
assert.match(source, /\/payable-settlements/)
|
||||
assert.match(source, /findSettlementInOfficialList/)
|
||||
assert.match(source, /`正式\$\{label\}列表包含同一 settlementId`/)
|
||||
assert.match(source, /findSettlementInOfficialList\(context, 'RECEIVABLE'/)
|
||||
assert.match(source, /findSettlementInOfficialList\(context, 'PAYABLE'/)
|
||||
assert.match(source, /fixture\.root\.statements = statementRows/)
|
||||
assert.match(source, /fixture\.root\.receivableSettlements = arRows/)
|
||||
assert.doesNotMatch(source, /generationMode:\s*['"]BY_CUTOFF['"]/)
|
||||
@@ -193,6 +206,10 @@ test('run 发布一条日期链、三张独立已出账单、三张 AR 和一张
|
||||
assert.equal(context.calls.some((call) => call.body?.feeSourceIds?.includes(null)), false)
|
||||
assert.equal(context.calls.some((call) => call.body?.feeSourceIds?.includes('106')), false)
|
||||
assert.equal(context.calls.some((call) => call.path.includes('/fee-pool')), true)
|
||||
assert.equal(context.calls.filter((call) => call.method === 'GET'
|
||||
&& call.path.includes('/receivable-settlements?customerId=11')).length, 3)
|
||||
assert.equal(context.calls.filter((call) => call.method === 'GET'
|
||||
&& call.path.includes('/payable-settlements?customerId=11')).length, 1)
|
||||
assert.equal(context.calls.some((call) => call.body?.generationMode === 'BY_CUTOFF'), false)
|
||||
const failedSteps = context.steps.filter((step) => !step.passed)
|
||||
assert.equal(failedSteps.length, 0, JSON.stringify(failedSteps, null, 2))
|
||||
|
||||
Reference in New Issue
Block a user