Update companyID and siteID in charging station when updating site Area
MODIFY
src/server/rest/v1/service/SiteAreaService.ts
src/server/rest/v1/service/SiteAreaService.ts
@@ -371,7 +371,7 @@ export default class SiteAreaService {
// Save
await SiteAreaStorage.saveSiteArea(req.tenant, siteArea, Utils.objectHasProperty(filteredRequest, 'image'));
// Update charging station
- await ChargingStationStorage.updateChargingStationsSite(req.tenant, filteredRequest.id, filteredRequest.siteID);
+ await ChargingStationStorage.updateChargingStationsSite(req.tenant, filteredRequest.id, filteredRequest.siteID, site.companyID);
// Retrigger Smart Charging
if (filteredRequest.smartCharging) {
// FIXME: the lock acquisition can wait for 30s before timeout and the whole code execution timeout at 3s

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -968,7 +968,7 @@ export default class ChargingStationStorage {
return firmware;
}
- public static async updateChargingStationsSite(tenant: Tenant, siteAreaID: string, siteID: string): Promise<void> {
+ public static async updateChargingStationsSite(tenant: Tenant, siteAreaID: string, siteID: string, companyID: string): Promise<void> {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
await global.database.getCollection<any>(tenant.id, 'chargingstations').updateMany(
@@ -976,7 +976,10 @@ export default class ChargingStationStorage {
siteAreaID: DatabaseUtils.convertToObjectID(siteAreaID),
},
{
- $set: { siteID: DatabaseUtils.convertToObjectID(siteID) }
+ $set: {
+ siteID: DatabaseUtils.convertToObjectID(siteID),
+ companyID: DatabaseUtils.convertToObjectID(companyID)
+ }
});
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'updateChargingStationsSite', startTime, { siteID });
}

Update companyID and siteID in charging station when updating site Area