mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 18:20:57 +00:00
feat: enhance cargo details handling and add document clearance features
- Improved handling of commodity selection in the cargo details form to prevent unwanted resets on re-renders. - Added `isReefer` flag to the CreateBookingDto interface for booking-level refrigerated status. - Introduced a new configuration file for clearance tabs to manage document clearance views. - Implemented DocumentClearanceDetailPage for detailed review and management of clearance documents. - Created DocumentClearanceListPage for listing and filtering clearance bookings with enhanced UI components.
This commit is contained in:
@@ -57,6 +57,12 @@ export interface BookingEvaluationInput {
|
||||
allowConsolidation?: boolean;
|
||||
shippingLineId?: string | null;
|
||||
totalWagons: number;
|
||||
/**
|
||||
* Total bulk tonnage on the booking (cargoTotalWeightVgm). Used to scale
|
||||
* PER_TON surcharges (e.g. the bulk reefer surcharge). 0/undefined for
|
||||
* container freight, which is scaled by container count instead.
|
||||
*/
|
||||
bulkTons?: number;
|
||||
containers: BookingContainerEvalInput[];
|
||||
}
|
||||
|
||||
@@ -224,16 +230,46 @@ export class RuleEngineService {
|
||||
});
|
||||
if (!triggered) continue;
|
||||
|
||||
let triggerValue: number | null = null;
|
||||
let calculatedAmount = Number(rate.rateValue);
|
||||
// Surcharges scale by their own rateUnit, so the same trigger can bill the
|
||||
// right way per freight shape — e.g. a PER_TON reefer rate multiplies the
|
||||
// bulk tonnage, while a PER_CONTAINER reefer rate multiplies the container
|
||||
// count. triggerValue records the quantity billed (shown on the breakdown).
|
||||
const rateValue = Number(rate.rateValue);
|
||||
const containerCount = input.containers.reduce(
|
||||
(sum, c) => sum + Number(c.quantity || 0),
|
||||
0,
|
||||
);
|
||||
const overweightExcessTons = containerWeightResults.reduce(
|
||||
(sum, r) => sum + (r.overweightExcessTons ?? 0),
|
||||
0,
|
||||
);
|
||||
|
||||
// Per-ton surcharges (typically OVERWEIGHT) bill against the excess tons.
|
||||
if (rate.rateUnit === 'PER_TON' && rate.trigger === 'OVERWEIGHT') {
|
||||
triggerValue = containerWeightResults.reduce(
|
||||
(sum, r) => sum + (r.overweightExcessTons ?? 0),
|
||||
0,
|
||||
);
|
||||
calculatedAmount = triggerValue * Number(rate.rateValue);
|
||||
let triggerValue: number | null = null;
|
||||
let calculatedAmount: number;
|
||||
|
||||
switch (rate.rateUnit) {
|
||||
case 'PER_TON':
|
||||
// OVERWEIGHT bills the excess tons; every other PER_TON surcharge
|
||||
// (e.g. bulk reefer) bills the full bulk tonnage.
|
||||
triggerValue =
|
||||
rate.trigger === 'OVERWEIGHT'
|
||||
? overweightExcessTons
|
||||
: Number(input.bulkTons ?? 0);
|
||||
calculatedAmount = triggerValue * rateValue;
|
||||
break;
|
||||
case 'PER_CONTAINER':
|
||||
triggerValue = containerCount;
|
||||
calculatedAmount = triggerValue * rateValue;
|
||||
break;
|
||||
case 'PER_WAGON':
|
||||
triggerValue = input.totalWagons;
|
||||
calculatedAmount = triggerValue * rateValue;
|
||||
break;
|
||||
case 'FLAT':
|
||||
default:
|
||||
// FLAT (and any unknown unit) bills once.
|
||||
calculatedAmount = rateValue;
|
||||
break;
|
||||
}
|
||||
|
||||
// Safety guard: never include a surcharge with a non-positive amount (a
|
||||
|
||||
Reference in New Issue
Block a user