test: select live unpaid settlement fixture
This commit is contained in:
@@ -36,6 +36,15 @@ async function detail(context, targetId) {
|
||||
return { response, value: data(response) }
|
||||
}
|
||||
|
||||
async function findActionTarget(context, items) {
|
||||
for (const item of items) {
|
||||
const current = await detail(context, settlementId(item))
|
||||
if (ok(current.response) && status(current.value) === 'ISSUED'
|
||||
&& outstanding(current.value) > 0 && paid(current.value) === 0) return item
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function verifyVoidReopen(context, item) {
|
||||
const targetId = settlementId(item)
|
||||
const before = await detail(context, targetId)
|
||||
@@ -152,8 +161,7 @@ export async function run(context) {
|
||||
manualIds.length > 0 && manualIds.every((feeId) => usedIds.has(feeId)),
|
||||
`manual=${manualIds.length}, settled=${manualIds.filter((feeId) => usedIds.has(feeId)).length}`, OPTIONS)
|
||||
|
||||
const actionTarget = validReceivables.find((item) => item.status === 'ISSUED')
|
||||
?? validPayables.find((item) => item.status === 'ISSUED')
|
||||
const actionTarget = await findActionTarget(context, [...validReceivables, ...validPayables])
|
||||
if (!actionTarget) gap(context, '取得结算单动作 Fixture', 'settlement VOID/REOPEN', '本轮没有未收付款且状态 ISSUED 的 AR/AP,禁止借历史单据')
|
||||
else await verifyVoidReopen(context, actionTarget)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user