@dhis2/analytics 24.4.1 → 24.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/build/cjs/components/OpenFileDialog/OpenFileDialog.js +7 -2
- package/build/cjs/components/PeriodDimension/PeriodTransfer.js +16 -4
- package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +204 -478
- package/build/cjs/locales/en/translations.json +0 -14
- package/build/es/components/OpenFileDialog/OpenFileDialog.js +7 -2
- package/build/es/components/PeriodDimension/PeriodTransfer.js +14 -4
- package/build/es/components/PeriodDimension/utils/fixedPeriods.js +202 -477
- package/build/es/locales/en/translations.json +0 -14
- package/package.json +7 -1
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.parsePeriodCode = exports.getYearOffsetFromNow = exports.getFixedPeriodsOptionsById = exports.getFixedPeriodsOptions = void 0;
|
|
7
7
|
|
|
8
|
+
var _multiCalendarDates = require("@dhis2/multi-calendar-dates");
|
|
9
|
+
|
|
8
10
|
var _index = _interopRequireDefault(require("../../../locales/index.js"));
|
|
9
11
|
|
|
10
12
|
var _index2 = require("./index.js");
|
|
@@ -49,452 +51,175 @@ const PERIOD_TYPE_REGEX = {
|
|
|
49
51
|
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
const getPeriods = _ref => {
|
|
55
|
+
let {
|
|
56
|
+
periodType,
|
|
57
|
+
config,
|
|
58
|
+
fnFilter,
|
|
59
|
+
calendar
|
|
60
|
+
} = _ref;
|
|
61
|
+
const offset = parseInt(config.offset, 10);
|
|
62
|
+
const isFilter = config.filterFuturePeriods;
|
|
63
|
+
const isReverse = periodType.match(/^FY|YEARLY/) ? true : config.reversePeriods;
|
|
64
|
+
const year = (0, _multiCalendarDates.getNowInCalendar)(calendar).eraYear + offset;
|
|
65
|
+
const params = {
|
|
66
|
+
periodType,
|
|
67
|
+
year,
|
|
68
|
+
calendar,
|
|
69
|
+
locale: 'en',
|
|
70
|
+
startingDay: config.startDay
|
|
71
|
+
};
|
|
72
|
+
let periods = (0, _multiCalendarDates.generateFixedPeriods)(params);
|
|
73
|
+
periods = isFilter ? fnFilter(periods) : periods;
|
|
74
|
+
periods = !isReverse ? periods : periods.reverse();
|
|
75
|
+
return periods;
|
|
55
76
|
};
|
|
56
77
|
|
|
57
|
-
const getDailyPeriodType = (
|
|
78
|
+
const getDailyPeriodType = (fnFilter, calendar) => {
|
|
58
79
|
return config => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
while (date.getFullYear() === year) {
|
|
67
|
-
const period = {};
|
|
68
|
-
period.startDate = formatYyyyMmDd(date);
|
|
69
|
-
period.endDate = period.startDate;
|
|
70
|
-
period.name = period.startDate;
|
|
71
|
-
period.iso = period.startDate.replace(/-/g, '');
|
|
72
|
-
period.id = period.iso;
|
|
73
|
-
periods.push(period);
|
|
74
|
-
date.setDate(date.getDate() + 1);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
78
|
-
periods = isReverse ? periods.reverse() : periods;
|
|
79
|
-
return periods;
|
|
80
|
+
return getPeriods({
|
|
81
|
+
periodType: 'DAILY',
|
|
82
|
+
config,
|
|
83
|
+
fnFilter,
|
|
84
|
+
calendar
|
|
85
|
+
});
|
|
80
86
|
};
|
|
81
87
|
};
|
|
82
88
|
|
|
83
|
-
const getWeeklyPeriodType = (
|
|
84
|
-
// Calculate the first date of an EPI year base on ISO standard ( first week always contains 4th Jan )
|
|
85
|
-
const getEpiWeekStartDay = (year, startDayOfWeek) => {
|
|
86
|
-
const jan4 = new Date(year, 0, 4);
|
|
87
|
-
const jan4DayOfWeek = jan4.getDay();
|
|
88
|
-
const startDate = jan4;
|
|
89
|
-
const dayDiff = jan4DayOfWeek - startDayOfWeek;
|
|
90
|
-
|
|
91
|
-
if (dayDiff > 0) {
|
|
92
|
-
startDate.setDate(jan4.getDate() - dayDiff);
|
|
93
|
-
} else if (dayDiff < 0) {
|
|
94
|
-
startDate.setDate(jan4.getDate() - dayDiff);
|
|
95
|
-
startDate.setDate(startDate.getDate() - 7);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return startDate;
|
|
99
|
-
};
|
|
100
|
-
|
|
89
|
+
const getWeeklyPeriodType = (weekObj, fnFilter, calendar) => {
|
|
101
90
|
return config => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
while (date.getFullYear() <= year) {
|
|
111
|
-
const period = {};
|
|
112
|
-
period.startDate = formatYyyyMmDd(date);
|
|
113
|
-
period.iso = "".concat(year).concat(weekObj.shortName, "W").concat(week);
|
|
114
|
-
period.id = period.iso;
|
|
115
|
-
date.setDate(date.getDate() + 6);
|
|
116
|
-
period.endDate = formatYyyyMmDd(date);
|
|
117
|
-
const weekNumber = week;
|
|
118
|
-
period.name = "".concat(_index.default.t('Week {{weekNumber}}', {
|
|
119
|
-
weekNumber
|
|
120
|
-
}), " - ").concat(period.startDate, " - ").concat(period.endDate); // if end date is Jan 4th or later, week belongs to next year
|
|
121
|
-
|
|
122
|
-
if (date.getFullYear() > year && date.getDate() >= 4) {
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
periods.push(period);
|
|
127
|
-
date.setDate(date.getDate() + 1);
|
|
128
|
-
week += 1;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
132
|
-
periods = isReverse ? periods.reverse() : periods;
|
|
133
|
-
return periods;
|
|
91
|
+
return getPeriods({
|
|
92
|
+
periodType: 'WEEKLY',
|
|
93
|
+
config: { ...config,
|
|
94
|
+
startDay: weekObj.startDay
|
|
95
|
+
},
|
|
96
|
+
fnFilter,
|
|
97
|
+
calendar
|
|
98
|
+
});
|
|
134
99
|
};
|
|
135
100
|
};
|
|
136
101
|
|
|
137
|
-
const getBiWeeklyPeriodType = (
|
|
102
|
+
const getBiWeeklyPeriodType = (fnFilter, calendar) => {
|
|
138
103
|
return config => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const day = date.getDay();
|
|
146
|
-
let biWeek = 1;
|
|
147
|
-
|
|
148
|
-
if (day <= 4) {
|
|
149
|
-
date.setDate(date.getDate() - (day - 1));
|
|
150
|
-
} else {
|
|
151
|
-
date.setDate(date.getDate() + (8 - day));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
while (date.getFullYear() <= year) {
|
|
155
|
-
const period = {};
|
|
156
|
-
period.iso = "".concat(year, "BiW").concat(biWeek);
|
|
157
|
-
period.id = period.iso;
|
|
158
|
-
period.startDate = formatYyyyMmDd(date);
|
|
159
|
-
date.setDate(date.getDate() + 13);
|
|
160
|
-
period.endDate = formatYyyyMmDd(date);
|
|
161
|
-
const biWeekNumber = biWeek;
|
|
162
|
-
period.name = "".concat(_index.default.t('Bi-Week {{biWeekNumber}}', {
|
|
163
|
-
biWeekNumber
|
|
164
|
-
}), " - ").concat(period.startDate, " - ").concat(period.endDate); // if end date is Jan 4th or later, biweek belongs to next year
|
|
165
|
-
|
|
166
|
-
if (date.getFullYear() > year && date.getDate() >= 4) {
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
periods.push(period);
|
|
171
|
-
date.setDate(date.getDate() + 1);
|
|
172
|
-
biWeek += 1;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
176
|
-
periods = isReverse ? periods.reverse() : periods;
|
|
177
|
-
return periods;
|
|
104
|
+
return getPeriods({
|
|
105
|
+
periodType: 'BIWEEKLY',
|
|
106
|
+
config,
|
|
107
|
+
fnFilter,
|
|
108
|
+
calendar
|
|
109
|
+
});
|
|
178
110
|
};
|
|
179
111
|
};
|
|
180
112
|
|
|
181
|
-
const getMonthlyPeriodType = (
|
|
182
|
-
const formatIso = date => {
|
|
183
|
-
const y = date.getFullYear();
|
|
184
|
-
let m = String(date.getMonth() + 1);
|
|
185
|
-
m = m.length < 2 ? "0".concat(m) : m;
|
|
186
|
-
return y + m;
|
|
187
|
-
};
|
|
188
|
-
|
|
113
|
+
const getMonthlyPeriodType = (fnFilter, calendar) => {
|
|
189
114
|
return config => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
while (date.getFullYear() === year) {
|
|
198
|
-
const period = {};
|
|
199
|
-
period.endDate = formatYyyyMmDd(date);
|
|
200
|
-
date.setDate(1);
|
|
201
|
-
period.startDate = formatYyyyMmDd(date);
|
|
202
|
-
const monthName = getMonthName(date.getMonth());
|
|
203
|
-
period.name = "".concat(monthName, " ").concat(year);
|
|
204
|
-
period.iso = formatIso(date);
|
|
205
|
-
period.id = period.iso;
|
|
206
|
-
periods.push(period);
|
|
207
|
-
date.setDate(0);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
211
|
-
periods = isReverse ? periods : periods.reverse(); // Months are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
212
|
-
|
|
213
|
-
return periods;
|
|
115
|
+
return getPeriods({
|
|
116
|
+
periodType: 'MONTHLY',
|
|
117
|
+
config,
|
|
118
|
+
fnFilter,
|
|
119
|
+
calendar
|
|
120
|
+
});
|
|
214
121
|
};
|
|
215
122
|
};
|
|
216
123
|
|
|
217
|
-
const getBiMonthlyPeriodType = (
|
|
124
|
+
const getBiMonthlyPeriodType = (fnFilter, calendar) => {
|
|
218
125
|
return config => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
let index = 6;
|
|
226
|
-
|
|
227
|
-
while (date.getFullYear() === year) {
|
|
228
|
-
const period = {};
|
|
229
|
-
period.endDate = formatYyyyMmDd(date);
|
|
230
|
-
date.setDate(0);
|
|
231
|
-
date.setDate(1);
|
|
232
|
-
period.startDate = formatYyyyMmDd(date);
|
|
233
|
-
const monthStart = getMonthName(date.getMonth());
|
|
234
|
-
const monthEnd = getMonthName(date.getMonth() + 1);
|
|
235
|
-
const fullYear = date.getFullYear();
|
|
236
|
-
period.name = "".concat(monthStart, " - ").concat(monthEnd, " ").concat(fullYear);
|
|
237
|
-
period.iso = "".concat(year, "0").concat(index, "B");
|
|
238
|
-
period.id = period.iso;
|
|
239
|
-
periods.push(period);
|
|
240
|
-
date.setDate(0);
|
|
241
|
-
index--;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
245
|
-
periods = isReverse ? periods : periods.reverse(); // Bi-months are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
246
|
-
|
|
247
|
-
return periods;
|
|
126
|
+
return getPeriods({
|
|
127
|
+
periodType: 'BIMONTHLY',
|
|
128
|
+
config,
|
|
129
|
+
fnFilter,
|
|
130
|
+
calendar
|
|
131
|
+
});
|
|
248
132
|
};
|
|
249
133
|
};
|
|
250
134
|
|
|
251
|
-
const getQuarterlyPeriodType = (
|
|
135
|
+
const getQuarterlyPeriodType = (fnFilter, calendar) => {
|
|
252
136
|
return config => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
let quarter = 4;
|
|
260
|
-
|
|
261
|
-
while (date.getFullYear() === year) {
|
|
262
|
-
const period = {};
|
|
263
|
-
period.endDate = formatYyyyMmDd(date);
|
|
264
|
-
date.setDate(0);
|
|
265
|
-
date.setDate(0);
|
|
266
|
-
date.setDate(1);
|
|
267
|
-
period.startDate = formatYyyyMmDd(date);
|
|
268
|
-
const monthStart = getMonthName(date.getMonth());
|
|
269
|
-
const monthEnd = getMonthName(date.getMonth() + 2);
|
|
270
|
-
const fullYear = date.getFullYear();
|
|
271
|
-
period.name = "".concat(monthStart, " - ").concat(monthEnd, " ").concat(fullYear);
|
|
272
|
-
period.iso = "".concat(year, "Q").concat(quarter);
|
|
273
|
-
period.id = period.iso;
|
|
274
|
-
periods.push(period);
|
|
275
|
-
date.setDate(0);
|
|
276
|
-
quarter -= 1;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
280
|
-
periods = isReverse ? periods : periods.reverse(); // Quarters are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
281
|
-
|
|
282
|
-
return periods;
|
|
137
|
+
return getPeriods({
|
|
138
|
+
periodType: 'QUARTERLY',
|
|
139
|
+
config,
|
|
140
|
+
fnFilter,
|
|
141
|
+
calendar
|
|
142
|
+
});
|
|
283
143
|
};
|
|
284
144
|
};
|
|
285
145
|
|
|
286
|
-
const getSixMonthlyPeriodType = fnFilter => {
|
|
146
|
+
const getSixMonthlyPeriodType = (fnFilter, calendar) => {
|
|
287
147
|
return config => {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
period.startDate = "".concat(year, "-01-01");
|
|
295
|
-
period.endDate = "".concat(year, "-06-30");
|
|
296
|
-
period.name = "".concat(getMonthName(0), " - ").concat(getMonthName(5), " ").concat(year);
|
|
297
|
-
period.iso = "".concat(year, "S1");
|
|
298
|
-
period.id = period.iso;
|
|
299
|
-
periods.push(period);
|
|
300
|
-
period = {};
|
|
301
|
-
period.startDate = "".concat(year, "-07-01");
|
|
302
|
-
period.endDate = "".concat(year, "-12-31");
|
|
303
|
-
period.name = "".concat(getMonthName(6), " - ").concat(getMonthName(11), " ").concat(year);
|
|
304
|
-
period.iso = "".concat(year, "S2");
|
|
305
|
-
period.id = period.iso;
|
|
306
|
-
periods.push(period);
|
|
307
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
308
|
-
periods = isReverse ? periods.reverse() : periods;
|
|
309
|
-
return periods;
|
|
148
|
+
return getPeriods({
|
|
149
|
+
periodType: 'SIXMONTHLY',
|
|
150
|
+
config,
|
|
151
|
+
fnFilter,
|
|
152
|
+
calendar
|
|
153
|
+
});
|
|
310
154
|
};
|
|
311
155
|
};
|
|
312
156
|
|
|
313
|
-
const getSixMonthlyAprilPeriodType = fnFilter => {
|
|
157
|
+
const getSixMonthlyAprilPeriodType = (fnFilter, calendar) => {
|
|
314
158
|
return config => {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
period.startDate = "".concat(year, "-04-01");
|
|
322
|
-
period.endDate = "".concat(year, "-09-30");
|
|
323
|
-
period.name = "".concat(getMonthName(3), " - ").concat(getMonthName(8), " ").concat(year);
|
|
324
|
-
period.iso = "".concat(year, "AprilS1");
|
|
325
|
-
period.id = period.iso;
|
|
326
|
-
periods.push(period);
|
|
327
|
-
period = {};
|
|
328
|
-
period.startDate = "".concat(year, "-10-01");
|
|
329
|
-
period.endDate = "".concat(year + 1, "-03-31");
|
|
330
|
-
period.name = "".concat(getMonthName(9), " ").concat(year, " - ").concat(getMonthName(2), " ").concat(year + 1);
|
|
331
|
-
period.iso = "".concat(year, "AprilS2");
|
|
332
|
-
period.id = period.iso;
|
|
333
|
-
periods.push(period);
|
|
334
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
335
|
-
periods = isReverse ? periods.reverse() : periods;
|
|
336
|
-
return periods;
|
|
159
|
+
return getPeriods({
|
|
160
|
+
periodType: 'SIXMONTHLYAPR',
|
|
161
|
+
config,
|
|
162
|
+
fnFilter,
|
|
163
|
+
calendar
|
|
164
|
+
});
|
|
337
165
|
};
|
|
338
166
|
};
|
|
339
167
|
|
|
340
|
-
const getYearlyPeriodType = (
|
|
168
|
+
const getYearlyPeriodType = (fnFilter, calendar) => {
|
|
341
169
|
return config => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
while (year - date.getFullYear() < 10) {
|
|
350
|
-
const period = {};
|
|
351
|
-
period.endDate = formatYyyyMmDd(date);
|
|
352
|
-
date.setMonth(0, 1);
|
|
353
|
-
period.startDate = formatYyyyMmDd(date);
|
|
354
|
-
const dateString = date.getFullYear().toString();
|
|
355
|
-
period.name = dateString;
|
|
356
|
-
period.iso = date.getFullYear().toString();
|
|
357
|
-
period.id = period.iso.toString();
|
|
358
|
-
periods.push(period);
|
|
359
|
-
date.setDate(0);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
363
|
-
periods = isReverse ? periods : periods.reverse(); // Years are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
364
|
-
|
|
365
|
-
return periods;
|
|
170
|
+
return getPeriods({
|
|
171
|
+
periodType: 'YEARLY',
|
|
172
|
+
config,
|
|
173
|
+
fnFilter,
|
|
174
|
+
calendar
|
|
175
|
+
});
|
|
366
176
|
};
|
|
367
177
|
};
|
|
368
178
|
|
|
369
|
-
const getFinancialOctoberPeriodType = (
|
|
179
|
+
const getFinancialOctoberPeriodType = (fnFilter, calendar) => {
|
|
370
180
|
return config => {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
for (let i = 0; i < 10; i++) {
|
|
379
|
-
const period = {};
|
|
380
|
-
period.endDate = formatYyyyMmDd(date);
|
|
381
|
-
date.setYear(date.getFullYear() - 1);
|
|
382
|
-
date.setDate(date.getDate() + 1);
|
|
383
|
-
period.startDate = formatYyyyMmDd(date);
|
|
384
|
-
const yearStart = date.getFullYear();
|
|
385
|
-
const yearEnd = date.getFullYear() + 1;
|
|
386
|
-
period.name = "".concat(getMonthName(9), " ").concat(yearStart, " - ").concat(getMonthName(8), " ").concat(yearEnd);
|
|
387
|
-
period.id = "".concat(date.getFullYear(), "Oct");
|
|
388
|
-
periods.push(period);
|
|
389
|
-
date.setDate(date.getDate() - 1);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
393
|
-
periods = isReverse ? periods : periods.reverse(); // FinancialOctober periods are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
394
|
-
|
|
395
|
-
return periods;
|
|
181
|
+
return getPeriods({
|
|
182
|
+
periodType: 'FYOCT',
|
|
183
|
+
config,
|
|
184
|
+
fnFilter,
|
|
185
|
+
calendar
|
|
186
|
+
});
|
|
396
187
|
};
|
|
397
188
|
};
|
|
398
189
|
|
|
399
|
-
const getFinancialNovemberPeriodType = (
|
|
190
|
+
const getFinancialNovemberPeriodType = (fnFilter, calendar) => {
|
|
400
191
|
return config => {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
for (let i = 0; i < 10; i++) {
|
|
409
|
-
const period = {};
|
|
410
|
-
period.endDate = formatYyyyMmDd(date);
|
|
411
|
-
date.setYear(date.getFullYear() - 1);
|
|
412
|
-
date.setDate(date.getDate() + 1);
|
|
413
|
-
period.startDate = formatYyyyMmDd(date);
|
|
414
|
-
const yearStart = date.getFullYear();
|
|
415
|
-
const yearEnd = date.getFullYear() + 1;
|
|
416
|
-
period.name = "".concat(getMonthName(10), " ").concat(yearStart, " - ").concat(getMonthName(9), " ").concat(yearEnd);
|
|
417
|
-
period.id = "".concat(date.getFullYear(), "Nov");
|
|
418
|
-
periods.push(period);
|
|
419
|
-
date.setDate(date.getDate() - 1);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
423
|
-
periods = isReverse ? periods : periods.reverse(); // FinancialNovember periods are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
424
|
-
|
|
425
|
-
return periods;
|
|
192
|
+
return getPeriods({
|
|
193
|
+
periodType: 'FYNOV',
|
|
194
|
+
config,
|
|
195
|
+
fnFilter,
|
|
196
|
+
calendar
|
|
197
|
+
});
|
|
426
198
|
};
|
|
427
199
|
};
|
|
428
200
|
|
|
429
|
-
const getFinancialJulyPeriodType = (
|
|
201
|
+
const getFinancialJulyPeriodType = (fnFilter, calendar) => {
|
|
430
202
|
return config => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
for (let i = 0; i < 10; i++) {
|
|
439
|
-
const period = {};
|
|
440
|
-
period.endDate = formatYyyyMmDd(date);
|
|
441
|
-
date.setYear(date.getFullYear() - 1);
|
|
442
|
-
date.setDate(date.getDate() + 1);
|
|
443
|
-
period.startDate = formatYyyyMmDd(date);
|
|
444
|
-
const yearStart = date.getFullYear();
|
|
445
|
-
const yearEnd = date.getFullYear() + 1;
|
|
446
|
-
period.name = "".concat(getMonthName(6), " ").concat(yearStart, " - ").concat(getMonthName(5), " ").concat(yearEnd);
|
|
447
|
-
period.id = "".concat(date.getFullYear(), "July");
|
|
448
|
-
periods.push(period);
|
|
449
|
-
date.setDate(date.getDate() - 1);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
453
|
-
periods = isReverse ? periods : periods.reverse(); // FinancialJuly periods are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
454
|
-
|
|
455
|
-
return periods;
|
|
203
|
+
return getPeriods({
|
|
204
|
+
periodType: 'FYJUL',
|
|
205
|
+
config,
|
|
206
|
+
fnFilter,
|
|
207
|
+
calendar
|
|
208
|
+
});
|
|
456
209
|
};
|
|
457
210
|
};
|
|
458
211
|
|
|
459
|
-
const getFinancialAprilPeriodType = (
|
|
212
|
+
const getFinancialAprilPeriodType = (fnFilter, calendar) => {
|
|
460
213
|
return config => {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
for (let i = 0; i < 10; i++) {
|
|
469
|
-
const period = {};
|
|
470
|
-
period.endDate = formatYyyyMmDd(date);
|
|
471
|
-
date.setYear(date.getFullYear() - 1);
|
|
472
|
-
date.setDate(date.getDate() + 1);
|
|
473
|
-
period.startDate = formatYyyyMmDd(date);
|
|
474
|
-
const yearStart = date.getFullYear();
|
|
475
|
-
const yearEnd = date.getFullYear() + 1;
|
|
476
|
-
period.name = "".concat(getMonthName(3), " ").concat(yearStart, " - ").concat(getMonthName(2), " ").concat(yearEnd);
|
|
477
|
-
period.id = "".concat(date.getFullYear(), "April");
|
|
478
|
-
periods.push(period);
|
|
479
|
-
date.setDate(date.getDate() - 1);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
periods = isFilter ? fnFilter(periods) : periods;
|
|
483
|
-
periods = isReverse ? periods : periods.reverse(); // FinancialApril periods are collected backwards. If isReverse is true, then do nothing. Else reverse to correct order and return.
|
|
484
|
-
|
|
485
|
-
return periods;
|
|
214
|
+
return getPeriods({
|
|
215
|
+
periodType: 'FYAPR',
|
|
216
|
+
config,
|
|
217
|
+
fnFilter,
|
|
218
|
+
calendar
|
|
219
|
+
});
|
|
486
220
|
};
|
|
487
221
|
};
|
|
488
222
|
|
|
489
|
-
const formatYyyyMmDd = date => {
|
|
490
|
-
const y = date.getFullYear();
|
|
491
|
-
let m = String(date.getMonth() + 1);
|
|
492
|
-
let d = String(date.getDate());
|
|
493
|
-
m = m.length < 2 ? "0".concat(m) : m;
|
|
494
|
-
d = d.length < 2 ? "0".concat(d) : d;
|
|
495
|
-
return "".concat(y, "-").concat(m, "-").concat(d);
|
|
496
|
-
};
|
|
497
|
-
|
|
498
223
|
const filterFuturePeriods = periods => {
|
|
499
224
|
const array = [];
|
|
500
225
|
const now = new Date(Date.now());
|
|
@@ -508,92 +233,93 @@ const filterFuturePeriods = periods => {
|
|
|
508
233
|
return array;
|
|
509
234
|
};
|
|
510
235
|
|
|
511
|
-
const getOptions = ()
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}, {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
},
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
236
|
+
const getOptions = function () {
|
|
237
|
+
let calendar = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'gregory';
|
|
238
|
+
return [{
|
|
239
|
+
id: _index2.DAILY,
|
|
240
|
+
getPeriods: getDailyPeriodType(filterFuturePeriods, calendar),
|
|
241
|
+
name: _index.default.t('Daily')
|
|
242
|
+
}, {
|
|
243
|
+
id: _index2.WEEKLY,
|
|
244
|
+
getPeriods: getWeeklyPeriodType({
|
|
245
|
+
startDay: 1
|
|
246
|
+
}, filterFuturePeriods, calendar),
|
|
247
|
+
name: _index.default.t('Weekly')
|
|
248
|
+
}, {
|
|
249
|
+
id: _index2.WEEKLYWED,
|
|
250
|
+
getPeriods: getWeeklyPeriodType({
|
|
251
|
+
startDay: 3
|
|
252
|
+
}, filterFuturePeriods, calendar),
|
|
253
|
+
name: _index.default.t('Weekly (Start Wednesday)')
|
|
254
|
+
}, {
|
|
255
|
+
id: _index2.WEEKLYTHU,
|
|
256
|
+
getPeriods: getWeeklyPeriodType({
|
|
257
|
+
startDay: 4
|
|
258
|
+
}, filterFuturePeriods, calendar),
|
|
259
|
+
name: _index.default.t('Weekly (Start Thursday)')
|
|
260
|
+
}, {
|
|
261
|
+
id: _index2.WEEKLYSAT,
|
|
262
|
+
getPeriods: getWeeklyPeriodType({
|
|
263
|
+
startDay: 6
|
|
264
|
+
}, filterFuturePeriods, calendar),
|
|
265
|
+
name: _index.default.t('Weekly (Start Saturday)')
|
|
266
|
+
}, {
|
|
267
|
+
id: _index2.WEEKLYSUN,
|
|
268
|
+
getPeriods: getWeeklyPeriodType({
|
|
269
|
+
startDay: 7
|
|
270
|
+
}, filterFuturePeriods, calendar),
|
|
271
|
+
name: _index.default.t('Weekly (Start Sunday)')
|
|
272
|
+
}, {
|
|
273
|
+
id: _index2.BIWEEKLY,
|
|
274
|
+
getPeriods: getBiWeeklyPeriodType(filterFuturePeriods, calendar),
|
|
275
|
+
name: _index.default.t('Bi-weekly')
|
|
276
|
+
}, {
|
|
277
|
+
id: _index2.MONTHLY,
|
|
278
|
+
getPeriods: getMonthlyPeriodType(filterFuturePeriods, calendar),
|
|
279
|
+
name: _index.default.t('Monthly')
|
|
280
|
+
}, {
|
|
281
|
+
id: _index2.BIMONTHLY,
|
|
282
|
+
getPeriods: getBiMonthlyPeriodType(filterFuturePeriods, calendar),
|
|
283
|
+
name: _index.default.t('Bi-monthly')
|
|
284
|
+
}, {
|
|
285
|
+
id: _index2.QUARTERLY,
|
|
286
|
+
getPeriods: getQuarterlyPeriodType(filterFuturePeriods, calendar),
|
|
287
|
+
name: _index.default.t('Quarterly')
|
|
288
|
+
}, {
|
|
289
|
+
id: _index2.SIXMONTHLY,
|
|
290
|
+
getPeriods: getSixMonthlyPeriodType(filterFuturePeriods, calendar),
|
|
291
|
+
name: _index.default.t('Six-monthly')
|
|
292
|
+
}, {
|
|
293
|
+
id: _index2.SIXMONTHLYAPR,
|
|
294
|
+
getPeriods: getSixMonthlyAprilPeriodType(filterFuturePeriods, calendar),
|
|
295
|
+
name: _index.default.t('Six-monthly April')
|
|
296
|
+
}, {
|
|
297
|
+
id: _index2.YEARLY,
|
|
298
|
+
getPeriods: getYearlyPeriodType(filterFuturePeriods, calendar),
|
|
299
|
+
name: _index.default.t('Yearly')
|
|
300
|
+
}, {
|
|
301
|
+
id: _index2.FYNOV,
|
|
302
|
+
getPeriods: getFinancialNovemberPeriodType(filterFuturePeriods, calendar),
|
|
303
|
+
name: _index.default.t('Financial year (Start November)')
|
|
304
|
+
}, {
|
|
305
|
+
id: _index2.FYOCT,
|
|
306
|
+
getPeriods: getFinancialOctoberPeriodType(filterFuturePeriods, calendar),
|
|
307
|
+
name: _index.default.t('Financial year (Start October)')
|
|
308
|
+
}, {
|
|
309
|
+
id: _index2.FYJUL,
|
|
310
|
+
getPeriods: getFinancialJulyPeriodType(filterFuturePeriods, calendar),
|
|
311
|
+
name: _index.default.t('Financial year (Start July)')
|
|
312
|
+
}, {
|
|
313
|
+
id: _index2.FYAPR,
|
|
314
|
+
getPeriods: getFinancialAprilPeriodType(filterFuturePeriods, calendar),
|
|
315
|
+
name: _index.default.t('Financial year (Start April)')
|
|
316
|
+
}];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const getFixedPeriodsOptionsById = function (id) {
|
|
320
|
+
let calendar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gregory';
|
|
321
|
+
return getOptions(calendar).find(option => option.id === id);
|
|
322
|
+
};
|
|
597
323
|
|
|
598
324
|
exports.getFixedPeriodsOptionsById = getFixedPeriodsOptionsById;
|
|
599
325
|
|