@zeniai/client-epic-state 5.0.17 → 5.0.18-betaSS1

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,7 +1,7 @@
1
1
  import omit from 'lodash/omit';
2
2
  import orderBy from 'lodash/orderBy';
3
3
  import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
4
- import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
+ import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
5
5
  import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
6
6
  import { getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
7
7
  import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
@@ -23,19 +23,33 @@ function getJEScheduleSortAccessor(sortKey) {
23
23
  case 'depCategory':
24
24
  return (s) => s.jeCredit.account?.accountName?.toLowerCase();
25
25
  case 'scheduleCategory':
26
- return (s) => s.jeScheduleType;
26
+ return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
27
27
  case 'startMonth':
28
28
  return (s) => s.startDate?.valueOf();
29
29
  case 'type':
30
- return (s) => s.baseTransaction.typeOfTransaction;
30
+ return (s) => s.jeScheduleType;
31
31
  case 'amortizationPeriod':
32
32
  return (s) => s.period;
33
33
  case 'jePostingDate':
34
- return (s) => s.dayOfPostingDate;
34
+ return (s) => s.lastDayOfMonth === true
35
+ ? LAST_SCHEDULE_DAY_OF_MONTH
36
+ : (s.dayOfPostingDate ?? null);
35
37
  case 'remainingMonths':
36
- return (s) => s.period;
38
+ return (s) => {
39
+ const total = s.period ?? 0;
40
+ const posted = Array.isArray(s.scheduledJournalEntry)
41
+ ? s.scheduledJournalEntry.length
42
+ : 0;
43
+ return total - posted;
44
+ };
37
45
  case 'runningBalance':
38
- return (s) => s.balanceAsOfToday?.amount;
46
+ return (s) => {
47
+ const sje = s.scheduledJournalEntry;
48
+ if (sje != null && !Array.isArray(sje)) {
49
+ return sje.runningBalance?.amount ?? null;
50
+ }
51
+ return s.balanceAsOfToday?.amount ?? null;
52
+ };
39
53
  case 'totalAmount':
40
54
  return (s) => s.baseTransaction.amount.amount;
41
55
  case 'transactionDate':
@@ -114,6 +128,11 @@ export function getExpenseAutomationJESchedulesView(state) {
114
128
  });
115
129
  });
116
130
  const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
131
+ const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
132
+ const pendingReviewSchedules = sortJEScheduledTransactions([
133
+ ...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
134
+ ...validResolveForPending,
135
+ ], sortKey, sortOrder);
117
136
  const allSteps = monthYearPeriodId != null
118
137
  ? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
119
138
  : [];
@@ -137,6 +156,7 @@ export function getExpenseAutomationJESchedulesView(state) {
137
156
  completedSchedules,
138
157
  draftSchedules,
139
158
  ongoingSchedules,
159
+ pendingReviewSchedules,
140
160
  resolveSchedules: resolveSchedules,
141
161
  accountSettingsView,
142
162
  postStatusById: postStatusById,
@@ -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 { toMonth, toMonthYearPeriodId, } from '../../commonStateTypes/timePeriod';
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, dateNow } from '../../zeniDayJS';
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
- : false;
51
+ : true;
60
52
  return {
61
53
  ...check,
62
54
  isDisabled,
@@ -47,8 +47,13 @@ const sortedJETransactionsView = (jeTransactions, sortKey, sortOrder) => {
47
47
  return jeTransaction.endDate != null
48
48
  ? jeTransaction.endDate.valueOf()
49
49
  : null;
50
- case 'months':
51
- return jeTransaction.period ?? null;
50
+ case 'months': {
51
+ const total = jeTransaction.period ?? 0;
52
+ const posted = Array.isArray(jeTransaction.scheduledJournalEntry)
53
+ ? jeTransaction.scheduledJournalEntry.length
54
+ : 0;
55
+ return total - posted;
56
+ }
52
57
  case 'transactionType':
53
58
  return jeTransaction.baseTransaction.type.toLowerCase();
54
59
  case 'status':
@@ -24,6 +24,7 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
24
24
  ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
25
25
  jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
26
26
  ongoingSchedules: JEScheduledTransaction[];
27
+ pendingReviewSchedules: (JEScheduledTransaction | JEScheduledTransactionWithFailedEntries)[];
27
28
  postStatusById: Record<ID, FetchStateAndError>;
28
29
  refreshStatus: FetchStateAndError;
29
30
  resolveSchedules: JEScheduledTransactionWithFailedEntries[];
@@ -29,19 +29,33 @@ function getJEScheduleSortAccessor(sortKey) {
29
29
  case 'depCategory':
30
30
  return (s) => s.jeCredit.account?.accountName?.toLowerCase();
31
31
  case 'scheduleCategory':
32
- return (s) => s.jeScheduleType;
32
+ return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
33
33
  case 'startMonth':
34
34
  return (s) => s.startDate?.valueOf();
35
35
  case 'type':
36
- return (s) => s.baseTransaction.typeOfTransaction;
36
+ return (s) => s.jeScheduleType;
37
37
  case 'amortizationPeriod':
38
38
  return (s) => s.period;
39
39
  case 'jePostingDate':
40
- return (s) => s.dayOfPostingDate;
40
+ return (s) => s.lastDayOfMonth === true
41
+ ? timePeriod_1.LAST_SCHEDULE_DAY_OF_MONTH
42
+ : (s.dayOfPostingDate ?? null);
41
43
  case 'remainingMonths':
42
- return (s) => s.period;
44
+ return (s) => {
45
+ const total = s.period ?? 0;
46
+ const posted = Array.isArray(s.scheduledJournalEntry)
47
+ ? s.scheduledJournalEntry.length
48
+ : 0;
49
+ return total - posted;
50
+ };
43
51
  case 'runningBalance':
44
- return (s) => s.balanceAsOfToday?.amount;
52
+ return (s) => {
53
+ const sje = s.scheduledJournalEntry;
54
+ if (sje != null && !Array.isArray(sje)) {
55
+ return sje.runningBalance?.amount ?? null;
56
+ }
57
+ return s.balanceAsOfToday?.amount ?? null;
58
+ };
45
59
  case 'totalAmount':
46
60
  return (s) => s.baseTransaction.amount.amount;
47
61
  case 'transactionDate':
@@ -120,6 +134,11 @@ function getExpenseAutomationJESchedulesView(state) {
120
134
  });
121
135
  });
122
136
  const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
137
+ const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
138
+ const pendingReviewSchedules = sortJEScheduledTransactions([
139
+ ...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
140
+ ...validResolveForPending,
141
+ ], sortKey, sortOrder);
123
142
  const allSteps = monthYearPeriodId != null
124
143
  ? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
125
144
  : [];
@@ -143,6 +162,7 @@ function getExpenseAutomationJESchedulesView(state) {
143
162
  completedSchedules,
144
163
  draftSchedules,
145
164
  ongoingSchedules,
165
+ pendingReviewSchedules,
146
166
  resolveSchedules: resolveSchedules,
147
167
  accountSettingsView,
148
168
  postStatusById: postStatusById,
@@ -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
- : false;
55
+ : true;
67
56
  return {
68
57
  ...check,
69
58
  isDisabled,
@@ -53,8 +53,13 @@ const sortedJETransactionsView = (jeTransactions, sortKey, sortOrder) => {
53
53
  return jeTransaction.endDate != null
54
54
  ? jeTransaction.endDate.valueOf()
55
55
  : null;
56
- case 'months':
57
- return jeTransaction.period ?? null;
56
+ case 'months': {
57
+ const total = jeTransaction.period ?? 0;
58
+ const posted = Array.isArray(jeTransaction.scheduledJournalEntry)
59
+ ? jeTransaction.scheduledJournalEntry.length
60
+ : 0;
61
+ return total - posted;
62
+ }
58
63
  case 'transactionType':
59
64
  return jeTransaction.baseTransaction.type.toLowerCase();
60
65
  case 'status':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.17",
3
+ "version": "5.0.18-betaSS1",
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",