From 80e1648672f78e86bb19eeea26dd3cd6d3b09a72 Mon Sep 17 00:00:00 2001 From: Hagernesh Date: Sat, 8 Aug 2026 13:17:33 +0000 Subject: [PATCH] fix --- .../warehouses/warehouse-inventory.service.ts | 15 ++++++++------- .../backoffice/src/types/warehouse.ts | 13 +++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/edr-freight-api/src/modules/warehouses/warehouse-inventory.service.ts b/apps/edr-freight-api/src/modules/warehouses/warehouse-inventory.service.ts index 3e11380c1..59a04f08c 100644 --- a/apps/edr-freight-api/src/modules/warehouses/warehouse-inventory.service.ts +++ b/apps/edr-freight-api/src/modules/warehouses/warehouse-inventory.service.ts @@ -1697,7 +1697,6 @@ export class WarehouseInventoryService { /** EXPORT inventory rows at a given status (route-derived direction), with booking detail. */ private async exportInventoryByStatus( status: WarehouseInventoryStatus, - requireInspectionPassed = false, ): Promise { const rows: Array< ReadyToLoadRow & { originCountry: string | null; destinationCountry: string | null } @@ -1726,7 +1725,6 @@ export class WarehouseInventoryService { LEFT JOIN freight.containers ct ON ct.id = inv.container_id WHERE inv.deleted_at IS NULL AND inv.status = $1 - ${requireInspectionPassed ? `AND inv.inspection_status = 'PASSED'` : ''} ORDER BY inv.created_at DESC`, [status], ); @@ -1739,9 +1737,13 @@ export class WarehouseInventoryService { .map(({ originCountry: _oc, destinationCountry: _dc, ...rest }) => rest); } - /** EXPORT inventory that passed inspection and is waiting to be loaded (READY_FOR_LOADING). */ + /** + * EXPORT inventory waiting to be loaded (READY_FOR_LOADING). Inspection state + * rides along on each row for the UI to show, but does not filter the queue — + * uninspected cargo must still be loadable. + */ async readyToLoadExport(): Promise { - return this.exportInventoryByStatus('READY_FOR_LOADING', true); + return this.exportInventoryByStatus('READY_FOR_LOADING'); } /** EXPORT inventory received at the facility and awaiting inspection. */ @@ -3130,9 +3132,8 @@ export class WarehouseInventoryService { if (!item.bookingId || !item.warehouseId || !item.yardId || !item.zoneId) { throw new BadRequestException('Inventory must have booking, warehouse, yard and zone before loading prep'); } - if (item.inspectionStatus !== 'PASSED') { - throw new BadRequestException('Inventory must pass inspection before it can be marked ready for loading'); - } + // Inspection is tracked, not enforced — uninspected cargo may still be + // marked ready and loaded so a train is never held for paperwork. return this.transition(id, 'READY_FOR_LOADING', { timestampField: 'readyForLoadingAt', activityType: 'READY_FOR_LOADING', diff --git a/apps/edr-freight-web/backoffice/src/types/warehouse.ts b/apps/edr-freight-web/backoffice/src/types/warehouse.ts index 6b11d4dcd..aac7e532d 100644 --- a/apps/edr-freight-web/backoffice/src/types/warehouse.ts +++ b/apps/edr-freight-web/backoffice/src/types/warehouse.ts @@ -85,14 +85,15 @@ export function getNextInventoryAction(item: WarehouseInventoryItem): InventoryA if (isImport) return inspected ? 'ready-for-pickup' : null; return 'store'; case 'STORED': - // Reserve is retired: a stored export item goes straight to loading prep - // once inspection passes. An import item parked back into storage returns - // to pickup — otherwise Store would strand it with no action. + // Reserve is retired: a stored export item goes straight to loading prep. + // An import item parked back into storage returns to pickup — otherwise + // Store would strand it with no action. if (isImport) return inspected ? 'ready-for-pickup' : null; - return inspected ? 'ready-for-loading' : null; + return 'ready-for-loading'; case 'RESERVED': - // Export loading is gated on a passed inspection. - return inspected ? 'ready-for-loading' : null; + // Export loading is not gated on inspection — inspection is tracked, but a + // train is never held waiting for it. + return 'ready-for-loading'; case 'READY_FOR_PICKUP': // Issue the DO / release order first, then hand over the goods. return item.releaseDate ? 'deliver' : 'release';