mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 03:10:54 +00:00
feat: fuel surcharge per lane and cargo type
This commit is contained in:
@@ -302,15 +302,18 @@ export class ContractPricingService {
|
||||
r.cargoTypeId === scope.cargoTypeId,
|
||||
);
|
||||
if (fuel && Number(fuel.rateValue) > 0) {
|
||||
const base = Number(fuel.baseLiters ?? 0);
|
||||
// Per-liter collapses to one flat total (base liters × rate value) —
|
||||
// the customer only sees the final price, and booking pricing bills
|
||||
// the same flat figure once (see RuleEngineService.fuelCharges).
|
||||
const perLiter = fuel.rateUnit === 'PER_LITER';
|
||||
const total = perLiter
|
||||
? Number(fuel.baseLiters ?? 0) * Number(fuel.rateValue)
|
||||
: Number(fuel.rateValue);
|
||||
lineItems.push({
|
||||
code: 'FUEL_SURCHARGE',
|
||||
label:
|
||||
fuel.rateUnit === 'PER_LITER'
|
||||
? `Fuel surcharge (${scope.cargoType.cargoTypeName}, ${base} liters)`
|
||||
: `Fuel surcharge (${scope.cargoType.cargoTypeName})`,
|
||||
unit: toContractUnit(fuel.rateUnit),
|
||||
unitPrice: convert(Number(fuel.rateValue)),
|
||||
label: `Fuel surcharge (${scope.cargoType.cargoTypeName})`,
|
||||
unit: perLiter ? 'flat' : toContractUnit(fuel.rateUnit),
|
||||
unitPrice: convert(total),
|
||||
cargoTypeCode: scope.cargoType.code ?? null,
|
||||
conditionalOn: 'has_fuel',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user