From 87bcbef8e4437861251893585482bed8b8c92fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Mestach?= Date: Tue, 24 Dec 2024 11:19:07 +0100 Subject: [PATCH] IA-2456 fix completeness for quarterlyNov --- .../js/apps/Iaso/domains/app/translations/en.json | 2 ++ .../js/apps/Iaso/domains/app/translations/fr.json | 2 ++ .../js/apps/Iaso/domains/completeness/messages.js | 4 ++++ .../js/apps/Iaso/domains/periods/messages.js | 2 +- hat/assets/js/apps/Iaso/domains/periods/models.ts | 15 +++++++++++---- hat/assets/js/apps/Iaso/domains/periods/utils.js | 7 +++++++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/hat/assets/js/apps/Iaso/domains/app/translations/en.json b/hat/assets/js/apps/Iaso/domains/app/translations/en.json index c256d71302..392dee9165 100644 --- a/hat/assets/js/apps/Iaso/domains/app/translations/en.json +++ b/hat/assets/js/apps/Iaso/domains/app/translations/en.json @@ -647,6 +647,7 @@ "iaso.label.periodType": "Periodicity", "iaso.label.periodType.month": "Month", "iaso.label.periodType.quarter": "Quarter", + "iaso.label.periodType.quarter_nov": "Quarter Nov", "iaso.label.periodType.six_month": "Semester", "iaso.label.periodType.year": "Year", "iaso.label.phoneNumber": "Phone number", @@ -661,6 +662,7 @@ "iaso.label.published": "Published", "iaso.label.publishingStatus": "Publishing status", "iaso.label.quarter": "Quarter", + "iaso.label.quarter_nov": "Quarter Nov", "iaso.label.rawHtml": "Raw html", "iaso.label.reAssignInstance": "Re-assign instance", "iaso.label.reAssignInstanceAction": "Re-assign", diff --git a/hat/assets/js/apps/Iaso/domains/app/translations/fr.json b/hat/assets/js/apps/Iaso/domains/app/translations/fr.json index a83510ced0..d100e3cb49 100644 --- a/hat/assets/js/apps/Iaso/domains/app/translations/fr.json +++ b/hat/assets/js/apps/Iaso/domains/app/translations/fr.json @@ -647,6 +647,7 @@ "iaso.label.periodType": "Périodicité", "iaso.label.periodType.month": "Mois", "iaso.label.periodType.quarter": "Trimestre", + "iaso.label.periodType.quarter_nov": "Timestre Novembre", "iaso.label.periodType.six_month": "Semestre", "iaso.label.periodType.year": "Année", "iaso.label.phoneNumber": "Numéro de téléphone", @@ -661,6 +662,7 @@ "iaso.label.published": "Publié", "iaso.label.publishingStatus": "Statut de publication", "iaso.label.quarter": "Trimestre", + "iaso.label.quarter_nov": "Trimestre Novembre", "iaso.label.rawHtml": "Simple HTML", "iaso.label.reAssignInstance": "Assigner la soumission", "iaso.label.reAssignInstanceAction": "Assigner", diff --git a/hat/assets/js/apps/Iaso/domains/completeness/messages.js b/hat/assets/js/apps/Iaso/domains/completeness/messages.js index 0b946c239b..0c825da309 100644 --- a/hat/assets/js/apps/Iaso/domains/completeness/messages.js +++ b/hat/assets/js/apps/Iaso/domains/completeness/messages.js @@ -117,6 +117,10 @@ const MESSAGES = defineMessages({ id: 'iaso.label.periodType.quarter', defaultMessage: 'Quarter', }, + quarter_nov: { + id: 'iaso.label.periodType.quarter_nov', + defaultMessage: 'Quarter Nov', + }, month: { id: 'iaso.label.periodType.month', defaultMessage: 'Month', diff --git a/hat/assets/js/apps/Iaso/domains/periods/messages.js b/hat/assets/js/apps/Iaso/domains/periods/messages.js index b19dc244fd..0341113cc3 100644 --- a/hat/assets/js/apps/Iaso/domains/periods/messages.js +++ b/hat/assets/js/apps/Iaso/domains/periods/messages.js @@ -10,7 +10,7 @@ const MESSAGES = defineMessages({ defaultMessage: 'Quarter', }, quarter_nov: { - id: 'iaso.label.quater_nov', + id: 'iaso.label.quarter_nov', defaultMessage: 'Quarter November', }, month: { diff --git a/hat/assets/js/apps/Iaso/domains/periods/models.ts b/hat/assets/js/apps/Iaso/domains/periods/models.ts index 49c6c68e1c..5e5dbbbcc2 100644 --- a/hat/assets/js/apps/Iaso/domains/periods/models.ts +++ b/hat/assets/js/apps/Iaso/domains/periods/models.ts @@ -17,6 +17,13 @@ export type PeriodObject = { day: number; }; +const QUARTER_NOV_MONTHS = { + 1: [11,12,1], + 2: [2,3,4], + 3: [5,6,7], + 4: [8,9,10] +} + export class Period { private readonly periodType: string; @@ -86,8 +93,8 @@ export class Period { throw new Error(`Invalid period type ${this.periodType}`); case PERIOD_TYPE_MONTH: return [this.month]; - case PERIOD_TYPE_QUARTER_NOV: - return _.range(this.month - 2, this.month + 1); + case PERIOD_TYPE_QUARTER_NOV: + return QUARTER_NOV_MONTHS[this.quarter]; case PERIOD_TYPE_QUARTER: return _.range(this.month - 2, this.month + 1); case PERIOD_TYPE_SIX_MONTH: @@ -196,9 +203,9 @@ export class Period { static parseQuarterNovString(quarterString: string): PeriodObject { const [year, quarter] = quarterString.split('NovQ').map(Number); - debugger; + const month = QUARTER_NOV_MONTHS[quarter].at(-1) return { - month: quarter * 3, + month: month, quarter, semester: Math.ceil(quarter / 2), year, diff --git a/hat/assets/js/apps/Iaso/domains/periods/utils.js b/hat/assets/js/apps/Iaso/domains/periods/utils.js index 690cebe7c2..9a1190ebbb 100644 --- a/hat/assets/js/apps/Iaso/domains/periods/utils.js +++ b/hat/assets/js/apps/Iaso/domains/periods/utils.js @@ -155,6 +155,13 @@ export const getPrettyPeriod = (period, formatMessage, currentUser) => { ); return `${prettyPeriod} (${monthRangeString})`; } + case PERIOD_TYPE_QUARTER_NOV: { + const monthRangeString = getMonthRangeString( + periodClass.monthRange, + formatMessage, + ); + return `${period} (${monthRangeString})`; + } case PERIOD_TYPE_QUARTER: { const monthRangeString = getMonthRangeString( periodClass.monthRange,