mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
changes
This commit is contained in:
@@ -379,6 +379,25 @@ describe('BookingPricingService — customs clearance fee billed on the booking
|
||||
expect(line!.amount).toBe(600);
|
||||
});
|
||||
|
||||
it('the fee scoped to the booking commodity wins over the catch-all', async () => {
|
||||
const service = makeService({
|
||||
liveRates: [
|
||||
{ ...bulkFeePerTon, id: 'rate-cc-catchall', rateValue: 5 } as Rate,
|
||||
{
|
||||
...bulkFeePerTon,
|
||||
id: 'rate-cc-sugar',
|
||||
rateValue: 9,
|
||||
cargoTypeId: 'cargo-1',
|
||||
} as Rate,
|
||||
],
|
||||
});
|
||||
const result = await service.computePriceForBooking(bulkBooking());
|
||||
|
||||
const line = result.lineItems.find((l) => l.code === 'CUSTOMS_CLEARANCE');
|
||||
expect(line!.unitAmount).toBe(9); // commodity rate, not the 5 USD catch-all
|
||||
expect(line!.amount).toBe(1080);
|
||||
});
|
||||
|
||||
it('bills a PER_WAGON bulk fee on ceil(tons ÷ wagon capacity)', async () => {
|
||||
const service = makeService({
|
||||
liveRates: [{ ...bulkFeePerTon, rateUnit: 'PER_WAGON', rateValue: 50 } as Rate],
|
||||
|
||||
@@ -1028,8 +1028,15 @@ export class BookingPricingService {
|
||||
|
||||
// Bulk — one fee for the whole booking. The bulk snapshot and the legacy
|
||||
// flat snapshot share the CUSTOMS_CLEARANCE code; both are the agreed fee.
|
||||
// Live lookup: the rate scoped to the booking's commodity wins; a
|
||||
// commodity-less rate (legacy) is the catch-all fallback.
|
||||
const frozen = this.frozenRateByCode(frozenRates, 'CUSTOMS_CLEARANCE', currency);
|
||||
const live = onLeg.find((r) => !r.containerTypeId);
|
||||
const live =
|
||||
(booking.cargoTypeId
|
||||
? onLeg.find(
|
||||
(r) => !r.containerTypeId && r.cargoTypeId === booking.cargoTypeId,
|
||||
)
|
||||
: undefined) ?? onLeg.find((r) => !r.containerTypeId && !r.cargoTypeId);
|
||||
if (!frozen && !live) {
|
||||
blocked.push(missingRateMessage('bulk cargo'));
|
||||
return { lineItems, usedRates, blocked };
|
||||
|
||||
Reference in New Issue
Block a user