feat(rates): last-mile rate rules with bulk per-ton-km and container distance bands

- rates: min_km/max_km columns, PER_TON_KM unit, ETB|USD currency for last mile
- extend UQ_rates_pattern with band start; overlap + shape validation
- shared last-mile charge resolver; approve-dialog price estimate endpoint
- delivery-fee invoice prices via rules, falls back to vehicle price/km
- backoffice: last-mile rate form (mode, container type, band, currency)
This commit is contained in:
Hagernesh
2026-08-05 22:12:40 +00:00
parent 6125f644b1
commit 5c8c68e990
25 changed files with 880 additions and 20 deletions

View File

@@ -727,8 +727,16 @@ export class BookingPricingService {
for (const leg of legs) {
if (!leg.active) continue;
// New-style last-mile rates (PER_TON_KM bulk / distance-banded PER_KM)
// price the operational leg via last-mile-charge.util, not the booking
// quote — this legacy lookup must never pick one up.
const rate = liveRates.find(
(r) => r.rateType === leg.rateType && r.currency === 'USD' && r.status === 'LIVE',
(r) =>
r.rateType === leg.rateType &&
r.currency === 'USD' &&
r.status === 'LIVE' &&
r.rateUnit !== 'PER_TON_KM' &&
r.minKm == null,
);
if (!rate) continue;