test(admin): align fee item acceptance payload

This commit is contained in:
2026-08-11 20:02:04 +08:00
parent 48bb752007
commit 1f4b09f0c9
2 changed files with 31 additions and 3 deletions
+9 -3
View File
@@ -8,6 +8,10 @@ const MERCHANT_PASSWORD = process.env.MERCHANT_TEST_PASSWORD || 'ChangeMe123!'
function id(value) { return value == null ? '' : String(value) }
function records(value) { return Array.isArray(value?.records) ? value.records : [] }
function success(response) { return response.http === 200 && String(response.body?.code) === '200' }
export function cleanupSucceeded(response) {
return success(response) || response.http === 404
|| (response.http === 200 && ['A0404', '404'].includes(String(response.body?.code)))
}
function conflict(response) {
return response.http === 200 && ['A0409', '409'].includes(String(response.body?.code))
}
@@ -182,7 +186,8 @@ export async function run(context) {
const feeDetailPath = `/api/platform/v1/inbounds/${encodeURIComponent(inbound.inboundId)}/fee-details?accountId=${encodeURIComponent(inbound.tenantId)}`
const detailPayload = {
feeItemId, direction: 'RECEIVABLE', businessDate: new Date().toISOString().slice(0, 10),
unitPrice: 1.25, currency: 'CNY', amount: 1.25, remark: context.marker,
unitPrice: 1.25, currency: 'CNY', amount: 1.25, settlementIncluded: false,
remark: context.marker,
}
const disabledBindingResponse = await context.request('POST', feeDetailPath, detailPayload)
context.assert(MODULE, '停用费用项目不可绑定新的入库费用', disabledBindingResponse,
@@ -205,6 +210,7 @@ export async function run(context) {
context.assert(MODULE, '任意客户费用明细引用后公共项目不可删除', protectedDeleteResponse,
conflict(protectedDeleteResponse),
`HTTP=${protectedDeleteResponse.http}, code=${protectedDeleteResponse.body?.code ?? 'missing'}, customer=${inbound.tenantId}`, OPTIONS)
itemDeleted = success(protectedDeleteResponse)
if (detailId) {
const detailDeleteResponse = await context.request('DELETE',
@@ -226,13 +232,13 @@ export async function run(context) {
if (detailId && !detailDeleted && inbound) {
const cleanupDetailResponse = await context.request('DELETE',
`/api/platform/v1/inbounds/${encodeURIComponent(inbound.inboundId)}/fee-details/${encodeURIComponent(detailId)}?accountId=${encodeURIComponent(inbound.tenantId)}`)
detailDeleted = success(cleanupDetailResponse)
detailDeleted = cleanupSucceeded(cleanupDetailResponse)
context.assert(MODULE, '异常路径清理本轮费用明细', cleanupDetailResponse, detailDeleted,
`detailId=${detailId}`, OPTIONS)
}
if (!itemDeleted && (!detailId || detailDeleted)) {
const cleanupItemResponse = await context.request('DELETE', `${BASE}/${encodeURIComponent(feeItemId)}`)
itemDeleted = success(cleanupItemResponse)
itemDeleted = cleanupSucceeded(cleanupItemResponse)
context.assert(MODULE, '异常路径清理本轮费用项目', cleanupItemResponse, itemDeleted,
`feeItemId=${feeItemId}`, OPTIONS)
}