feat: fuel surcharge per lane and cargo type

This commit is contained in:
Marshal
2026-08-12 13:47:53 +00:00
parent dd39c2be7c
commit ff3cee12e3
4 changed files with 42 additions and 21 deletions

View File

@@ -193,17 +193,26 @@ export class ContractRateScheduleBuilder {
return rate.tradeDirection === want;
}
/** Fuel row — the lane matters, so it rides along in the charge label. */
/**
* Fuel row — the lane matters, so it rides along in the charge label.
* Per-liter collapses to one flat total (base liters × rate value); the
* customer only ever sees the final price.
*/
private fuelRow(rate: Rate): RateScheduleRow {
const origin = rate.originYard?.label ?? rate.originYard?.code ?? '—';
const destination =
rate.destinationYard?.label ?? rate.destinationYard?.code ?? '—';
const perLiter = rate.rateUnit === 'PER_LITER';
return {
route: `Fuel surcharge (${origin}${destination})`,
cargo: this.cargoLabel(rate),
currency: rate.currency,
amount: this.formatAmount(rate.rateValue),
unit: this.unitLabel(rate.rateUnit),
amount: this.formatAmount(
perLiter
? Number(rate.baseLiters ?? 0) * Number(rate.rateValue)
: rate.rateValue,
),
unit: perLiter ? 'flat' : this.unitLabel(rate.rateUnit),
};
}