Enhance contract management by adding booking windows section and updating invoice logic for offloaded cargo

This commit is contained in:
Marshal
2026-07-07 09:49:12 +00:00
parent f4d28e77fa
commit 1c18fdbd52
8 changed files with 422 additions and 22 deletions

View File

@@ -395,14 +395,20 @@ export class GlOperationsService {
}
if (!file) throw new BadRequestException('Attach the invoice document.');
// Invoiceable once cargo is offloaded, or — for export, where OFFLOADED is a
// DJ doc milestone that may never be recorded — once the Djibouti gate pass
// is secured. The invoice itself stays optional; nothing forces GL DJ to send one.
const milestones = await this.milestoneService.listForBooking(bookingId);
const offloaded = milestones.find(
(m) => m.milestoneCode === 'OFFLOADED' && m.status === 'COMPLETED',
);
if (!offloaded) {
throw new BadRequestException(
'Cargo must be offloaded before the final invoice can be raised.',
);
const gatepass = await this.gatepassForBooking(bookingId);
if (!gatepass.granted) {
throw new BadRequestException(
'Cargo must be offloaded (or the gate pass secured) before the final invoice can be raised.',
);
}
}
const existing = await this.billingService.findInvoice(