feat: implement manual consolidation candidate selection logic and update related tests

This commit is contained in:
marshalyordanos
2026-09-04 13:52:19 +03:00
parent eaa006a932
commit ca84aac456
6 changed files with 210 additions and 93 deletions

View File

@@ -2007,7 +2007,7 @@ export default function GlCreateBookingForm() {
shared wagon — each booking is still priced and invoiced
separately.
</Text>
<Switch
{/* <Switch
checked={consolidateOdd}
color="edr-green"
label="Share a wagon with another booking"
@@ -2015,7 +2015,7 @@ export default function GlCreateBookingForm() {
consolidateTouchedRef.current = true;
setConsolidateOdd(e.currentTarget.checked);
}}
/>
/> */}
{consolidateOdd ? (
<Group gap={10} align="center" wrap="wrap">
<Button

View File

@@ -18,8 +18,11 @@ import type { ConsolidationCandidate } from "@/services/contracts.service";
/**
* Picker for the booking that shares this booking's wagon. The server has
* already narrowed the list to bookings that can legally pair — same route and
* direction, same booking day, customs clearing, an odd 20ft count of their own
* and not already linked to someone else — so every row here is a valid choice.
* direction, customs clearing, an odd 20ft count of their own and not already
* linked to someone else — so every row here is a valid choice. Booking day is
* deliberately not part of that filter: both halves are completed together onto
* the departure date chosen on this form, so the partner's current date is
* overwritten either way.
*/
interface Props {
opened: boolean;
@@ -55,8 +58,9 @@ export function ConsolidationPartnerPicker({
Pick the parent booking
</Text>
<Text fz="xs" c="dimmed">
Customs bookings on the same route and booking day that also carry
an odd number of 20ft containers.
Customs bookings on the same route that also carry an odd number
of 20ft containers. Both halves ride the departure date you pick on
this form.
</Text>
</Box>
</Group>
@@ -84,10 +88,9 @@ export function ConsolidationPartnerPicker({
title="No booking available to share this wagon"
>
<Text fz="sm">
No other customs booking on this route and booking day currently
carries an odd number of 20ft containers. Either wait for one, or
switch the shared-wagon option off and book an even number of 20ft
containers.
No other customs booking on this route currently carries an odd
number of 20ft containers. Either wait for one, or switch the
shared-wagon option off and book an even number of 20ft containers.
</Text>
</Alert>
) : (
@@ -116,6 +119,14 @@ export function ConsolidationPartnerPicker({
{" · "}
{`${candidate.ft20Quantity} × 20ft`}
</Text>
{/* The partner's current date, shown because completing the
pair moves it onto the date chosen on this form. */}
{candidate.scheduledDate ? (
<Text fz={12} c="dimmed" mt={2}>
Currently booked for{" "}
{new Date(candidate.scheduledDate).toLocaleDateString()}
</Text>
) : null}
</Box>
<Button
size="xs"