Asset Push API fixed non existing last consumption
MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -137,6 +137,7 @@ export default class AssetService {
}
// Get latest consumption and check dates
const lastConsumption = await ConsumptionStorage.getLastAssetConsumption(req.tenant, { assetID: filteredRequest.assetID });
+ if (!Utils.isNullOrUndefined(lastConsumption)) {
if (moment(filteredRequest.startedAt).isBefore(moment(lastConsumption.endedAt))) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
@@ -147,6 +148,7 @@ export default class AssetService {
action: action
});
}
+ }
// Add site area
const consumptionToSave: Consumption = {
...filteredRequest,

Asset Push API fixed non existing last consumption