This commit is contained in:
Hagernesh
2026-08-08 13:17:33 +00:00
parent 204bfd2421
commit 80e1648672
2 changed files with 15 additions and 13 deletions

View File

@@ -1697,7 +1697,6 @@ export class WarehouseInventoryService {
/** EXPORT inventory rows at a given status (route-derived direction), with booking detail. */ /** EXPORT inventory rows at a given status (route-derived direction), with booking detail. */
private async exportInventoryByStatus( private async exportInventoryByStatus(
status: WarehouseInventoryStatus, status: WarehouseInventoryStatus,
requireInspectionPassed = false,
): Promise<ReadyToLoadRow[]> { ): Promise<ReadyToLoadRow[]> {
const rows: Array< const rows: Array<
ReadyToLoadRow & { originCountry: string | null; destinationCountry: string | null } 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 LEFT JOIN freight.containers ct ON ct.id = inv.container_id
WHERE inv.deleted_at IS NULL WHERE inv.deleted_at IS NULL
AND inv.status = $1 AND inv.status = $1
${requireInspectionPassed ? `AND inv.inspection_status = 'PASSED'` : ''}
ORDER BY inv.created_at DESC`, ORDER BY inv.created_at DESC`,
[status], [status],
); );
@@ -1739,9 +1737,13 @@ export class WarehouseInventoryService {
.map(({ originCountry: _oc, destinationCountry: _dc, ...rest }) => rest); .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<ReadyToLoadRow[]> { async readyToLoadExport(): Promise<ReadyToLoadRow[]> {
return this.exportInventoryByStatus('READY_FOR_LOADING', true); return this.exportInventoryByStatus('READY_FOR_LOADING');
} }
/** EXPORT inventory received at the facility and awaiting inspection. */ /** 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) { if (!item.bookingId || !item.warehouseId || !item.yardId || !item.zoneId) {
throw new BadRequestException('Inventory must have booking, warehouse, yard and zone before loading prep'); throw new BadRequestException('Inventory must have booking, warehouse, yard and zone before loading prep');
} }
if (item.inspectionStatus !== 'PASSED') { // Inspection is tracked, not enforced — uninspected cargo may still be
throw new BadRequestException('Inventory must pass inspection before it can be marked ready for loading'); // marked ready and loaded so a train is never held for paperwork.
}
return this.transition(id, 'READY_FOR_LOADING', { return this.transition(id, 'READY_FOR_LOADING', {
timestampField: 'readyForLoadingAt', timestampField: 'readyForLoadingAt',
activityType: 'READY_FOR_LOADING', activityType: 'READY_FOR_LOADING',

View File

@@ -85,14 +85,15 @@ export function getNextInventoryAction(item: WarehouseInventoryItem): InventoryA
if (isImport) return inspected ? 'ready-for-pickup' : null; if (isImport) return inspected ? 'ready-for-pickup' : null;
return 'store'; return 'store';
case 'STORED': case 'STORED':
// Reserve is retired: a stored export item goes straight to loading prep // Reserve is retired: a stored export item goes straight to loading prep.
// once inspection passes. An import item parked back into storage returns // An import item parked back into storage returns to pickup — otherwise
// to pickup — otherwise Store would strand it with no action. // Store would strand it with no action.
if (isImport) return inspected ? 'ready-for-pickup' : null; if (isImport) return inspected ? 'ready-for-pickup' : null;
return inspected ? 'ready-for-loading' : null; return 'ready-for-loading';
case 'RESERVED': case 'RESERVED':
// Export loading is gated on a passed inspection. // Export loading is not gated on inspection — inspection is tracked, but a
return inspected ? 'ready-for-loading' : null; // train is never held waiting for it.
return 'ready-for-loading';
case 'READY_FOR_PICKUP': case 'READY_FOR_PICKUP':
// Issue the DO / release order first, then hand over the goods. // Issue the DO / release order first, then hand over the goods.
return item.releaseDate ? 'deliver' : 'release'; return item.releaseDate ? 'deliver' : 'release';