@zeniai/client-epic-state 5.0.17 → 5.0.18
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.
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { createSelector } from '@reduxjs/toolkit';
|
|
2
|
-
import isEqual from 'lodash/isEqual';
|
|
3
2
|
import { DEFAULT_DATE_FORMAT } from '../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
4
|
-
import {
|
|
3
|
+
import { toMonthYearPeriodId, } from '../../commonStateTypes/timePeriod';
|
|
5
4
|
import { getMonthEndCloseChecksByTenantId } from '../../entity/monthEndCloseChecks/monthEndCloseChecksSelector';
|
|
6
5
|
import { defaultMonthYearPeriod } from '../../entity/tenant/epic/fetchAllTenantsEpic';
|
|
7
6
|
import { getCurrentTenant, } from '../../entity/tenant/tenantSelector';
|
|
8
|
-
import { date
|
|
7
|
+
import { date } from '../../zeniDayJS';
|
|
9
8
|
export const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary) => {
|
|
10
9
|
if (auditSummary != null) {
|
|
11
10
|
if (auditSummary.auditScorePercentage < 75 &&
|
|
12
11
|
userAllowedToAccessMonthEndInsights === false) {
|
|
13
12
|
return true;
|
|
14
13
|
}
|
|
15
|
-
const previousMonthPeriod = {
|
|
16
|
-
month: toMonth(dateNow().subtract(1, 'month').month() + 1),
|
|
17
|
-
year: dateNow().subtract(1, 'month').year(),
|
|
18
|
-
};
|
|
19
|
-
if (!isEqual(previousMonthPeriod, selectedPeriod)) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
14
|
// if the selected period is November 2024, then book close date should not be null and book close date should be 30th November 2024
|
|
23
15
|
const { bookCloseDate } = currentTenant;
|
|
24
16
|
const selectedPeriodFirstDay = date(`${selectedPeriod.year}-${selectedPeriod.month}-01`);
|
|
@@ -56,7 +48,7 @@ export const getMonthEndCloseChecksViewByTenantId = createSelector((state) => st
|
|
|
56
48
|
if (check.id === 'month_end_insights') {
|
|
57
49
|
const isDisabled = monthEndCloseChecks.reportEmailSentDate == null
|
|
58
50
|
? isMonthEndInsightDisabled(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, monthEndCloseChecks.auditSummary)
|
|
59
|
-
:
|
|
51
|
+
: true;
|
|
60
52
|
return {
|
|
61
53
|
...check,
|
|
62
54
|
isDisabled,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getMonthEndCloseChecksViewByTenantId = exports.isMonthEndInsightDisabled = void 0;
|
|
7
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
8
|
-
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
9
5
|
const formatZeniDateFY_1 = require("../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
10
6
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
11
7
|
const monthEndCloseChecksSelector_1 = require("../../entity/monthEndCloseChecks/monthEndCloseChecksSelector");
|
|
@@ -18,13 +14,6 @@ const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToA
|
|
|
18
14
|
userAllowedToAccessMonthEndInsights === false) {
|
|
19
15
|
return true;
|
|
20
16
|
}
|
|
21
|
-
const previousMonthPeriod = {
|
|
22
|
-
month: (0, timePeriod_1.toMonth)((0, zeniDayJS_1.dateNow)().subtract(1, 'month').month() + 1),
|
|
23
|
-
year: (0, zeniDayJS_1.dateNow)().subtract(1, 'month').year(),
|
|
24
|
-
};
|
|
25
|
-
if (!(0, isEqual_1.default)(previousMonthPeriod, selectedPeriod)) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
17
|
// if the selected period is November 2024, then book close date should not be null and book close date should be 30th November 2024
|
|
29
18
|
const { bookCloseDate } = currentTenant;
|
|
30
19
|
const selectedPeriodFirstDay = (0, zeniDayJS_1.date)(`${selectedPeriod.year}-${selectedPeriod.month}-01`);
|
|
@@ -63,7 +52,7 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
|
|
|
63
52
|
if (check.id === 'month_end_insights') {
|
|
64
53
|
const isDisabled = monthEndCloseChecks.reportEmailSentDate == null
|
|
65
54
|
? (0, exports.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, monthEndCloseChecks.auditSummary)
|
|
66
|
-
:
|
|
55
|
+
: true;
|
|
67
56
|
return {
|
|
68
57
|
...check,
|
|
69
58
|
isDisabled,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.18",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|