mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-02 17:23:38 +00:00
mile
This commit is contained in:
@@ -3,6 +3,7 @@ import { WagonStatus } from '@edr/types';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
import { Booking } from '../modules/bookings/entities/booking.entity';
|
||||
import { Company } from '../modules/companies/entities/company.entity';
|
||||
import { Locomotive } from '../modules/locomotives/entities/locomotive.entity';
|
||||
import { CargoType } from '../modules/rule-engine/entities/cargo-type.entity';
|
||||
import { ServiceType } from '../modules/rule-engine/entities/service-type.entity';
|
||||
@@ -116,6 +117,11 @@ export class MarshallingDemoTrainsSeeder {
|
||||
? await warehouseZoneRepo.findOne({ where: { yardId: warehouseYard.id } })
|
||||
: null;
|
||||
|
||||
// bookings.company_id is NOT NULL — reuse any seeded company for the demo.
|
||||
const company = await this.dataSource
|
||||
.getRepository(Company)
|
||||
.findOne({ where: {}, order: { createdAt: 'ASC' } });
|
||||
|
||||
const missing = [
|
||||
!djiboutiYard ? 'Djibouti yard' : '',
|
||||
!ethiopiaYard ? 'Ethiopia yard' : '',
|
||||
@@ -124,6 +130,7 @@ export class MarshallingDemoTrainsSeeder {
|
||||
!warehouse ? 'INDODE_OPEN warehouse' : '',
|
||||
!warehouseYard ? 'warehouse yard' : '',
|
||||
!warehouseZone ? 'warehouse zone' : '',
|
||||
!company ? 'company' : '',
|
||||
].filter(Boolean);
|
||||
if (missing.length) {
|
||||
this.logger.warn(`Cannot seed marshalling demo trains, missing: ${missing.join(', ')}`);
|
||||
@@ -141,6 +148,7 @@ export class MarshallingDemoTrainsSeeder {
|
||||
warehouse: warehouse!,
|
||||
warehouseYard: warehouseYard!,
|
||||
warehouseZone: warehouseZone!,
|
||||
company: company!,
|
||||
});
|
||||
if (created) seeded += 1;
|
||||
}
|
||||
@@ -164,6 +172,7 @@ export class MarshallingDemoTrainsSeeder {
|
||||
warehouse: Warehouse;
|
||||
warehouseYard: WarehouseYard;
|
||||
warehouseZone: WarehouseZone;
|
||||
company: Company;
|
||||
},
|
||||
): Promise<boolean> {
|
||||
const bookingRepo = this.dataSource.getRepository(Booking);
|
||||
@@ -231,6 +240,7 @@ export class MarshallingDemoTrainsSeeder {
|
||||
const booking = await bookingRepo.save(
|
||||
bookingRepo.create({
|
||||
reference: bookingReference,
|
||||
companyId: refs.company.id,
|
||||
originYardId: originYard.id,
|
||||
destinationYardId: destinationYard.id,
|
||||
serviceTypeId: refs.serviceType.id,
|
||||
|
||||
Reference in New Issue
Block a user