优化
This commit is contained in:
@@ -49,16 +49,17 @@ async function runOwnedFixture(context) {
|
||||
}
|
||||
|
||||
async function loadPayableInputs(context) {
|
||||
const [feeItemsResponse, partnersResponse] = await Promise.all([
|
||||
const [feeItemsResponse, suppliersResponse] = await Promise.all([
|
||||
context.request('GET', '/api/platform/v1/fee-items?page=1&pageSize=200'),
|
||||
context.request('GET', '/api/platform/v1/partners?page=1&size=200&status=ACTIVE'),
|
||||
context.request('GET', '/api/platform/v1/suppliers?page=1&size=200&status=ACTIVE&category=BOOKING'),
|
||||
])
|
||||
const feeItems = rows(data(feeItemsResponse))
|
||||
const partners = rows(data(partnersResponse))
|
||||
const suppliers = rows(data(suppliersResponse))
|
||||
return {
|
||||
feeItem: feeItems.find((item) => item?.status === 'ACTIVE' && item?.warehousePayable === true) || null,
|
||||
supplier: partners.find((item) => item?.status === 'ACTIVE' && item?.id) || null,
|
||||
response: !ok(feeItemsResponse) ? feeItemsResponse : partnersResponse,
|
||||
feeItem: feeItems.find((item) => item?.status === 'ACTIVE' && item?.warehousePayable === true
|
||||
&& /BOOKING|FREIGHT|OCEAN|SHIPPING|订舱|海运|运费/i.test(`${item.feeCode || item.code || ''} ${item.feeName || item.name || ''}`)) || null,
|
||||
supplier: suppliers.find((item) => item?.status === 'ACTIVE' && item?.category === 'BOOKING' && item?.id) || null,
|
||||
response: !ok(feeItemsResponse) ? feeItemsResponse : suppliersResponse,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ async function createWaybillPayable(context, fixture, order, input, index) {
|
||||
const path = `/api/platform/v1/inbounds/${encodeURIComponent(inboundId)}/fee-details?accountId=${encodeURIComponent(fixture.customerId)}`
|
||||
const body = { feeItemId: Number(input.feeItem.id), direction: 'PAYABLE', businessDate: dateOffset(-3 - index),
|
||||
unitPrice: 90 + index * 10, amount: 90 + index * 10, currency: 'CNY', settlementIncluded: true,
|
||||
partnerId: id(input.supplier.id), partnerName: input.supplier.partnerName || null,
|
||||
partnerId: id(input.supplier.id), partnerName: input.supplier.name || null,
|
||||
remark: `${context.marker}-WAYBILL-PAYABLE-${index + 1}` }
|
||||
const response = await write(context, 'POST', path, body, `waybill-payable-${index + 1}`)
|
||||
const detail = context.apiSuccess(MODULE, `创建第 ${index + 1} 条独占运单 PAYABLE 来源`, response,
|
||||
@@ -82,7 +83,7 @@ async function createWaybillPayable(context, fixture, order, input, index) {
|
||||
return { sourceFeeId, inboundId, orderId: id(order.orderId),
|
||||
waybillId: id(order.waybillId ?? order.shipmentId ?? order.orderNo),
|
||||
businessDate: body.businessDate, amount: body.amount,
|
||||
supplierId: id(input.supplier.id), supplierName: input.supplier.partnerName || null }
|
||||
supplierId: id(input.supplier.id), supplierName: input.supplier.name || null }
|
||||
}
|
||||
|
||||
async function resolvePoolSources(context, fixture, created) {
|
||||
|
||||
Reference in New Issue
Block a user