From 6f60a3f0258e7e151447de663f94bd590b6f1b40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20PAILHAREY?= <rpailharey@grandlyon.com>
Date: Thu, 8 Feb 2024 16:29:21 +0000
Subject: [PATCH] fix(newsletter): previous month year in January

---
 src/notifications/monthlyReport.hbs               | 8 +++-----
 src/targets/services/monthlyReportNotification.ts | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/notifications/monthlyReport.hbs b/src/notifications/monthlyReport.hbs
index 29dfae79d..bce1313b6 100644
--- a/src/notifications/monthlyReport.hbs
+++ b/src/notifications/monthlyReport.hbs
@@ -28,19 +28,17 @@
           Bonjour {{username}},
         </mj-text>
         {{#if comparisonExist }}
-          <mj-text color="white" font-weight="700" font-size="18px">Votre bilan {{currentMonth}} {{currentYear}} est prêt. Voilà l’évolution de vos consommations :</mj-text>
+          <mj-text color="white" font-weight="700" font-size="18px">Votre bilan {{currentMonth}} {{currentYear}} est prêt. Voilà l’évolution de vos consommations&nbsp;:</mj-text>
           {{#if yearComparisonExist }}
             <mj-text color="white" font-weight="400" font-size="18px">
               Par rapport au mois 
-              <span class="bold gold">{{currentMonth}} {{previousYear}}</span>
-              , vous avez consommé :{{{yearComparisonText}}}
+              <span class="bold gold">{{currentMonth}} {{previousYear}}</span>, vous avez consommé&nbsp;:{{{yearComparisonText}}}
             </mj-text>
           {{/if}}
           {{#if monthComparisonExist }}
             <mj-text color="white" font-weight="400" font-size="18px">
               Par rapport au mois
-              <span class="bold gold">{{previousMonth}} {{currentYear}}</span>
-              , vous avez consommé :{{{monthComparisonText}}}
+              <span class="bold gold">{{previousMonth}} {{previousMonthYear}}</span>, vous avez consommé&nbsp;:{{{monthComparisonText}}}
             </mj-text>
           {{/if}}
         {{/if}}
diff --git a/src/targets/services/monthlyReportNotification.ts b/src/targets/services/monthlyReportNotification.ts
index 276c47cac..15ef813be 100644
--- a/src/targets/services/monthlyReportNotification.ts
+++ b/src/targets/services/monthlyReportNotification.ts
@@ -280,6 +280,7 @@ const monthlyReportNotification = async ({
     currentMonth: getMonthNameWithPrep(date),
     previousYear: date.year - 1,
     currentYear: date.year,
+    previousMonthYear: date.month === 1 ? date.year - 1 : date.year,
     consoImageUrl: baseUrl + '/assets/multifluidConsumption.png',
     feedbackImageUrl: baseUrl + '/assets/feedback.png',
   })
-- 
GitLab