diff --git a/services/consumptionAlert/ecolyo.js b/services/consumptionAlert/ecolyo.js index 9b9f9f0e9dbd4e1fd3709c5b86033b7128b227d7..f00cc5a30d764f2135532becbaca275473aaea02 100644 --- a/services/consumptionAlert/ecolyo.js +++ b/services/consumptionAlert/ecolyo.js @@ -77148,11 +77148,19 @@ const consumptionAlert = async ({ const fetchedData = await consumptionService.getLastDataload(_fluid.FluidType.WATER); let lastDayValue = 0; + let alertDay = _luxon.DateTime.local().setZone('utc', { + keepLocalTime: true + }); + if (fetchedData && fetchedData.length > 0) { fetchedData.forEach(element => { if (element.value) { lastDayValue = element.value; } + + if (element.date) { + alertDay = element.date; + } }); } @@ -77163,11 +77171,6 @@ const consumptionAlert = async ({ log('info', 'Creation of mail...'); const mailService = new _mail.default(); - - const today = _luxon.DateTime.local().setZone('utc', { - keepLocalTime: true - }); - const environmentService = new _environment.default(); const template = consumptionLimit({ title: 'Ça déborde !', @@ -77176,7 +77179,7 @@ const consumptionAlert = async ({ clientUrl: `${appLink}/#/consumption/water`, unsubscribeUrl: `${appLink}/#/options`, userLimit: userProfil.waterDailyConsumptionLimit, - limitDate: `${today.day} ${(0, _utils.getPreviousMonthName)(today)}` + limitDate: `${alertDay.day} ${(0, _utils.getPreviousMonthName)(alertDay)}` }); const mailData = { mode: 'noreply',