mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
feat: fuel surcharge per lane and cargo type
This commit is contained in:
@@ -475,13 +475,16 @@ describe('RuleEngineService — fuel surcharge (per lane + cargo type)', () => {
|
||||
const fuelMods = (result: Awaited<ReturnType<RuleEngineService['evaluate']>>) =>
|
||||
result.appliedModifiers.filter((m) => m.surchargeCode === 'FUEL_SURCHARGE');
|
||||
|
||||
it('PER_LITER bills base liters × rate value once, regardless of wagons', async () => {
|
||||
it('PER_LITER collapses to one flat total (base liters × rate value), regardless of wagons', async () => {
|
||||
const result = await buildService([fuelPerLiter]).evaluate(fuelInput());
|
||||
const mods = fuelMods(result);
|
||||
expect(mods).toHaveLength(1);
|
||||
expect(mods[0].triggerValue).toBe(100);
|
||||
// Flat: the customer sees only the total, and a frozen contract snapshot
|
||||
// (also stored flat) multiplies it by quantity 1 — never by the liters.
|
||||
expect(mods[0].triggerValue).toBe(1);
|
||||
expect(mods[0].unitPriceUsd).toBe(200);
|
||||
expect(mods[0].calculatedAmount).toBe(200);
|
||||
expect(mods[0].billingUnit).toBe('PER_LITER');
|
||||
expect(mods[0].billingUnit).toBe('FLAT');
|
||||
});
|
||||
|
||||
it('PER_WAGON bills the wagons the cargo occupies', async () => {
|
||||
|
||||
Reference in New Issue
Block a user