mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 22:58:17 +00:00
Facility
This commit is contained in:
@@ -275,6 +275,9 @@ export class AppModule implements OnApplicationBootstrap {
|
|||||||
// await this.demoUsersSeeder.run();
|
// await this.demoUsersSeeder.run();
|
||||||
// await this.freightStaffUsersSeeder.run();
|
// await this.freightStaffUsersSeeder.run();
|
||||||
// await this.pricingDataSeeder.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.indodeFacilitySeeder.run();
|
||||||
// await this.batch14TestDataSeeder.run();
|
// await this.batch14TestDataSeeder.run();
|
||||||
// await this.batch5TestDataSeeder.run();
|
// await this.batch5TestDataSeeder.run();
|
||||||
|
|||||||
@@ -74,20 +74,22 @@ export class IndodeFacilitySeeder {
|
|||||||
const yardRepo = manager.getRepository(WarehouseYard);
|
const yardRepo = manager.getRepository(WarehouseYard);
|
||||||
const zoneRepo = manager.getRepository(WarehouseZone);
|
const zoneRepo = manager.getRepository(WarehouseZone);
|
||||||
|
|
||||||
// Ensure facility exists
|
// Ensure facility exists. An existing facility row is not proof the
|
||||||
const facility = await facilityRepo.findOne({
|
// 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 },
|
where: { code: INDODE_FACILITY.code },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (facility) {
|
let savedFacility: Facility;
|
||||||
this.logger.log('Indode facility already exists, skipping seed');
|
if (existing) {
|
||||||
return;
|
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
|
// Create warehouses for the facility
|
||||||
for (const warehouseData of WAREHOUSES) {
|
for (const warehouseData of WAREHOUSES) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user