@zeniai/client-epic-state 5.0.16-betaJK2 → 5.0.16-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.
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +26 -6
- package/lib/esm/view/monthEndCloseChecksView/monthEndCloseChecksViewSelector.js +11 -7
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListSelector.js +7 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +1 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +25 -5
- package/lib/view/monthEndCloseChecksView/monthEndCloseChecksViewSelector.js +12 -5
- package/lib/view/scheduleView/scheduleListView/scheduleListSelector.js +7 -2
- package/package.json +1 -1
|
@@ -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.
|
|
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.
|
|
30
|
+
return (s) => s.jeScheduleType;
|
|
31
31
|
case 'amortizationPeriod':
|
|
32
32
|
return (s) => s.period;
|
|
33
33
|
case 'jePostingDate':
|
|
34
|
-
return (s) => s.
|
|
34
|
+
return (s) => s.lastDayOfMonth === true
|
|
35
|
+
? LAST_SCHEDULE_DAY_OF_MONTH
|
|
36
|
+
: (s.dayOfPostingDate ?? null);
|
|
35
37
|
case 'remainingMonths':
|
|
36
|
-
return (s) =>
|
|
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) =>
|
|
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,28 @@
|
|
|
1
1
|
import { createSelector } from '@reduxjs/toolkit';
|
|
2
|
+
import isEqual from 'lodash/isEqual';
|
|
2
3
|
import { DEFAULT_DATE_FORMAT } from '../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
3
|
-
import { toMonthYearPeriodId, } from '../../commonStateTypes/timePeriod';
|
|
4
|
+
import { toMonth, toMonthYearPeriodId, } from '../../commonStateTypes/timePeriod';
|
|
4
5
|
import { getMonthEndCloseChecksByTenantId } from '../../entity/monthEndCloseChecks/monthEndCloseChecksSelector';
|
|
5
6
|
import { defaultMonthYearPeriod } from '../../entity/tenant/epic/fetchAllTenantsEpic';
|
|
6
7
|
import { getCurrentTenant, } from '../../entity/tenant/tenantSelector';
|
|
7
|
-
import { date } from '../../zeniDayJS';
|
|
8
|
+
import { date, dateNow } from '../../zeniDayJS';
|
|
8
9
|
export const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary) => {
|
|
9
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ selectedPeriod:', selectedPeriod);
|
|
10
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ userAllowedToAccessMonthEndInsights:', userAllowedToAccessMonthEndInsights);
|
|
11
10
|
if (auditSummary != null) {
|
|
12
11
|
if (auditSummary.auditScorePercentage < 75 &&
|
|
13
12
|
userAllowedToAccessMonthEndInsights === false) {
|
|
14
13
|
return true;
|
|
15
14
|
}
|
|
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
|
+
}
|
|
16
22
|
// if the selected period is November 2024, then book close date should not be null and book close date should be 30th November 2024
|
|
17
23
|
const { bookCloseDate } = currentTenant;
|
|
18
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ bookCloseDate:', bookCloseDate);
|
|
19
24
|
const selectedPeriodFirstDay = date(`${selectedPeriod.year}-${selectedPeriod.month}-01`);
|
|
20
25
|
const selectedPeriodLastDay = selectedPeriodFirstDay.endOf('month');
|
|
21
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ selectedPeriodLastDay:', selectedPeriodLastDay);
|
|
22
26
|
if (bookCloseDate == null ||
|
|
23
27
|
bookCloseDate.format(DEFAULT_DATE_FORMAT) !==
|
|
24
28
|
selectedPeriodLastDay.format(DEFAULT_DATE_FORMAT)) {
|
|
@@ -52,7 +56,7 @@ export const getMonthEndCloseChecksViewByTenantId = createSelector((state) => st
|
|
|
52
56
|
if (check.id === 'month_end_insights') {
|
|
53
57
|
const isDisabled = monthEndCloseChecks.reportEmailSentDate == null
|
|
54
58
|
? isMonthEndInsightDisabled(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, monthEndCloseChecks.auditSummary)
|
|
55
|
-
:
|
|
59
|
+
: false;
|
|
56
60
|
return {
|
|
57
61
|
...check,
|
|
58
62
|
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
|
-
|
|
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.
|
|
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.
|
|
36
|
+
return (s) => s.jeScheduleType;
|
|
37
37
|
case 'amortizationPeriod':
|
|
38
38
|
return (s) => s.period;
|
|
39
39
|
case 'jePostingDate':
|
|
40
|
-
return (s) => s.
|
|
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) =>
|
|
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) =>
|
|
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,7 +1,11 @@
|
|
|
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
6
|
exports.getMonthEndCloseChecksViewByTenantId = exports.isMonthEndInsightDisabled = void 0;
|
|
4
7
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
8
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
5
9
|
const formatZeniDateFY_1 = require("../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
6
10
|
const timePeriod_1 = require("../../commonStateTypes/timePeriod");
|
|
7
11
|
const monthEndCloseChecksSelector_1 = require("../../entity/monthEndCloseChecks/monthEndCloseChecksSelector");
|
|
@@ -9,19 +13,22 @@ const fetchAllTenantsEpic_1 = require("../../entity/tenant/epic/fetchAllTenantsE
|
|
|
9
13
|
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
10
14
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
11
15
|
const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, auditSummary) => {
|
|
12
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ selectedPeriod:', selectedPeriod);
|
|
13
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ userAllowedToAccessMonthEndInsights:', userAllowedToAccessMonthEndInsights);
|
|
14
16
|
if (auditSummary != null) {
|
|
15
17
|
if (auditSummary.auditScorePercentage < 75 &&
|
|
16
18
|
userAllowedToAccessMonthEndInsights === false) {
|
|
17
19
|
return true;
|
|
18
20
|
}
|
|
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
|
+
}
|
|
19
28
|
// if the selected period is November 2024, then book close date should not be null and book close date should be 30th November 2024
|
|
20
29
|
const { bookCloseDate } = currentTenant;
|
|
21
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ bookCloseDate:', bookCloseDate);
|
|
22
30
|
const selectedPeriodFirstDay = (0, zeniDayJS_1.date)(`${selectedPeriod.year}-${selectedPeriod.month}-01`);
|
|
23
31
|
const selectedPeriodLastDay = selectedPeriodFirstDay.endOf('month');
|
|
24
|
-
console.log('jklogs ~ isMonthEndInsightDisabled ~ selectedPeriodLastDay:', selectedPeriodLastDay);
|
|
25
32
|
if (bookCloseDate == null ||
|
|
26
33
|
bookCloseDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT) !==
|
|
27
34
|
selectedPeriodLastDay.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)) {
|
|
@@ -56,7 +63,7 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
|
|
|
56
63
|
if (check.id === 'month_end_insights') {
|
|
57
64
|
const isDisabled = monthEndCloseChecks.reportEmailSentDate == null
|
|
58
65
|
? (0, exports.isMonthEndInsightDisabled)(currentTenant, selectedPeriod, userAllowedToAccessMonthEndInsights, monthEndCloseChecks.auditSummary)
|
|
59
|
-
:
|
|
66
|
+
: false;
|
|
60
67
|
return {
|
|
61
68
|
...check,
|
|
62
69
|
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
|
-
|
|
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.16-
|
|
3
|
+
"version": "5.0.16-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",
|