fix(bookings): gate export carriage acceptance sheet on GRN receipt

The sheet attests EDR has taken custody. Export custody happens at
warehouse receipt, so the shared received-with-GRN gate now runs even
when wagons are already allocated. Receipt-row query also accepts the
legacy notes GRN fallback, matching the loading gate.
This commit is contained in:
Hagernesh
2026-08-04 07:59:03 +00:00
parent 19ab3af1cb
commit 87b04973d8
5 changed files with 83 additions and 14 deletions

View File

@@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class EmptyContainerReturnStatusHistory3220000000000 implements MigrationInterface {
name = 'EmptyContainerReturnStatusHistory3220000000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE freight.empty_container_returns
ADD COLUMN IF NOT EXISTS status_history jsonb NOT NULL DEFAULT '[]'::jsonb
`);
await queryRunner.query(`
UPDATE freight.empty_container_returns
SET status_history = jsonb_build_array(
jsonb_build_object('status', status, 'changedAt', created_at, 'performedBy', performed_by)
)
WHERE status_history = '[]'::jsonb
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE freight.empty_container_returns
DROP COLUMN IF EXISTS status_history
`);
}
}