mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
Merge pull request #485 from Tria-plc/CutomerTruckAssign
separte handover edr lastmile and customer last mile flow
Self-haul: handover auto-generated on first truck arrival.
Signed when customer approves delivery
Fixes
Import train dispatch no longer blocked by loading confirmation (committed 0a170182).
Marshalling / handover / GRN docs no longer masquerade as "Release Order" (decoupled from the release fallback).
Weighing modal now fetches trucks from both last-mile + customer portal, shows "Truck is not assigned yet".
Name fields (warehouse/fee/allocation) → letters-only.
11 build errors = stale package dist → rebuilt @edr/types + @edr/api-common.
jose missing dep → installed.
Features built
Multi-truck self-haul assignment — 1–2 containers/truck, per-truck arrival; entities + migration + service + controller + portal card. Exit paper carries truck info; freight-order PDF lists every truck.
Import vs export split — import: no container pre-select, staff weigh + register load on leaving (departTruck, gross weight, gate-out, locks), exit paper per container; export: pre-selected containers, receive-only.
Per-container GRN + received_to_port — on booking_container_units; auto-marked on receive (export delivery), staff-confirmed GRN (per batch / per booking), staff-only.
Online demurrage/storage pay in customer portal — Telebirr/Waafi pay button on warehouse invoices.
Container-number picker on truck assignment (surfaced booking container numbers).
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Structured import handover records. Replaces the ad-hoc handover notes so a
|
||||
* booking can carry one handover (single truck) or several (one per truck when
|
||||
* multiple trucks are used). Timing differs by mile type:
|
||||
* - SELF_HAUL: generated on first truck arrival, signed before the truck leaves.
|
||||
* - EDR_LAST_MILE: generated at delivery (after exit); signed on delivery.
|
||||
*/
|
||||
export class AddBookingHandovers1980000000000 implements MigrationInterface {
|
||||
name = 'AddBookingHandovers1980000000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE IF NOT EXISTS freight.booking_handovers (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
booking_id uuid NOT NULL REFERENCES freight.bookings(id) ON DELETE CASCADE,
|
||||
truck_assignment_id uuid REFERENCES freight.customer_truck_assignments(id) ON DELETE SET NULL,
|
||||
truck_plate varchar(32),
|
||||
mile_type varchar(20) NOT NULL,
|
||||
reference varchar(100) NOT NULL,
|
||||
generated_at timestamptz NOT NULL DEFAULT now(),
|
||||
signed_at timestamptz,
|
||||
signed_by_user_id uuid,
|
||||
delivered_at timestamptz,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
deleted_at timestamptz
|
||||
);
|
||||
`);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX IF NOT EXISTS "IDX_booking_handovers_booking" ON freight.booking_handovers (booking_id);`,
|
||||
);
|
||||
// At most one live handover per (booking, customer truck). EDR trucks (which
|
||||
// aren't customer_truck_assignments) and per-booking handovers are de-duped
|
||||
// in the service, since a NULL truck_assignment_id can't be uniquely indexed.
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "UQ_booking_handovers_booking_truck"
|
||||
ON freight.booking_handovers (booking_id, truck_assignment_id)
|
||||
WHERE deleted_at IS NULL AND truck_assignment_id IS NOT NULL;
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS freight.booking_handovers;`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user