fix(booking-edit): reconstruct pallet dims with 120x80 base (not a cube)
La reprise reconstruisait un cube (cbrt du volume) au lieu de la base palette standard, d'ou des longueur/largeur/hauteur incorrectes. Pour une palette on reconstitue desormais 120x80 cm et on deduit la hauteur du volume (ex: 0.96 CBM -> 120x80x100). Les colis restent en cube equivalent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
c5f823f8b7
commit
64de600292
@ -185,14 +185,33 @@ export default function AdvancedSearchPage() {
|
|||||||
// totals (the booking only stores totals, not individual packages).
|
// totals (the booking only stores totals, not individual packages).
|
||||||
const q = pallets > 0 ? pallets : 1;
|
const q = pallets > 0 ? pallets : 1;
|
||||||
const perVolM3 = vol > 0 ? vol / q : 0;
|
const perVolM3 = vol > 0 ? vol / q : 0;
|
||||||
const sideCm = perVolM3 > 0 ? Math.cbrt(perVolM3) * 100 : 0;
|
const isPalette = pallets > 0;
|
||||||
|
|
||||||
|
// The booking only stores aggregate totals, not per-package dimensions. For
|
||||||
|
// pallets we reconstruct the standard EUR pallet footprint (120×80 cm) and
|
||||||
|
// derive the height from the volume — so a default 0.96 CBM pallet comes back
|
||||||
|
// as 120×80×100. For loose parcels we fall back to a cube of equal volume.
|
||||||
|
let length: number;
|
||||||
|
let width: number;
|
||||||
|
let height: number;
|
||||||
|
if (isPalette) {
|
||||||
|
length = 120;
|
||||||
|
width = 80;
|
||||||
|
const baseM2 = (length / 100) * (width / 100); // 0.96 m²
|
||||||
|
height = perVolM3 > 0 ? Math.round((perVolM3 / baseM2) * 100 * 100) / 100 : 100;
|
||||||
|
} else {
|
||||||
|
const sideCm = perVolM3 > 0 ? Math.round(Math.cbrt(perVolM3) * 100 * 100) / 100 : 0;
|
||||||
|
length = sideCm;
|
||||||
|
width = sideCm;
|
||||||
|
height = sideCm;
|
||||||
|
}
|
||||||
const pkg = {
|
const pkg = {
|
||||||
type: (pallets > 0 ? 'palette' : 'colis') as Package['type'],
|
type: (isPalette ? 'palette' : 'colis') as Package['type'],
|
||||||
quantity: q,
|
quantity: q,
|
||||||
length: sideCm,
|
length,
|
||||||
width: sideCm,
|
width,
|
||||||
height: sideCm,
|
height,
|
||||||
weight: wgt > 0 ? wgt / q : 0,
|
weight: wgt > 0 ? Math.round((wgt / q) * 100) / 100 : 0,
|
||||||
stackable: true,
|
stackable: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user