@zeniai/client-epic-state 4.13.26 → 4.13.28

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.
@@ -12,10 +12,11 @@ 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, auditSummary) => {
15
+ const isPreviousStepDisabled = (allSteps, stepIndex, userAllowedToAccessMonthEndInsights, auditSummary) => {
16
16
  if (stepIndex === 0) {
17
- // TODO - Jitesh update condition
18
- if (auditSummary == null || auditSummary.auditScorePercentage < 75) {
17
+ if (auditSummary == null ||
18
+ (auditSummary.auditScorePercentage < 75 &&
19
+ userAllowedToAccessMonthEndInsights === false)) {
19
20
  return true;
20
21
  }
21
22
  return false;
@@ -23,8 +24,8 @@ const isPreviousStepDisabled = (allSteps, stepIndex, auditSummary) => {
23
24
  return allSteps[stepIndex - 1].isDisabled;
24
25
  };
25
26
  function getExpenseAutomationView(state) {
26
- var _a;
27
- const { expenseAutomationViewState, tenantState, expenseAutomationMissingReceiptsViewState, expenseAutomationJESchedulesViewState, monthEndCloseChecksState, } = state;
27
+ var _a, _b;
28
+ const { expenseAutomationViewState, tenantState, expenseAutomationMissingReceiptsViewState, expenseAutomationJESchedulesViewState, monthEndCloseChecksState, companyState, } = state;
28
29
  const { loggedInUser, currentTenantId } = tenantState;
29
30
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
30
31
  const { currentSelectedView, selectedPeriodByTenantId, selectedTransactionCategorizationTab, } = expenseAutomationViewState;
@@ -43,10 +44,19 @@ function getExpenseAutomationView(state) {
43
44
  ];
44
45
  let allSteps = [];
45
46
  let auditSummary = undefined;
47
+ const currentCompany = companyState.companiesById[currentTenant.companyId];
48
+ const managementInfo = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.managegmentInfo;
49
+ const controllerUserIds = managementInfo != null ? managementInfo.controllerUserIds : [];
50
+ const reviewerUserIds = managementInfo != null ? managementInfo.reviewerUserIds : [];
51
+ const isZeniUser = Boolean((_a = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.userEmail) === null || _a === void 0 ? void 0 : _a.includes('zeni.ai'));
52
+ const isControllerOrReviewer = loggedInUser != null &&
53
+ (controllerUserIds.includes(loggedInUser.userId) ||
54
+ reviewerUserIds.includes(loggedInUser.userId));
55
+ const userAllowedToAccessMonthEndInsights = isZeniUser === false || isControllerOrReviewer;
46
56
  if (selectedPeriod != null) {
47
57
  const monthYearPeriodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
48
58
  if (currentTenantId != null) {
49
- auditSummary = (_a = (0, monthEndCloseChecksSelector_1.getMonthEndCloseChecksForATenantForSelectedPeriod)(monthEndCloseChecksState, currentTenantId, selectedPeriod)) === null || _a === void 0 ? void 0 : _a.auditSummary;
59
+ auditSummary = (_b = (0, monthEndCloseChecksSelector_1.getMonthEndCloseChecksForATenantForSelectedPeriod)(monthEndCloseChecksState, currentTenantId, selectedPeriod)) === null || _b === void 0 ? void 0 : _b.auditSummary;
50
60
  }
51
61
  allSteps = (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId, auditSummary);
52
62
  allSteps.forEach((stepDetail, index, allStepsOriginal) => {
@@ -62,7 +72,8 @@ function getExpenseAutomationView(state) {
62
72
  return;
63
73
  case 'month_end_insights':
64
74
  allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { isDisabled: auditSummary != null
65
- ? auditSummary.auditScorePercentage < 75 // TODO - jk - update condition
75
+ ? auditSummary.auditScorePercentage < 75 &&
76
+ userAllowedToAccessMonthEndInsights === false
66
77
  : true });
67
78
  return;
68
79
  case 'flux_analysis':
@@ -74,7 +85,7 @@ function getExpenseAutomationView(state) {
74
85
  allSteps.forEach((stepDetail, index, allStepsOriginal) => {
75
86
  allStepsOriginal[index] = Object.assign(Object.assign({}, stepDetail), { isNextDisabled: index === allStepsOriginal.length - 1
76
87
  ? allStepsOriginal[0].isDisabled
77
- : allStepsOriginal[index + 1].isDisabled, isPrevDisabled: isPreviousStepDisabled(allStepsOriginal, index, auditSummary) });
88
+ : allStepsOriginal[index + 1].isDisabled, isPrevDisabled: isPreviousStepDisabled(allStepsOriginal, index, userAllowedToAccessMonthEndInsights, auditSummary) });
78
89
  });
79
90
  }
80
91
  const reducedFetchStatus = (0, reduceFetchState_1.reduceAnyFetchState)(fetchStateVariables); // Add more states
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.13.26",
3
+ "version": "4.13.28",
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",