mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
changes export flow
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Export bookings get their own pay window, separately tunable from import:
|
||||
* - global_rules.export_payment_window_minutes — global default for EXPORT
|
||||
* (payment_window_minutes keeps governing IMPORT/DOMESTIC).
|
||||
* - train_schedules.rule_payment_window_minutes — per-schedule override; until
|
||||
* now the DTO accepted paymentWindowMinutes but only folded it into the
|
||||
* reopen-delay sum, so the override never reached the actual pay window.
|
||||
* - bookings.requested_train_schedule_id — the export train the customer picked
|
||||
* at day-commit; pickExportSchedule honors it instead of earliest-first.
|
||||
* - bookings.payment_reminder_sent_at — marks the one pre-deadline pay
|
||||
* reminder so the 10s window tick doesn't re-send it.
|
||||
*/
|
||||
export class AddExportPaymentWindow3060000000000 implements MigrationInterface {
|
||||
name = 'AddExportPaymentWindow3060000000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.train_scheduling_global_rules ADD COLUMN IF NOT EXISTS export_payment_window_minutes int NOT NULL DEFAULT 60;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.train_schedules ADD COLUMN IF NOT EXISTS rule_payment_window_minutes int;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.bookings ADD COLUMN IF NOT EXISTS requested_train_schedule_id uuid;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.bookings ADD COLUMN IF NOT EXISTS payment_reminder_sent_at timestamptz;`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.bookings DROP COLUMN IF EXISTS payment_reminder_sent_at;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.bookings DROP COLUMN IF EXISTS requested_train_schedule_id;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.train_schedules DROP COLUMN IF EXISTS rule_payment_window_minutes;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.train_scheduling_global_rules DROP COLUMN IF EXISTS export_payment_window_minutes;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Break-bulk (PER_ITEM) bookings store their item count in
|
||||
* cargo_total_weight_vgm, so the actual tonnage was never captured — wagon
|
||||
* allocation divided an item COUNT by a tons capacity and under-allocated
|
||||
* (400 machines ÷ 69T wagon read as 6 wagons instead of 12). New column holds
|
||||
* the real total weight in tons for PER_ITEM cargo; null for PER_TON bulk and
|
||||
* container bookings.
|
||||
*/
|
||||
export class AddBulkTotalWeightTons3070000000000 implements MigrationInterface {
|
||||
name = 'AddBulkTotalWeightTons3070000000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.bookings ADD COLUMN IF NOT EXISTS bulk_total_weight_tons numeric(12,3);`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.bookings DROP COLUMN IF EXISTS bulk_total_weight_tons;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user