18 lines
1.0 KiB
JavaScript
18 lines
1.0 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
import { orderBillingMetric } from './orderDetailSummary.ts'
|
|
|
|
test('detail uses the published billing quantity without substituting physical gross weight', () => {
|
|
const billing = { inbound: { summary: { actualGrossWeightKg: 23, chargeableWeightKg: null } },
|
|
billingBasis: { chargeUnit: 'KG', chargeableQuantity: 17.0006, chargeableWeightKg: null } }
|
|
assert.deepEqual(orderBillingMetric(billing, null), { label: '计费重量', quantity: 17.0006, unit: 'kg' })
|
|
assert.equal(orderBillingMetric(billing, null).quantity.toLocaleString('zh-CN'), '17.001')
|
|
})
|
|
|
|
test('volume charging retains its real unit and missing billing does not invent a quantity', () => {
|
|
assert.deepEqual(orderBillingMetric({ billingBasis: { chargeUnit: 'CBM', chargeableQuantity: 0.102 } }, 23),
|
|
{ label: '计费体积', quantity: 0.102, unit: 'm³' })
|
|
assert.equal(orderBillingMetric(null, null).quantity, null)
|
|
assert.equal(orderBillingMetric(null, 0).quantity, 0)
|
|
})
|