add finance cost allocation detail

This commit is contained in:
2026-08-12 14:40:05 +08:00
parent fcb7c11af4
commit c4e6c28da0
4 changed files with 41 additions and 2 deletions
@@ -267,7 +267,12 @@ async function createContainerCost(context, customerId, container, voucherFileId
`message=${response.body.message || 'missing'}, loadingPlanId=${container.loadingPlanId || 'missing'}, containerBookingId=${container.containerBookingId || 'missing'}, voucherFileId=${voucherFileId || 'missing'}, publicSnapshotValid=${snapshotInput?.valid === true}, validItems=${snapshotInput?.items?.length || 0}, accountId=${first?.accountId ?? 'missing'}, orderId=${first?.orderId ?? 'missing'}, volumeCbm=${first?.volumeCbm ?? 'missing'}, requestId=${response.requestId || 'missing'}, traceId=${response.traceId || 'missing'};若 publicSnapshotValid=true,说明 fixture ID 与公开装柜明细有效,阻断位于 Finance -> Firstleg 内部快照服务部署/契约`)
}
const cost = context.apiSuccess(MODULE, '创建整柜成本并触发真实体积分摊', response, '', OPTIONS)
return cost?.id ? { costId: id(cost.id), allocations: Array.isArray(cost.allocations) ? cost.allocations : null } : null
if (!cost?.id) return null
const detailResponse = await context.request('GET',
`/api/platform/finance/v1/cost-entries/${encodeURIComponent(cost.id)}?customerId=${encodeURIComponent(customerId)}`)
const detail = context.apiSuccess(MODULE, '回读整柜成本分摊结果', detailResponse,
`costId=${cost.id}`, OPTIONS)
return { costId: id(cost.id), allocations: Array.isArray(detail?.allocations) ? detail.allocations : null }
}
async function verifyContainerCostSnapshotInput(context, customerId, container) {
@@ -382,7 +387,7 @@ export async function run(context) {
const cost = snapshotInput.valid ? await createContainerCost(context, customerId, container, voucherFileId, snapshotInput) : null
if (Array.isArray(cost?.allocations)) allocations = cost.allocations
else blocker(context, '回读整柜成本分摊结果',
`costId=${cost?.costId || 'missing'};Finance POST /api/platform/finance/v1/cost-entries 仅返回 ResourceResult,GET cost-entries 仅返回成本摘要,当前没有公开接口回读 fin_cost_allocation;禁止从金额和体积自行伪造持久化结果`)
`costId=${cost?.costId || 'missing'};Finance 成本详情未返回真实 fin_cost_allocation,禁止从金额和体积自行伪造持久化结果`)
}
if (allocations.length === 0) blocker(context, '输出真实订单/运单分摊',
'缺少已完成柜次、凭证、供应商或 Finance 分摊响应;不伪造 allocation ID/金额')