mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 20:40:55 +00:00
Merge pull request #942 from Tria-plc/freight_feature/usermanagement
revert back the clerance payment
This commit is contained in:
@@ -65,8 +65,12 @@ export function computeGlShipmentTotal(
|
||||
(i) =>
|
||||
i.containerSize === line.containerSize &&
|
||||
i.unit === "per_container" &&
|
||||
!i.conditionalOn,
|
||||
) ?? rateFor((i) => i.containerSize === line.containerSize);
|
||||
!i.conditionalOn &&
|
||||
!i.isClearance,
|
||||
) ??
|
||||
rateFor(
|
||||
(i) => i.containerSize === line.containerSize && !i.isClearance,
|
||||
);
|
||||
if (rate) {
|
||||
lines.push({
|
||||
label: rate.label,
|
||||
@@ -123,7 +127,9 @@ export function computeGlShipmentTotal(
|
||||
} else {
|
||||
const qty = q.bulkQuantity;
|
||||
const rate =
|
||||
rateFor((i) => i.unit === "per_ton" || i.unit === "per_item") ?? items[0];
|
||||
rateFor(
|
||||
(i) => (i.unit === "per_ton" || i.unit === "per_item") && !i.isClearance,
|
||||
) ?? items[0];
|
||||
if (rate && qty > 0) {
|
||||
lines.push({
|
||||
label: rate.label,
|
||||
@@ -159,6 +165,36 @@ export function computeGlShipmentTotal(
|
||||
}
|
||||
}
|
||||
|
||||
// Customs clearance service fee — billed on the booking invoice with the
|
||||
// freight. Container fees estimate per size (per box, or per wagon: two 20ft
|
||||
// share one); bulk per-ton scales by tonnage. Bulk per-wagon fees depend on
|
||||
// the wagon capacity the train stocks — shown at real pricing, not estimated.
|
||||
for (const cl of items.filter((i) => i.isClearance)) {
|
||||
let qty = 0;
|
||||
if (q.isContainer) {
|
||||
const boxes = q.containers
|
||||
.filter((c) => c.containerSize === cl.containerSize)
|
||||
.reduce((s, c) => s + Number(c.quantity || 0), 0);
|
||||
qty =
|
||||
cl.unit === "per_wagon"
|
||||
? Math.ceil(boxes * (cl.containerSize === "40ft" ? 1 : 0.5))
|
||||
: boxes;
|
||||
} else if (cl.unit === "per_ton") {
|
||||
qty = q.bulkQuantity;
|
||||
} else if (cl.unit === "flat") {
|
||||
qty = 1;
|
||||
}
|
||||
if (qty > 0) {
|
||||
lines.push({
|
||||
label: cl.label,
|
||||
unitPrice: cl.unitPrice,
|
||||
unit: cl.unit,
|
||||
quantity: qty,
|
||||
amount: cl.unitPrice * qty,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const total = lines.reduce((s, l) => s + l.amount, 0);
|
||||
return { currency, lines, total };
|
||||
}
|
||||
@@ -167,6 +203,7 @@ export function computeGlShipmentTotal(
|
||||
export function formatRateUnit(unit: Freight.ContractRateUnit | string): string {
|
||||
const map: Record<string, string> = {
|
||||
per_container: "container",
|
||||
per_wagon: "wagon",
|
||||
per_ton: "ton",
|
||||
per_item: "item",
|
||||
per_km: "km",
|
||||
|
||||
@@ -209,6 +209,12 @@ const RuleEngineFormDialog = ({
|
||||
next.containerTypeId = "";
|
||||
next.cargoTypeId = "";
|
||||
}
|
||||
// Cargo kind (customs / lashing) decides both the container-type scope
|
||||
// and the legal units (container → per box/wagon, bulk → per ton/wagon).
|
||||
if (name === "cargoKind") {
|
||||
next.containerTypeId = "";
|
||||
next.rateUnit = "";
|
||||
}
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user