feat(bookings): update payment eligibility logic for general contracts and one-time bookings

This commit is contained in:
Marshal
2026-06-22 11:40:35 +00:00
parent b777da4bd7
commit ff039bd440
3 changed files with 17 additions and 3 deletions

View File

@@ -3,10 +3,11 @@
* Times run in EAT so the 07:00/10:00/… boundaries match the local operating clock.
*/
/** Batch boundaries — every 3h from 07:00 (the 07:0010:00 intake settles at 10:00, etc.). */
/** Batch boundaries — every 3h from 00:00 (0003, 0306, … 2124), matching the board windows. */
// export const BATCH_CRON = '0 7,10,13,16,19,22 * * *';
// export const BATCH_CRON = '*/3 * * * *';
export const BATCH_CRON = '*/5 * * * *';
// export const BATCH_CRON = '0 */3 * * *';//
export const BATCH_TIMEZONE = 'Africa/Addis_Ababa';

View File

@@ -50,8 +50,15 @@ export function ReadonlyBookingView({ booking }: { booking: Freight.IBooking })
});
const pricing = booking.pricingBreakdown;
// A general contract is paid once it's FULLY_EXECUTED (signed) — it never
// enters batch selection. A one-time booking can only pay once it's been
// SELECTED_FOR_BATCH (assigned a slot with a pay window).
const isGeneralContract = booking.bookingType === "GENERAL_CONTRACT";
const canPay =
status === "SELECTED_FOR_BATCH" && booking.paymentStatus !== "PAID";
booking.paymentStatus !== "PAID" &&
(isGeneralContract
? status === "FULLY_EXECUTED"
: status === "SELECTED_FOR_BATCH");
const showCountdown = canPay && !!booking.paymentDeadline;
const isExpired = status === "EXPIRED";
const isPendingConsolidation = status === "PENDING_CONSOLIDATION";

View File

@@ -180,6 +180,9 @@ function PrimaryAction({
}) {
const { status, id } = booking;
const go = () => onNavigate(`/bookings/${id}`);
// A general contract is payable as soon as it's FULLY_EXECUTED (signed); a
// one-time booking only after it's SELECTED_FOR_BATCH.
const isGeneralContract = booking.bookingType === "GENERAL_CONTRACT";
if (status === "DRAFT") {
return (
<Button
@@ -210,7 +213,10 @@ function PrimaryAction({
</Button>
);
}
if (status === "SELECTED_FOR_BATCH" && booking.paymentStatus !== "PAID") {
const payableStatus = isGeneralContract
? "FULLY_EXECUTED"
: "SELECTED_FOR_BATCH";
if (status === payableStatus && booking.paymentStatus !== "PAID") {
return <PayNowButton booking={booking} />;
}
return (