refactor(firstleg): keep trucking payable only
This commit is contained in:
@@ -55,7 +55,7 @@ export function truckAppointmentPayload(context, suffix, identity, version = 0,
|
||||
storeName: `装柜点-${suffix}`, storeContact: '仓库联系人', storePhone: '13800000006',
|
||||
storeAddress: '深圳市南山区验收地址', storeCity: '深圳', storeZipcode: '518000',
|
||||
packageCount: 0, grossWeightKg: 0, volumeCbm: 0, palletCount: 0, poNo: `PO-${suffix}`,
|
||||
plannedLoadingAt: '2026-12-31T10:00:00', transitMinutes: 0, payableAmount: 0, receivableAmount: 0,
|
||||
plannedLoadingAt: '2026-12-31T10:00:00', transitMinutes: 0, payableAmount: 0,
|
||||
currency: 'RMB', remark: `拖车平台业务-${suffix}`, expectedVersion: version, ...overrides }
|
||||
}
|
||||
|
||||
@@ -172,6 +172,7 @@ export async function run(context) {
|
||||
['错误柜号归属拒绝创建', { ...base, containerBookingId: (BigInt(identity.containerBookingId) + 1n).toString() }],
|
||||
['错误提单拒绝创建', { ...base, billOfLadingNo: `WRONG-${identity.suffix}` }],
|
||||
['错误承运商拒绝创建', { ...base, carrierId: (BigInt(identity.truckSupplier.supplierId) + 1n).toString() }],
|
||||
['非法拖车币种拒绝创建', { ...base, currency: 'CNY' }],
|
||||
]) {
|
||||
const response = await request(context, 'POST', TRUCKS, payload)
|
||||
context.addStep(MODULE, label, response, failure(response), `code=${codeOf(response)}`, OPTIONS)
|
||||
@@ -179,12 +180,21 @@ export async function run(context) {
|
||||
const createdResponse = await request(context, 'POST', TRUCKS, base)
|
||||
const appointment = context.apiSuccess(MODULE, '创建合法拖车预约', createdResponse, '', OPTIONS)
|
||||
const appointmentId = id(appointment?.id); if (!appointmentId) return
|
||||
context.assert(MODULE, '拖车响应不含客户字段', createdResponse,
|
||||
!Object.hasOwn(appointment, 'customerId') && !Object.hasOwn(appointment, 'customerName'), '', OPTIONS)
|
||||
context.assert(MODULE, 'RMB应付费用响应无客户及应收字段', createdResponse,
|
||||
appointment?.currency === 'RMB' && Number(appointment?.payableAmount) === 0
|
||||
&& !Object.hasOwn(appointment, 'receivableAmount')
|
||||
&& !Object.hasOwn(appointment, 'customerId') && !Object.hasOwn(appointment, 'customerName'), '', OPTIONS)
|
||||
const path = `${TRUCKS}/${appointmentId}`
|
||||
const usdResponse = await request(context, 'PUT', path,
|
||||
{ ...base, currency: 'USD', payableAmount: 12.34, expectedVersion: Number(appointment.version) })
|
||||
const usdAppointment = context.apiSuccess(MODULE, '编辑为USD应付费用', usdResponse, '', OPTIONS)
|
||||
context.assert(MODULE, 'USD应付费用保存且无应收字段', usdResponse,
|
||||
usdAppointment?.currency === 'USD' && Number(usdAppointment?.payableAmount) === 12.34
|
||||
&& !Object.hasOwn(usdAppointment || {}, 'receivableAmount'), '', OPTIONS)
|
||||
const duplicate = await request(context, 'POST', TRUCKS, base)
|
||||
context.addStep(MODULE, '同柜第二条非终态预约拒绝且零漂移', duplicate, failure(duplicate), `code=${codeOf(duplicate)}`, OPTIONS)
|
||||
const path = `${TRUCKS}/${appointmentId}`; const submitKey = `${context.marker}-truck-submit`.slice(0, 128)
|
||||
const submitBody = { expectedVersion: Number(appointment.version), reason: '幂等提交' }
|
||||
const submitKey = `${context.marker}-truck-submit`.slice(0, 128)
|
||||
const submitBody = { expectedVersion: Number(usdAppointment?.version), reason: '幂等提交' }
|
||||
const first = await request(context, 'POST', `${path}/submit`, submitBody, { 'Idempotency-Key': submitKey })
|
||||
const firstData = context.apiSuccess(MODULE, '提交拖车预约', first, '', OPTIONS)
|
||||
const replay = await request(context, 'POST', `${path}/submit`, submitBody, { 'Idempotency-Key': submitKey })
|
||||
@@ -206,9 +216,11 @@ export async function run(context) {
|
||||
context.assert(MODULE, '详情字段完整且订舱柜号身份无客户字段漂移', detailResponse,
|
||||
detail?.status === 'DISPATCHED' && detailGaps.length === 0
|
||||
&& !Object.hasOwn(detail || {}, 'customerId') && !Object.hasOwn(detail || {}, 'customerName')
|
||||
&& !Object.hasOwn(detail || {}, 'receivableAmount')
|
||||
&& detail?.currency === 'USD' && Number(detail?.payableAmount) === 12.34
|
||||
&& id(detail?.oceanBookingId) === identity.oceanBookingId
|
||||
&& id(detail?.containerBookingId) === identity.containerBookingId,
|
||||
`missing=${detailGaps.join(',') || 'none'}, oceanBookingId=${id(detail?.oceanBookingId) || 'missing'}, containerBookingId=${id(detail?.containerBookingId) || 'missing'}`, OPTIONS)
|
||||
`missing=${detailGaps.join(',') || 'none'}, currency=${detail?.currency || 'missing'}, payableAmount=${detail?.payableAmount ?? 'missing'}, oceanBookingId=${id(detail?.oceanBookingId) || 'missing'}, containerBookingId=${id(detail?.containerBookingId) || 'missing'}`, OPTIONS)
|
||||
context.createdResources.truckAppointment = { id: appointmentId, marker: context.marker, finalStatus: 'DISPATCHED',
|
||||
oceanBookingId: identity.oceanBookingId, containerBookingId: identity.containerBookingId }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user