mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 15:18:11 +00:00
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:
@@ -56,4 +56,11 @@ export class EmptyContainerReturn extends BaseEntity {
|
||||
|
||||
@Column({ name: 'returned_by', type: 'varchar', length: 20, nullable: true })
|
||||
returnedBy?: 'EDR' | 'CUSTOMER' | null;
|
||||
|
||||
@Column({ name: 'status_history', type: 'jsonb', default: () => "'[]'" })
|
||||
statusHistory!: Array<{
|
||||
status: EmptyContainerReturnStatus;
|
||||
changedAt: string;
|
||||
performedBy: string | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
@@ -149,12 +149,13 @@ export class ImportOperationsService {
|
||||
}
|
||||
|
||||
async createEmptyReturn(dto: CreateEmptyContainerReturnDto) {
|
||||
const returnDate = dto.returnDate ? new Date(dto.returnDate) : new Date();
|
||||
return this.emptyReturns.save(
|
||||
this.emptyReturns.create({
|
||||
containerNumber: dto.containerNumber,
|
||||
bookingId: dto.bookingId ?? null,
|
||||
customerId: dto.customerId ?? null,
|
||||
returnDate: dto.returnDate ? new Date(dto.returnDate) : new Date(),
|
||||
returnDate,
|
||||
facility: dto.facility ?? null,
|
||||
yard: dto.yard ?? null,
|
||||
zone: dto.zone ?? null,
|
||||
@@ -162,6 +163,9 @@ export class ImportOperationsService {
|
||||
handoverNote: dto.handoverNote ?? null,
|
||||
performedBy: dto.performedBy ?? null,
|
||||
returnedBy: dto.returnedBy ?? null,
|
||||
statusHistory: [
|
||||
{ status: 'RETURNED', changedAt: returnDate.toISOString(), performedBy: dto.performedBy ?? null },
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -176,6 +180,10 @@ export class ImportOperationsService {
|
||||
wagonAllocationReference: dto.wagonAllocationReference ?? row.wagonAllocationReference ?? null,
|
||||
handoverNote: dto.handoverNote ?? row.handoverNote ?? null,
|
||||
performedBy: dto.performedBy ?? row.performedBy ?? null,
|
||||
statusHistory: [
|
||||
...(row.statusHistory ?? []),
|
||||
{ status: dto.status, changedAt: new Date().toISOString(), performedBy: dto.performedBy ?? row.performedBy ?? null },
|
||||
],
|
||||
});
|
||||
return this.emptyReturns.findOneOrFail({ where: { id } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user