mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
A truck holds one 40ft or two 20ft, a container booking takes no more trucks than it has containers, and a bulk booking takes trucks until its tonnage is hauled away. The same physics whoever drives, but the rule was written out four times — addTruck, updateTruck, departTruck and LastMileService — beside a byte-identical container-size query. Copies drift: that is how the self-haul guard ended up enforced on one side only. The bulk cap was the real gap. EDR summed net_weight_tons of departed trucks and refused another once the booking was drawn down. The customer side had no cap at all: for bulk it skipped straight past every check, so a self-haul bulk booking could take unlimited trucks. It could not simply reuse the EDR sum. customer_truck_assignments had no net and no tare, only a gross_weight_kg that holds tonnes despite its name and that nothing in the live flow ever wrote — release() recorded exit weights against the EDR table alone, which is why all five customer trucks on dev have neither weight nor departure. Any drawdown keyed on it would have summed zero forever and never fired. So the customer table now carries tare_weight_tons and net_weight_tons to match the EDR one, release() records the customer truck's exit as it already did for EDR, and the drawdown counts both sources — a booking hauls by one path or the other and "until no tonnage is left" means the same either way. Also locks a load once its truck has arrived on the EDR side, which the customer side has always done, and fills the arrival form from the customer truck on file: the prefill read booking.customer_truck_*, which multi-truck self-haul leaves null, so a booking with a truck assigned opened blank. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>