mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Facility
This commit is contained in:
@@ -275,6 +275,9 @@ export class AppModule implements OnApplicationBootstrap {
|
||||
// await this.demoUsersSeeder.run();
|
||||
// await this.freightStaffUsersSeeder.run();
|
||||
// await this.pricingDataSeeder.run();
|
||||
// IndodeFacilitySeeder keys its warehouses on INDODE_OPEN / INDODE_CLOSED, so
|
||||
// it will not recognise a hand-created Indode warehouse and will seed a second
|
||||
// one alongside it. Only enable it against an Indode that has no warehouse.
|
||||
// await this.indodeFacilitySeeder.run();
|
||||
// await this.batch14TestDataSeeder.run();
|
||||
// await this.batch5TestDataSeeder.run();
|
||||
|
||||
@@ -74,20 +74,22 @@ export class IndodeFacilitySeeder {
|
||||
const yardRepo = manager.getRepository(WarehouseYard);
|
||||
const zoneRepo = manager.getRepository(WarehouseZone);
|
||||
|
||||
// Ensure facility exists
|
||||
const facility = await facilityRepo.findOne({
|
||||
// Ensure facility exists. An existing facility row is not proof the
|
||||
// warehouses under it survived, so reuse it and carry on rather than
|
||||
// returning — otherwise a facility with no warehouses stays that way.
|
||||
const existing = await facilityRepo.findOne({
|
||||
where: { code: INDODE_FACILITY.code },
|
||||
});
|
||||
|
||||
if (facility) {
|
||||
this.logger.log('Indode facility already exists, skipping seed');
|
||||
return;
|
||||
let savedFacility: Facility;
|
||||
if (existing) {
|
||||
savedFacility = await facilityRepo.save({ ...existing, ...INDODE_FACILITY });
|
||||
this.logger.log(`Facility ${savedFacility.code} already exists, reusing`);
|
||||
} else {
|
||||
savedFacility = await facilityRepo.save(facilityRepo.create(INDODE_FACILITY));
|
||||
this.logger.log(`Created facility: ${savedFacility.code}`);
|
||||
}
|
||||
|
||||
const newFacility = facilityRepo.create(INDODE_FACILITY);
|
||||
const savedFacility = await facilityRepo.save(newFacility);
|
||||
this.logger.log(`Created facility: ${savedFacility.code}`);
|
||||
|
||||
// Create warehouses for the facility
|
||||
for (const warehouseData of WAREHOUSES) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user