@zeniai/client-epic-state 5.2.22-betaAM1 → 5.2.22-betaAM3
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/jeSchedules/jeSchedulesPayload.d.ts +2 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +6 -0
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +2 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +6 -0
- package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +77 -55
- package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +2 -1
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +78 -56
- package/package.json +1 -1
|
@@ -135,6 +135,7 @@ export interface JEOneTimeAccrualClearedPayload {
|
|
|
135
135
|
match_tier?: string | null;
|
|
136
136
|
matched_amount?: number | null;
|
|
137
137
|
matched_line_id?: string | null;
|
|
138
|
+
matched_transaction_date?: string | null;
|
|
138
139
|
matched_transaction_id?: string | null;
|
|
139
140
|
matched_transaction_integration_id?: string | null;
|
|
140
141
|
matched_transaction_type?: string | null;
|
|
@@ -144,6 +145,7 @@ export interface JEOneTimeAccrualMatchSuggestionPayload {
|
|
|
144
145
|
match_tier?: string | null;
|
|
145
146
|
matched_amount?: number | null;
|
|
146
147
|
matched_line_id?: string | null;
|
|
148
|
+
matched_transaction_date?: string | null;
|
|
147
149
|
matched_transaction_id?: string | null;
|
|
148
150
|
matched_transaction_integration_id?: string | null;
|
|
149
151
|
matched_transaction_type?: string | null;
|
|
@@ -473,6 +473,9 @@ function toJEOneTimeAccrualCleared(payload, currencyCode) {
|
|
|
473
473
|
: undefined,
|
|
474
474
|
accrualIds: payload.accrual_ids ?? undefined,
|
|
475
475
|
reversedAt: payload.reversed_at != null ? (0, zeniDayJS_1.date)(payload.reversed_at) : undefined,
|
|
476
|
+
matchedTransactionDate: payload.matched_transaction_date != null
|
|
477
|
+
? (0, zeniDayJS_1.date)(payload.matched_transaction_date)
|
|
478
|
+
: undefined,
|
|
476
479
|
matchTier: payload.match_tier ?? undefined,
|
|
477
480
|
matchShape: payload.match_shape ?? undefined,
|
|
478
481
|
};
|
|
@@ -491,6 +494,9 @@ function toJEOneTimeAccrualMatchSuggestion(payload, currencyCode) {
|
|
|
491
494
|
matchedAmount: payload.matched_amount != null
|
|
492
495
|
? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
|
|
493
496
|
: undefined,
|
|
497
|
+
matchedTransactionDate: payload.matched_transaction_date != null
|
|
498
|
+
? (0, zeniDayJS_1.date)(payload.matched_transaction_date)
|
|
499
|
+
: undefined,
|
|
494
500
|
};
|
|
495
501
|
}
|
|
496
502
|
function toJEOneTimeAccrual(payload) {
|
|
@@ -204,6 +204,7 @@ export interface JEOneTimeAccrualCleared {
|
|
|
204
204
|
groupSum?: Amount;
|
|
205
205
|
matchedAmount?: Amount;
|
|
206
206
|
matchedLineId?: string;
|
|
207
|
+
matchedTransactionDate?: ZeniDate;
|
|
207
208
|
matchedTransactionId?: string;
|
|
208
209
|
matchedTransactionIntegrationId?: string;
|
|
209
210
|
matchedTransactionType?: string;
|
|
@@ -215,6 +216,7 @@ export interface JEOneTimeAccrualCleared {
|
|
|
215
216
|
export interface JEOneTimeAccrualMatchSuggestion {
|
|
216
217
|
matchedAmount?: Amount;
|
|
217
218
|
matchedLineId?: string;
|
|
219
|
+
matchedTransactionDate?: ZeniDate;
|
|
218
220
|
matchedTransactionId?: string;
|
|
219
221
|
matchedTransactionIntegrationId?: string;
|
|
220
222
|
matchedTransactionType?: string;
|
|
@@ -462,6 +462,9 @@ function toJEOneTimeAccrualCleared(payload, currencyCode) {
|
|
|
462
462
|
: undefined,
|
|
463
463
|
accrualIds: payload.accrual_ids ?? undefined,
|
|
464
464
|
reversedAt: payload.reversed_at != null ? date(payload.reversed_at) : undefined,
|
|
465
|
+
matchedTransactionDate: payload.matched_transaction_date != null
|
|
466
|
+
? date(payload.matched_transaction_date)
|
|
467
|
+
: undefined,
|
|
465
468
|
matchTier: payload.match_tier ?? undefined,
|
|
466
469
|
matchShape: payload.match_shape ?? undefined,
|
|
467
470
|
};
|
|
@@ -480,6 +483,9 @@ function toJEOneTimeAccrualMatchSuggestion(payload, currencyCode) {
|
|
|
480
483
|
matchedAmount: payload.matched_amount != null
|
|
481
484
|
? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
|
|
482
485
|
: undefined,
|
|
486
|
+
matchedTransactionDate: payload.matched_transaction_date != null
|
|
487
|
+
? date(payload.matched_transaction_date)
|
|
488
|
+
: undefined,
|
|
483
489
|
};
|
|
484
490
|
}
|
|
485
491
|
export function toJEOneTimeAccrual(payload) {
|
|
@@ -17,28 +17,8 @@ export function isPendingReviewAccrual(accrual) {
|
|
|
17
17
|
const resolution = accrual.matchSuggestion.resolution;
|
|
18
18
|
return resolution == null || resolution.length === 0;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
if (groupSum == null || groupSum <= 0) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const matchShape = accrual.cleared?.matchShape;
|
|
26
|
-
const accrualIdsLength = accrual.cleared?.accrualIds?.length ?? 0;
|
|
27
|
-
return matchShape === '1:N' || matchShape === 'N:1' || accrualIdsLength > 1;
|
|
28
|
-
}
|
|
29
|
-
export function getClearedAllocatedActualAmount(accrual) {
|
|
30
|
-
const matchedAmount = accrual.cleared?.matchedAmount?.amount;
|
|
31
|
-
if (matchedAmount == null) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
if (!isGroupedClearedMatch(accrual)) {
|
|
35
|
-
return matchedAmount;
|
|
36
|
-
}
|
|
37
|
-
const groupSum = accrual.cleared?.groupSum?.amount;
|
|
38
|
-
if (groupSum == null || groupSum <= 0) {
|
|
39
|
-
return matchedAmount;
|
|
40
|
-
}
|
|
41
|
-
return matchedAmount * (accrual.estimatedAmount.amount / groupSum);
|
|
20
|
+
export function getClearedMatchedAmount(accrual) {
|
|
21
|
+
return accrual.cleared?.matchedAmount?.amount;
|
|
42
22
|
}
|
|
43
23
|
export function getActualMatchingAmount(accrual) {
|
|
44
24
|
if (isPendingReviewAccrual(accrual)) {
|
|
@@ -46,25 +26,79 @@ export function getActualMatchingAmount(accrual) {
|
|
|
46
26
|
accrual.estimatedAmount.amount);
|
|
47
27
|
}
|
|
48
28
|
if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
|
|
49
|
-
return (
|
|
29
|
+
return getClearedMatchedAmount(accrual) ?? accrual.estimatedAmount.amount;
|
|
50
30
|
}
|
|
51
31
|
return accrual.estimatedAmount.amount;
|
|
52
32
|
}
|
|
53
33
|
export function getActualMatchingReversalDate(accrual) {
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
34
|
+
if (isPendingReviewAccrual(accrual)) {
|
|
35
|
+
return accrual.matchSuggestion?.matchedTransactionDate;
|
|
56
36
|
}
|
|
57
|
-
return accrual.
|
|
37
|
+
return accrual.cleared?.matchedTransactionDate;
|
|
58
38
|
}
|
|
59
|
-
function
|
|
39
|
+
function getActualMatchingBillCollapseKey(accrual) {
|
|
40
|
+
const stamp = isPendingReviewAccrual(accrual)
|
|
41
|
+
? accrual.matchSuggestion
|
|
42
|
+
: accrual.cleared;
|
|
43
|
+
const txnId = stamp?.matchedTransactionId;
|
|
44
|
+
if (txnId != null && txnId !== '') {
|
|
45
|
+
return `txn:${txnId}`;
|
|
46
|
+
}
|
|
47
|
+
const integrationId = stamp?.matchedTransactionIntegrationId;
|
|
48
|
+
if (integrationId != null && integrationId !== '') {
|
|
49
|
+
return `int:${integrationId}`;
|
|
50
|
+
}
|
|
51
|
+
const ids = accrual.cleared?.accrualIds;
|
|
52
|
+
if (ids != null && ids.length > 1) {
|
|
53
|
+
return `cleared:${[...ids].sort().join(',')}`;
|
|
54
|
+
}
|
|
55
|
+
return `accrual:${accrual.accrualId}`;
|
|
56
|
+
}
|
|
57
|
+
function collectGroupedAccrualIds(members) {
|
|
58
|
+
const stampIds = members[0]?.cleared?.accrualIds;
|
|
59
|
+
const memberIds = members.map((member) => member.accrualId);
|
|
60
|
+
if (stampIds != null && stampIds.length >= memberIds.length) {
|
|
61
|
+
return stampIds;
|
|
62
|
+
}
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
const grouped = [];
|
|
65
|
+
for (const id of [...(stampIds ?? []), ...memberIds]) {
|
|
66
|
+
if (!seen.has(id)) {
|
|
67
|
+
seen.add(id);
|
|
68
|
+
grouped.push(id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return grouped;
|
|
72
|
+
}
|
|
73
|
+
function toActualMatchingRow(accrual, kind, groupedAccrualIds) {
|
|
60
74
|
return {
|
|
61
75
|
...accrual,
|
|
62
76
|
kind,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
: getActualMatchingReversalDate(accrual),
|
|
77
|
+
groupedAccrualIds,
|
|
78
|
+
reversalDate: getActualMatchingReversalDate(accrual),
|
|
66
79
|
};
|
|
67
80
|
}
|
|
81
|
+
function collapseActualMatchingRows(accruals, kind) {
|
|
82
|
+
const groups = new Map();
|
|
83
|
+
for (const accrual of accruals) {
|
|
84
|
+
const key = getActualMatchingBillCollapseKey(accrual);
|
|
85
|
+
const members = groups.get(key);
|
|
86
|
+
if (members != null) {
|
|
87
|
+
members.push(accrual);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
groups.set(key, [accrual]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const rows = [];
|
|
94
|
+
for (const members of groups.values()) {
|
|
95
|
+
rows.push(toActualMatchingRow(members[0], kind, collectGroupedAccrualIds(members)));
|
|
96
|
+
}
|
|
97
|
+
return rows;
|
|
98
|
+
}
|
|
99
|
+
function sumCollapsedActualMatchingAmounts(rows) {
|
|
100
|
+
return rows.reduce((sum, row) => sum + getActualMatchingAmount(row), 0);
|
|
101
|
+
}
|
|
68
102
|
function matchesSearch(accrual, searchString) {
|
|
69
103
|
const trimmed = searchString.trim().toLowerCase();
|
|
70
104
|
if (trimmed.length === 0) {
|
|
@@ -120,42 +154,30 @@ export function getExpenseAutomationActualMatchingView(state) {
|
|
|
120
154
|
.map((key) => getJEOneTimeAccrualByKey(key, state.jeSchedulesState))
|
|
121
155
|
.filter((accrual) => accrual != null);
|
|
122
156
|
const filtered = accruals.filter((accrual) => matchesSearch(accrual, uiState.searchString));
|
|
123
|
-
const autoReversed = sortActualMatchingRows(filtered
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
.map((accrual) => toActualMatchingRow(accrual, 'pending_review')), uiState);
|
|
129
|
-
const manuallyReversed = sortActualMatchingRows(filtered
|
|
130
|
-
.filter(isManuallyReversedAccrual)
|
|
131
|
-
.map((accrual) => toActualMatchingRow(accrual, 'manually_reversed')), uiState);
|
|
132
|
-
const listedAccruals = accruals.filter((accrual) => isAutoReversedAccrual(accrual) ||
|
|
133
|
-
isPendingReviewAccrual(accrual) ||
|
|
134
|
-
isManuallyReversedAccrual(accrual));
|
|
135
|
-
const kpiSummary = listedAccruals.length === 0
|
|
157
|
+
const autoReversed = sortActualMatchingRows(collapseActualMatchingRows(filtered.filter(isAutoReversedAccrual), 'auto_reversed'), uiState);
|
|
158
|
+
const pendingReview = sortActualMatchingRows(collapseActualMatchingRows(filtered.filter(isPendingReviewAccrual), 'pending_review'), uiState);
|
|
159
|
+
const manuallyReversed = sortActualMatchingRows(collapseActualMatchingRows(filtered.filter(isManuallyReversedAccrual), 'manually_reversed'), uiState);
|
|
160
|
+
const listedRows = [...autoReversed, ...pendingReview, ...manuallyReversed];
|
|
161
|
+
const kpiSummary = listedRows.length === 0
|
|
136
162
|
? emptyKpiSummary()
|
|
137
163
|
: {
|
|
138
164
|
autoReversed: {
|
|
139
|
-
count:
|
|
140
|
-
amount:
|
|
141
|
-
.filter(isAutoReversedAccrual)
|
|
142
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
165
|
+
count: autoReversed.length,
|
|
166
|
+
amount: sumCollapsedActualMatchingAmounts(autoReversed),
|
|
143
167
|
},
|
|
144
168
|
pendingReview: {
|
|
145
|
-
count:
|
|
146
|
-
amount:
|
|
147
|
-
.filter(isPendingReviewAccrual)
|
|
148
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
169
|
+
count: pendingReview.length,
|
|
170
|
+
amount: sumCollapsedActualMatchingAmounts(pendingReview),
|
|
149
171
|
},
|
|
150
172
|
totalThisClose: {
|
|
151
|
-
count:
|
|
152
|
-
amount:
|
|
173
|
+
count: listedRows.length,
|
|
174
|
+
amount: sumCollapsedActualMatchingAmounts(listedRows),
|
|
153
175
|
},
|
|
154
176
|
ai: {
|
|
155
|
-
count:
|
|
177
|
+
count: listedRows.filter((row) => row.origin === 'agent').length,
|
|
156
178
|
},
|
|
157
179
|
manual: {
|
|
158
|
-
count:
|
|
180
|
+
count: listedRows.filter((row) => row.origin === 'human').length,
|
|
159
181
|
},
|
|
160
182
|
};
|
|
161
183
|
const accrualSearchResults = matchModal.accrualSearch.results
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
1
|
+
import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
3
3
|
import { JEOneTimeAccrual } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
4
4
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
@@ -6,6 +6,7 @@ import { ActualMatchingTransactionSearchResult, ActualMatchingViewUIState, Match
|
|
|
6
6
|
export type ActualMatchingRowKind = 'auto_reversed' | 'pending_review' | 'manually_reversed';
|
|
7
7
|
export interface ActualMatchingRow extends JEOneTimeAccrual {
|
|
8
8
|
kind: ActualMatchingRowKind;
|
|
9
|
+
groupedAccrualIds?: ID[];
|
|
9
10
|
reversalDate?: ZeniDate;
|
|
10
11
|
}
|
|
11
12
|
export interface ActualMatchingKpiSummary {
|
|
@@ -5,7 +5,7 @@ import { ExpenseAutomationActualMatchingViewSelector } from '../selectorTypes/ac
|
|
|
5
5
|
export declare function isAutoReversedAccrual(accrual: JEOneTimeAccrual): boolean;
|
|
6
6
|
export declare function isManuallyReversedAccrual(accrual: JEOneTimeAccrual): boolean;
|
|
7
7
|
export declare function isPendingReviewAccrual(accrual: JEOneTimeAccrual): boolean;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function getClearedMatchedAmount(accrual: JEOneTimeAccrual): number | undefined;
|
|
9
9
|
export declare function getActualMatchingAmount(accrual: JEOneTimeAccrual): number;
|
|
10
10
|
export declare function getActualMatchingReversalDate(accrual: JEOneTimeAccrual): ZeniDate | undefined;
|
|
11
11
|
export declare function getExpenseAutomationActualMatchingView(state: RootState): ExpenseAutomationActualMatchingViewSelector;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.isAutoReversedAccrual = isAutoReversedAccrual;
|
|
7
7
|
exports.isManuallyReversedAccrual = isManuallyReversedAccrual;
|
|
8
8
|
exports.isPendingReviewAccrual = isPendingReviewAccrual;
|
|
9
|
-
exports.
|
|
9
|
+
exports.getClearedMatchedAmount = getClearedMatchedAmount;
|
|
10
10
|
exports.getActualMatchingAmount = getActualMatchingAmount;
|
|
11
11
|
exports.getActualMatchingReversalDate = getActualMatchingReversalDate;
|
|
12
12
|
exports.getExpenseAutomationActualMatchingView = getExpenseAutomationActualMatchingView;
|
|
@@ -29,28 +29,8 @@ function isPendingReviewAccrual(accrual) {
|
|
|
29
29
|
const resolution = accrual.matchSuggestion.resolution;
|
|
30
30
|
return resolution == null || resolution.length === 0;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
if (groupSum == null || groupSum <= 0) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
const matchShape = accrual.cleared?.matchShape;
|
|
38
|
-
const accrualIdsLength = accrual.cleared?.accrualIds?.length ?? 0;
|
|
39
|
-
return matchShape === '1:N' || matchShape === 'N:1' || accrualIdsLength > 1;
|
|
40
|
-
}
|
|
41
|
-
function getClearedAllocatedActualAmount(accrual) {
|
|
42
|
-
const matchedAmount = accrual.cleared?.matchedAmount?.amount;
|
|
43
|
-
if (matchedAmount == null) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
if (!isGroupedClearedMatch(accrual)) {
|
|
47
|
-
return matchedAmount;
|
|
48
|
-
}
|
|
49
|
-
const groupSum = accrual.cleared?.groupSum?.amount;
|
|
50
|
-
if (groupSum == null || groupSum <= 0) {
|
|
51
|
-
return matchedAmount;
|
|
52
|
-
}
|
|
53
|
-
return matchedAmount * (accrual.estimatedAmount.amount / groupSum);
|
|
32
|
+
function getClearedMatchedAmount(accrual) {
|
|
33
|
+
return accrual.cleared?.matchedAmount?.amount;
|
|
54
34
|
}
|
|
55
35
|
function getActualMatchingAmount(accrual) {
|
|
56
36
|
if (isPendingReviewAccrual(accrual)) {
|
|
@@ -58,25 +38,79 @@ function getActualMatchingAmount(accrual) {
|
|
|
58
38
|
accrual.estimatedAmount.amount);
|
|
59
39
|
}
|
|
60
40
|
if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
|
|
61
|
-
return (
|
|
41
|
+
return getClearedMatchedAmount(accrual) ?? accrual.estimatedAmount.amount;
|
|
62
42
|
}
|
|
63
43
|
return accrual.estimatedAmount.amount;
|
|
64
44
|
}
|
|
65
45
|
function getActualMatchingReversalDate(accrual) {
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
46
|
+
if (isPendingReviewAccrual(accrual)) {
|
|
47
|
+
return accrual.matchSuggestion?.matchedTransactionDate;
|
|
68
48
|
}
|
|
69
|
-
return accrual.
|
|
49
|
+
return accrual.cleared?.matchedTransactionDate;
|
|
70
50
|
}
|
|
71
|
-
function
|
|
51
|
+
function getActualMatchingBillCollapseKey(accrual) {
|
|
52
|
+
const stamp = isPendingReviewAccrual(accrual)
|
|
53
|
+
? accrual.matchSuggestion
|
|
54
|
+
: accrual.cleared;
|
|
55
|
+
const txnId = stamp?.matchedTransactionId;
|
|
56
|
+
if (txnId != null && txnId !== '') {
|
|
57
|
+
return `txn:${txnId}`;
|
|
58
|
+
}
|
|
59
|
+
const integrationId = stamp?.matchedTransactionIntegrationId;
|
|
60
|
+
if (integrationId != null && integrationId !== '') {
|
|
61
|
+
return `int:${integrationId}`;
|
|
62
|
+
}
|
|
63
|
+
const ids = accrual.cleared?.accrualIds;
|
|
64
|
+
if (ids != null && ids.length > 1) {
|
|
65
|
+
return `cleared:${[...ids].sort().join(',')}`;
|
|
66
|
+
}
|
|
67
|
+
return `accrual:${accrual.accrualId}`;
|
|
68
|
+
}
|
|
69
|
+
function collectGroupedAccrualIds(members) {
|
|
70
|
+
const stampIds = members[0]?.cleared?.accrualIds;
|
|
71
|
+
const memberIds = members.map((member) => member.accrualId);
|
|
72
|
+
if (stampIds != null && stampIds.length >= memberIds.length) {
|
|
73
|
+
return stampIds;
|
|
74
|
+
}
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
const grouped = [];
|
|
77
|
+
for (const id of [...(stampIds ?? []), ...memberIds]) {
|
|
78
|
+
if (!seen.has(id)) {
|
|
79
|
+
seen.add(id);
|
|
80
|
+
grouped.push(id);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return grouped;
|
|
84
|
+
}
|
|
85
|
+
function toActualMatchingRow(accrual, kind, groupedAccrualIds) {
|
|
72
86
|
return {
|
|
73
87
|
...accrual,
|
|
74
88
|
kind,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
: getActualMatchingReversalDate(accrual),
|
|
89
|
+
groupedAccrualIds,
|
|
90
|
+
reversalDate: getActualMatchingReversalDate(accrual),
|
|
78
91
|
};
|
|
79
92
|
}
|
|
93
|
+
function collapseActualMatchingRows(accruals, kind) {
|
|
94
|
+
const groups = new Map();
|
|
95
|
+
for (const accrual of accruals) {
|
|
96
|
+
const key = getActualMatchingBillCollapseKey(accrual);
|
|
97
|
+
const members = groups.get(key);
|
|
98
|
+
if (members != null) {
|
|
99
|
+
members.push(accrual);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
groups.set(key, [accrual]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const rows = [];
|
|
106
|
+
for (const members of groups.values()) {
|
|
107
|
+
rows.push(toActualMatchingRow(members[0], kind, collectGroupedAccrualIds(members)));
|
|
108
|
+
}
|
|
109
|
+
return rows;
|
|
110
|
+
}
|
|
111
|
+
function sumCollapsedActualMatchingAmounts(rows) {
|
|
112
|
+
return rows.reduce((sum, row) => sum + getActualMatchingAmount(row), 0);
|
|
113
|
+
}
|
|
80
114
|
function matchesSearch(accrual, searchString) {
|
|
81
115
|
const trimmed = searchString.trim().toLowerCase();
|
|
82
116
|
if (trimmed.length === 0) {
|
|
@@ -132,42 +166,30 @@ function getExpenseAutomationActualMatchingView(state) {
|
|
|
132
166
|
.map((key) => (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(key, state.jeSchedulesState))
|
|
133
167
|
.filter((accrual) => accrual != null);
|
|
134
168
|
const filtered = accruals.filter((accrual) => matchesSearch(accrual, uiState.searchString));
|
|
135
|
-
const autoReversed = sortActualMatchingRows(filtered
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
.map((accrual) => toActualMatchingRow(accrual, 'pending_review')), uiState);
|
|
141
|
-
const manuallyReversed = sortActualMatchingRows(filtered
|
|
142
|
-
.filter(isManuallyReversedAccrual)
|
|
143
|
-
.map((accrual) => toActualMatchingRow(accrual, 'manually_reversed')), uiState);
|
|
144
|
-
const listedAccruals = accruals.filter((accrual) => isAutoReversedAccrual(accrual) ||
|
|
145
|
-
isPendingReviewAccrual(accrual) ||
|
|
146
|
-
isManuallyReversedAccrual(accrual));
|
|
147
|
-
const kpiSummary = listedAccruals.length === 0
|
|
169
|
+
const autoReversed = sortActualMatchingRows(collapseActualMatchingRows(filtered.filter(isAutoReversedAccrual), 'auto_reversed'), uiState);
|
|
170
|
+
const pendingReview = sortActualMatchingRows(collapseActualMatchingRows(filtered.filter(isPendingReviewAccrual), 'pending_review'), uiState);
|
|
171
|
+
const manuallyReversed = sortActualMatchingRows(collapseActualMatchingRows(filtered.filter(isManuallyReversedAccrual), 'manually_reversed'), uiState);
|
|
172
|
+
const listedRows = [...autoReversed, ...pendingReview, ...manuallyReversed];
|
|
173
|
+
const kpiSummary = listedRows.length === 0
|
|
148
174
|
? emptyKpiSummary()
|
|
149
175
|
: {
|
|
150
176
|
autoReversed: {
|
|
151
|
-
count:
|
|
152
|
-
amount:
|
|
153
|
-
.filter(isAutoReversedAccrual)
|
|
154
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
177
|
+
count: autoReversed.length,
|
|
178
|
+
amount: sumCollapsedActualMatchingAmounts(autoReversed),
|
|
155
179
|
},
|
|
156
180
|
pendingReview: {
|
|
157
|
-
count:
|
|
158
|
-
amount:
|
|
159
|
-
.filter(isPendingReviewAccrual)
|
|
160
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
181
|
+
count: pendingReview.length,
|
|
182
|
+
amount: sumCollapsedActualMatchingAmounts(pendingReview),
|
|
161
183
|
},
|
|
162
184
|
totalThisClose: {
|
|
163
|
-
count:
|
|
164
|
-
amount:
|
|
185
|
+
count: listedRows.length,
|
|
186
|
+
amount: sumCollapsedActualMatchingAmounts(listedRows),
|
|
165
187
|
},
|
|
166
188
|
ai: {
|
|
167
|
-
count:
|
|
189
|
+
count: listedRows.filter((row) => row.origin === 'agent').length,
|
|
168
190
|
},
|
|
169
191
|
manual: {
|
|
170
|
-
count:
|
|
192
|
+
count: listedRows.filter((row) => row.origin === 'human').length,
|
|
171
193
|
},
|
|
172
194
|
};
|
|
173
195
|
const accrualSearchResults = matchModal.accrualSearch.results
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.22-
|
|
3
|
+
"version": "5.2.22-betaAM3",
|
|
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",
|