Skip to content

Commit

Permalink
IA-2456 fix completeness for quarterlyNov
Browse files Browse the repository at this point in the history
  • Loading branch information
mestachs committed Dec 24, 2024
1 parent aad4bd6 commit 87bcbef
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions hat/assets/js/apps/Iaso/domains/app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions hat/assets/js/apps/Iaso/domains/completeness/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion hat/assets/js/apps/Iaso/domains/periods/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
15 changes: 11 additions & 4 deletions hat/assets/js/apps/Iaso/domains/periods/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions hat/assets/js/apps/Iaso/domains/periods/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 87bcbef

Please sign in to comment.