test: use active suppliers for finance fixtures
This commit is contained in:
@@ -3,7 +3,8 @@ import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { buildContainerCostBody, normalizeFinanceFixtureSources, run } from './finance-full-fixtures.mjs'
|
||||
import { buildContainerCostBody, normalizeFinanceFixtureSources, run,
|
||||
supplierCategoryForFeeItem } from './finance-full-fixtures.mjs'
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url))
|
||||
const source = fs.readFileSync(path.join(here, 'finance-full-fixtures.mjs'), 'utf8')
|
||||
@@ -30,10 +31,13 @@ test('fee writes use verified Firstleg paths and do not fabricate historical IDs
|
||||
assert.match(source, /chargeUnit === 'CBM'/)
|
||||
})
|
||||
|
||||
test('PAYABLE fee selection uses the formal warehousePayable flag without name heuristics', () => {
|
||||
test('PAYABLE fee selection requires the formal flag and a Finance-supported supplier category', () => {
|
||||
const selector = source.slice(source.indexOf('async function loadFeeItem'), source.indexOf('async function createManualFee'))
|
||||
assert.match(selector, /item\.warehousePayable === true/)
|
||||
assert.doesNotMatch(selector, /BOOKING\|FREIGHT|订舱|海运|运费/)
|
||||
assert.match(selector, /supplierCategoryForFeeItem\(item\)/)
|
||||
assert.equal(supplierCategoryForFeeItem({ feeCode: 'FBA_HEAD_FREIGHT', feeName: '头程运费' }), 'BOOKING')
|
||||
assert.equal(supplierCategoryForFeeItem({ code: 'CUSTOMS_CLEARANCE', name: '报关费' }), 'CUSTOMS')
|
||||
assert.equal(supplierCategoryForFeeItem({ feeCode: 'UNSUPPORTED', feeName: '操作费' }), null)
|
||||
})
|
||||
|
||||
test('automatic fee fixture completes the reviewed pricing workflow without recalculating', () => {
|
||||
@@ -98,7 +102,8 @@ function hookSet({ missing = false } = {}) {
|
||||
createOrder: async (context, suffix) => ({ marker: `${context.marker}-${suffix}`, tenantId: '701',
|
||||
orderId: `O-${suffix}`, orderNo: `NO-${suffix}`, waybillId: suffix === 'AUTO1' ? 'WB-1' : null, inboundId: `I-${suffix}` }),
|
||||
measureOrder: async (context, resource) => ({ ...resource, measurementId: `M-${resource.orderId}`, actualWeightKg: 12.5, totalVolumeCbm: 0.072 }),
|
||||
loadFeeItem: async (context, direction) => ({ id: direction === 'PAYABLE' ? '902' : '901', status: 'ACTIVE' }),
|
||||
loadFeeItem: async (context, direction) => ({ id: direction === 'PAYABLE' ? '902' : '901', status: 'ACTIVE',
|
||||
feeCode: direction === 'PAYABLE' ? 'FBA_HEAD_FREIGHT' : 'RECEIVABLE_SERVICE' }),
|
||||
loadSupplier: async () => missing ? null : ({ id: 'SUPPLIER-1', name: '订舱供应商一', category: 'BOOKING', status: 'ACTIVE' }),
|
||||
uploadVoucher: async () => missing ? null : 'VOUCHER-1',
|
||||
verifyContainerCostSnapshotInput: async () => ({ valid: true, items: [{ accountId: '701', orderId: 'O-AUTO1', volumeCbm: 0.072 }] }),
|
||||
@@ -134,12 +139,15 @@ test('run behavior emits consumer shape, both billing bases, distinct dates, sup
|
||||
assert.ok(new Set(fixture.feeSources.map((item) => item.businessDate)).size >= 2)
|
||||
assert.equal(fixture.supplier.supplierId, 'SUPPLIER-1')
|
||||
assert.equal(fixture.supplier.supplierName, '订舱供应商一')
|
||||
assert.equal(fixture.supplier.category, 'BOOKING')
|
||||
assert.equal(fixture.voucherFileId, 'VOUCHER-1')
|
||||
assert.ok(Array.isArray(fixture.allocations))
|
||||
assert.ok(fixture.feeSources.filter((item) => item.direction === 'RECEIVABLE').length >= 4)
|
||||
assert.ok(new Set(fixture.feeSources.filter((item) => item.direction === 'RECEIVABLE').map((item) => item.businessDate)).size >= 2)
|
||||
assert.equal(fixture.feeSources.every((item) => item.feeSourceId && item.customerId === fixture.customerId
|
||||
&& item.businessDate && (item.waybillId || item.shipmentId || item.orderNo) && item.marker === context.marker), true)
|
||||
assert.equal(fixture.feeSources.filter((item) => item.direction === 'PAYABLE').every((item) => item.supplierId
|
||||
&& item.supplierName && item.supplierCategory === fixture.supplier.category), true)
|
||||
})
|
||||
|
||||
test('run preserves real price-row profiles when creating automatic orders', async () => {
|
||||
|
||||
Reference in New Issue
Block a user