@zeniai/client-epic-state 4.13.53 → 4.13.54
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/lib/entity/monthEndCloseChecks/monthEndCloseChecksPayload.d.ts +1 -1
- package/lib/entity/monthEndCloseChecks/monthEndCloseChecksPayload.js +5 -1
- package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +2 -1
- package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +10 -13
- package/lib/view/monthEndCloseChecksView/monthEndCloseChecksViewSelector.d.ts +3 -1
- package/lib/view/monthEndCloseChecksView/monthEndCloseChecksViewSelector.js +48 -4
- package/package.json +3 -2
|
@@ -25,8 +25,8 @@ export interface MonthEndCloseChecksPayload {
|
|
|
25
25
|
insights: MonthEndInsightsPayload;
|
|
26
26
|
audit_summary: MonthEndAuditSummaryPayload;
|
|
27
27
|
month_close_checks: MonthCloseChecksPayload[];
|
|
28
|
-
zeni_book_close_date: string;
|
|
29
28
|
history_month_and_year_flag: string[];
|
|
29
|
+
report_email_sent_date?: string;
|
|
30
30
|
}
|
|
31
31
|
export declare const toMonthEndCloseChecksInfo: (payload: MonthEndCloseChecksPayload, period: MonthYearPeriod) => MonthEndCloseChecksInfo;
|
|
32
32
|
export {};
|
|
@@ -14,6 +14,8 @@ const toMonthEndCloseCheck = (monthCloseCheck) => {
|
|
|
14
14
|
frequency: (0, monthEndCloseChecksState_1.toMonthEndCloseCheckFrequency)(monthCloseCheck.action_frequency),
|
|
15
15
|
progress: monthCloseCheck.progress_percentage,
|
|
16
16
|
sequence: monthCloseCheck.sequence,
|
|
17
|
+
isDisabled: (0, expenseAutomationViewState_1.toExpenseAutomationViewType)(monthCloseCheck.month_close_check_type) ===
|
|
18
|
+
'month_end_insights',
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
const toMonthEndInsights = (monthEndStatisticsPayload) => {
|
|
@@ -52,7 +54,9 @@ const toMonthEndCloseChecksInfo = (payload, period) => ({
|
|
|
52
54
|
? (0, zeniDayJS_1.date)(payload.audit_summary.audit_report_last_generated_date)
|
|
53
55
|
: null,
|
|
54
56
|
},
|
|
55
|
-
|
|
57
|
+
reportEmailSentDate: payload.report_email_sent_date != null
|
|
58
|
+
? (0, zeniDayJS_1.date)(payload.report_email_sent_date)
|
|
59
|
+
: undefined,
|
|
56
60
|
historicMonthYear: payload.history_month_and_year_flag != null
|
|
57
61
|
? toMonthYearPeriods(payload.history_month_and_year_flag)
|
|
58
62
|
: [],
|
|
@@ -11,6 +11,7 @@ export interface MonthEndCloseCheck {
|
|
|
11
11
|
description: string;
|
|
12
12
|
progress: number;
|
|
13
13
|
frequency: MonthEndCloseCheckFrequency;
|
|
14
|
+
isDisabled: boolean;
|
|
14
15
|
sequence: number;
|
|
15
16
|
}
|
|
16
17
|
export interface MonthEndInsights {
|
|
@@ -30,8 +31,8 @@ export interface MonthEndCloseChecksInfo {
|
|
|
30
31
|
auditSummary: MonthEndAuditSummary;
|
|
31
32
|
monthEndCloseCheckList: MonthEndCloseCheck[];
|
|
32
33
|
id: MonthYearPeriodId;
|
|
33
|
-
zeniBookCloseDate: ZeniDate;
|
|
34
34
|
historicMonthYear: MonthYearPeriod[];
|
|
35
|
+
reportEmailSentDate?: ZeniDate;
|
|
35
36
|
}
|
|
36
37
|
export interface MonthEndCloseChecksState {
|
|
37
38
|
monthEndCloseChecksByTenantId: Record<ID, Record<MonthYearPeriodId, MonthEndCloseChecksInfo>>;
|
|
@@ -12,19 +12,16 @@ const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
|
12
12
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
13
13
|
const monthEndCloseChecksViewSelector_1 = require("../monthEndCloseChecksView/monthEndCloseChecksViewSelector");
|
|
14
14
|
const transactionCategorizationSelector_1 = require("./selectors/transactionCategorizationSelector");
|
|
15
|
-
const isPreviousStepDisabled = (allSteps, stepIndex, userAllowedToAccessMonthEndInsights, auditSummary) => {
|
|
15
|
+
const isPreviousStepDisabled = (allSteps, stepIndex, currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, reportEmailSentDate, auditSummary) => {
|
|
16
16
|
if (stepIndex === 0) {
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
17
|
+
return reportEmailSentDate == null
|
|
18
|
+
? (0, monthEndCloseChecksViewSelector_1.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary)
|
|
19
|
+
: false;
|
|
23
20
|
}
|
|
24
21
|
return allSteps[stepIndex - 1].isDisabled;
|
|
25
22
|
};
|
|
26
23
|
function getExpenseAutomationView(state) {
|
|
27
|
-
var _a, _b;
|
|
24
|
+
var _a, _b, _c;
|
|
28
25
|
const { expenseAutomationViewState, tenantState, expenseAutomationMissingReceiptsViewState, expenseAutomationJESchedulesViewState, monthEndCloseChecksState, companyState, } = state;
|
|
29
26
|
const { loggedInUser, currentTenantId } = tenantState;
|
|
30
27
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
@@ -56,6 +53,7 @@ function getExpenseAutomationView(state) {
|
|
|
56
53
|
auditSummary = (_b = (0, monthEndCloseChecksSelector_1.getMonthEndCloseChecksForATenantForSelectedPeriod)(monthEndCloseChecksState, currentTenantId, selectedPeriod)) === null || _b === void 0 ? void 0 : _b.auditSummary;
|
|
57
54
|
}
|
|
58
55
|
allSteps = (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId, auditSummary);
|
|
56
|
+
const reportEmailSentDate = (_c = monthEndCloseChecksView.monthEndCloseChecks) === null || _c === void 0 ? void 0 : _c.reportEmailSentDate;
|
|
59
57
|
allSteps.forEach((stepDetail, index, allStepsOriginal) => {
|
|
60
58
|
switch (stepDetail.step) {
|
|
61
59
|
case 'transaction_categorization':
|
|
@@ -68,10 +66,9 @@ function getExpenseAutomationView(state) {
|
|
|
68
66
|
allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { completionStatus: missingReceipts.completionStatus });
|
|
69
67
|
return;
|
|
70
68
|
case 'month_end_insights':
|
|
71
|
-
allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { isDisabled:
|
|
72
|
-
?
|
|
73
|
-
|
|
74
|
-
: true });
|
|
69
|
+
allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { isDisabled: reportEmailSentDate == null
|
|
70
|
+
? (0, monthEndCloseChecksViewSelector_1.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary)
|
|
71
|
+
: false });
|
|
75
72
|
return;
|
|
76
73
|
case 'flux_analysis':
|
|
77
74
|
default:
|
|
@@ -82,7 +79,7 @@ function getExpenseAutomationView(state) {
|
|
|
82
79
|
allSteps.forEach((stepDetail, index, allStepsOriginal) => {
|
|
83
80
|
allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { isNextDisabled: index === allStepsOriginal.length - 1
|
|
84
81
|
? allStepsOriginal[0].isDisabled
|
|
85
|
-
: allStepsOriginal[index + 1].isDisabled, isPrevDisabled: isPreviousStepDisabled(allStepsOriginal, index, userAllowedToAccessMonthEndInsights, auditSummary) });
|
|
82
|
+
: allStepsOriginal[index + 1].isDisabled, isPrevDisabled: isPreviousStepDisabled(allStepsOriginal, index, currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, reportEmailSentDate, auditSummary) });
|
|
86
83
|
});
|
|
87
84
|
}
|
|
88
85
|
const reducedFetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)(fetchStateVariables); // Add more states
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ID, FetchStateAndError } from '../../commonStateTypes/common';
|
|
2
2
|
import { SelectorView } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
3
3
|
import { RootState } from '../../reducer';
|
|
4
|
-
import { MonthEndCloseChecksInfo } from '../../entity/monthEndCloseChecks/monthEndCloseChecksState';
|
|
4
|
+
import { MonthEndCloseChecksInfo, MonthEndAuditSummary } from '../../entity/monthEndCloseChecks/monthEndCloseChecksState';
|
|
5
5
|
import { MonthYearPeriod } from '../../commonStateTypes/timePeriod';
|
|
6
|
+
import { CurrentTenant } from '../../entity/tenant/tenantSelector';
|
|
6
7
|
export interface MonthEndCloseChecksView extends SelectorView {
|
|
7
8
|
monthEndCloseChecks?: MonthEndCloseChecksInfo;
|
|
8
9
|
selectedPeriod: MonthYearPeriod;
|
|
9
10
|
refreshStatus: FetchStateAndError;
|
|
10
11
|
}
|
|
12
|
+
export declare const isMonthEndInsightDisabled: (currentTenant: CurrentTenant, selectedPeriod: MonthYearPeriod, userAllowedToAccessMonthEndInsights: boolean, auditSummary?: MonthEndAuditSummary | undefined) => boolean;
|
|
11
13
|
export declare const getMonthEndCloseChecksViewByTenantId: (state: RootState, tenantId: ID) => MonthEndCloseChecksView;
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMonthEndCloseChecksViewByTenantId = void 0;
|
|
6
|
+
exports.getMonthEndCloseChecksViewByTenantId = exports.isMonthEndInsightDisabled = void 0;
|
|
7
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
4
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
9
|
const monthEndCloseChecksSelector_1 = require("../../entity/monthEndCloseChecks/monthEndCloseChecksSelector");
|
|
6
10
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
12
|
+
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
13
|
+
const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary) => {
|
|
14
|
+
if (auditSummary != null) {
|
|
15
|
+
if (auditSummary.auditScorePercentage < 75 &&
|
|
16
|
+
userAllowedToAccessMonthEndInsights === false) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const lastReportSentMonthYearPeriod = currentTenant.zeniBookCloseMonthAndYear;
|
|
20
|
+
if (lastReportSentMonthYearPeriod == null) {
|
|
21
|
+
return (selectedPeriod.month === (0, zeniDayJS_1.dateNow)().get('month') &&
|
|
22
|
+
selectedPeriod.year === (0, zeniDayJS_1.dateNow)().get('year'));
|
|
23
|
+
}
|
|
24
|
+
const currentDate = (0, zeniDayJS_1.date)(`${lastReportSentMonthYearPeriod.year}-${lastReportSentMonthYearPeriod.month}-01`);
|
|
25
|
+
const nextMonthDate = currentDate.add(1, 'month');
|
|
26
|
+
const nextMonthPeriod = {
|
|
27
|
+
month: (0, timePeriod_1.toMonth)(nextMonthDate.month() + 1),
|
|
28
|
+
year: nextMonthDate.year(),
|
|
29
|
+
};
|
|
30
|
+
return !(0, isEqual_1.default)(selectedPeriod, nextMonthPeriod);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
exports.isMonthEndInsightDisabled = isMonthEndInsightDisabled;
|
|
35
|
+
exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((state) => state.monthEndCloseChecksState, (state) => state.monthEndCloseChecksViewState, (state) => state.expenseAutomationViewState, (state) => (0, tenantSelector_1.getCurrentTenant)(state), (state) => state.companyState, (state) => state.tenantState, (_state, tenantId) => tenantId, (monthEndCloseChecksState, monthEndCloseChecksViewState, expenseAutomationViewState, currentTenant, companyState, tenantState, tenantId) => {
|
|
36
|
+
var _a, _b;
|
|
9
37
|
const { refreshStatus } = monthEndCloseChecksViewState;
|
|
38
|
+
const { loggedInUser } = tenantState;
|
|
10
39
|
const selectedPeriod = expenseAutomationViewState.selectedPeriodByTenantId[tenantId];
|
|
11
40
|
const { monthEndCloseChecksViewByTenantId } = monthEndCloseChecksViewState;
|
|
12
41
|
const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : null;
|
|
@@ -20,7 +49,22 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
|
|
|
20
49
|
const sortedMonthEndCloseCheckList = [
|
|
21
50
|
...monthEndCloseChecks.monthEndCloseCheckList,
|
|
22
51
|
].sort((a, b) => b.frequency.localeCompare(a.frequency));
|
|
23
|
-
|
|
52
|
+
const currentCompany = companyState.companiesById[currentTenant.companyId];
|
|
53
|
+
const managementInfo = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.managementInfo;
|
|
54
|
+
const preparerUserIds = managementInfo != null ? managementInfo.preparerUserIds : [];
|
|
55
|
+
const isZeniUser = Boolean((_b = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.userEmail) === null || _b === void 0 ? void 0 : _b.includes('zeni.ai'));
|
|
56
|
+
const isPreparer = loggedInUser != null && preparerUserIds.includes(loggedInUser.userId);
|
|
57
|
+
const userAllowedToAccessMonthEndInsights = isZeniUser === false || isPreparer === false;
|
|
58
|
+
const monthEndCloseCheckListWithDisabledState = sortedMonthEndCloseCheckList.map((check) => {
|
|
59
|
+
if (check.id === 'month_end_insights') {
|
|
60
|
+
const isDisabled = monthEndCloseChecks.reportEmailSentDate == null
|
|
61
|
+
? (0, exports.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, monthEndCloseChecks.auditSummary)
|
|
62
|
+
: false;
|
|
63
|
+
return Object.assign(Object.assign({}, check), { isDisabled });
|
|
64
|
+
}
|
|
65
|
+
return check;
|
|
66
|
+
});
|
|
67
|
+
return Object.assign(Object.assign({}, monthEndCloseChecksView), { monthEndCloseChecks: Object.assign(Object.assign({}, monthEndCloseChecks), { monthEndCloseCheckList: monthEndCloseCheckListWithDisabledState }), reportId: 'expense_automation_card', selectedPeriod,
|
|
24
68
|
refreshStatus });
|
|
25
69
|
}
|
|
26
70
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.54",
|
|
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
|
"types": "lib/index.d.ts",
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"postversion": "git push && git push --tags",
|
|
95
95
|
"create-release-branch": "chmod +x ./scripts/create_release_branch.sh && ./scripts/create_release_branch.sh",
|
|
96
96
|
"bump-update-web-app-cockpit-beta": "chmod +x ./scripts/bump_and_update_web_app_ui_beta.sh && ./scripts/bump_and_update_web_app_ui_beta.sh",
|
|
97
|
-
"send-release-notes": "chmod +x ./scripts/send_release_notes.sh && ./scripts/send_release_notes.sh"
|
|
97
|
+
"send-release-notes": "chmod +x ./scripts/send_release_notes.sh && ./scripts/send_release_notes.sh",
|
|
98
|
+
"update-slack-group-topic": "chmod +x ./scripts/update-slack-group-topic.sh && ./scripts/update-slack-group-topic.sh"
|
|
98
99
|
}
|
|
99
100
|
}
|