适配财务验收FBA内部编号
This commit is contained in:
@@ -18,6 +18,9 @@ test('finance fixture module is independently exported and marker isolated', ()
|
||||
test('fixture covers weight, volume, manual order, and container allocation contracts', () => {
|
||||
for (const basis of ['WEIGHT_KG', 'VOLUME_CBM', 'MANUAL_ORDER_FEE', 'CONTAINER_SHARED']) assert.match(source, new RegExp(basis))
|
||||
assert.match(source, /chargeMode: pricingProfile\.chargeUnit/)
|
||||
assert.match(source, /warehouse-admin\?tenantId=0&page=/)
|
||||
assert.match(source, /item\?\.internalCode && item\?\.warehouseCode/)
|
||||
assert.match(source, /fbaInternalCodes\.has\(String\(rate\.destinationCode\)/)
|
||||
assert.match(source, /customer-rules\/versions\?tenantId=/)
|
||||
assert.match(source, /taxMode: 'TAX_EXCLUDED'/)
|
||||
assert.match(source, /inbound\?\.summary\?\.businessType \|\| profile\.businessType/)
|
||||
|
||||
@@ -298,6 +298,23 @@ async function uploadVoucher(context, customerId) {
|
||||
|
||||
async function loadPricingEvidence(context) {
|
||||
if (context.financeFixtureHooks?.loadPricingEvidence) return context.financeFixtureHooks.loadPricingEvidence(context)
|
||||
const fbaInternalCodes = new Set()
|
||||
let warehousePage = 1
|
||||
let warehouseTotal = 0
|
||||
do {
|
||||
const warehouseResponse = await context.request('GET',
|
||||
`/api/platform/v1/warehouse-admin?tenantId=0&page=${warehousePage}&size=200&warehouseType=FBA&status=ACTIVE`)
|
||||
const warehouseResult = context.apiSuccess(MODULE, `读取具备内部编号的 FBA 仓第 ${warehousePage} 页`,
|
||||
warehouseResponse, '', OPTIONS)
|
||||
const warehouses = rows(warehouseResult)
|
||||
warehouseTotal = Number(warehouseResult?.total || warehouses.length)
|
||||
warehouses.filter((item) => item?.internalCode && item?.warehouseCode)
|
||||
.forEach((item) => fbaInternalCodes.add(String(item.warehouseCode).trim().toUpperCase()))
|
||||
if (warehouses.length === 0) break
|
||||
warehousePage += 1
|
||||
} while ((warehousePage - 1) * 200 < warehouseTotal)
|
||||
context.assert(MODULE, '自动计费候选使用已配置内部编号的 FBA 仓', null,
|
||||
fbaInternalCodes.size > 0, `warehouses=${fbaInternalCodes.size}`, OPTIONS)
|
||||
const response = await context.request('GET', '/api/platform/v1/fba-pricing/carrier-rates/price-books?status=ACTIVE')
|
||||
const versions = context.apiSuccess(MODULE, '读取真实生效价格配置', response, '', OPTIONS)
|
||||
const active = rows(versions).filter((item) => item?.status === 'ACTIVE')
|
||||
@@ -308,6 +325,7 @@ async function loadPricingEvidence(context) {
|
||||
const rates = Array.isArray(detail?.rates) ? detail.rates : []
|
||||
for (const rate of rates) {
|
||||
if (rate?.destinationType !== 'FBA' || !rate?.originWarehouseId || !rate?.channelCode || !rate?.pricingTaxMode || !rate?.destinationCode) continue
|
||||
if (!fbaInternalCodes.has(String(rate.destinationCode).trim().toUpperCase())) continue
|
||||
if (!['KG', 'CBM'].includes(rate.chargeUnit) || profiles.some((item) => item.chargeUnit === rate.chargeUnit)) continue
|
||||
const matches = rates.filter((item) => id(item.originWarehouseId) === id(rate.originWarehouseId)
|
||||
&& item.channelCode === rate.channelCode && item.destinationType === rate.destinationType
|
||||
|
||||
Reference in New Issue
Block a user