@zeniai/client-epic-state 5.2.22-betaAM1 → 5.2.22-betaAM2
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.
|
@@ -17,28 +17,28 @@ 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;
|
|
20
|
+
export function getClearedMatchedAmount(accrual) {
|
|
21
|
+
return accrual.cleared?.matchedAmount?.amount;
|
|
28
22
|
}
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
23
|
+
function getActualMatchingGroupKey(accrual) {
|
|
24
|
+
const ids = accrual.cleared?.accrualIds;
|
|
25
|
+
if (ids != null && ids.length > 1) {
|
|
26
|
+
return `cleared:${[...ids].sort().join(',')}`;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
return accrual.accrualId;
|
|
29
|
+
}
|
|
30
|
+
function sumUniqueActualMatchingAmounts(accruals) {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
let sum = 0;
|
|
33
|
+
for (const accrual of accruals) {
|
|
34
|
+
const key = getActualMatchingGroupKey(accrual);
|
|
35
|
+
if (seen.has(key)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
seen.add(key);
|
|
39
|
+
sum += getActualMatchingAmount(accrual);
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return sum;
|
|
42
42
|
}
|
|
43
43
|
export function getActualMatchingAmount(accrual) {
|
|
44
44
|
if (isPendingReviewAccrual(accrual)) {
|
|
@@ -46,7 +46,7 @@ export function getActualMatchingAmount(accrual) {
|
|
|
46
46
|
accrual.estimatedAmount.amount);
|
|
47
47
|
}
|
|
48
48
|
if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
|
|
49
|
-
return (
|
|
49
|
+
return getClearedMatchedAmount(accrual) ?? accrual.estimatedAmount.amount;
|
|
50
50
|
}
|
|
51
51
|
return accrual.estimatedAmount.amount;
|
|
52
52
|
}
|
|
@@ -137,19 +137,15 @@ export function getExpenseAutomationActualMatchingView(state) {
|
|
|
137
137
|
: {
|
|
138
138
|
autoReversed: {
|
|
139
139
|
count: listedAccruals.filter(isAutoReversedAccrual).length,
|
|
140
|
-
amount: listedAccruals
|
|
141
|
-
.filter(isAutoReversedAccrual)
|
|
142
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
140
|
+
amount: sumUniqueActualMatchingAmounts(listedAccruals.filter(isAutoReversedAccrual)),
|
|
143
141
|
},
|
|
144
142
|
pendingReview: {
|
|
145
143
|
count: listedAccruals.filter(isPendingReviewAccrual).length,
|
|
146
|
-
amount: listedAccruals
|
|
147
|
-
.filter(isPendingReviewAccrual)
|
|
148
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
144
|
+
amount: sumUniqueActualMatchingAmounts(listedAccruals.filter(isPendingReviewAccrual)),
|
|
149
145
|
},
|
|
150
146
|
totalThisClose: {
|
|
151
147
|
count: listedAccruals.length,
|
|
152
|
-
amount: listedAccruals
|
|
148
|
+
amount: sumUniqueActualMatchingAmounts(listedAccruals),
|
|
153
149
|
},
|
|
154
150
|
ai: {
|
|
155
151
|
count: listedAccruals.filter((accrual) => accrual.origin === 'agent').length,
|
|
@@ -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,28 @@ 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;
|
|
32
|
+
function getClearedMatchedAmount(accrual) {
|
|
33
|
+
return accrual.cleared?.matchedAmount?.amount;
|
|
40
34
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
35
|
+
function getActualMatchingGroupKey(accrual) {
|
|
36
|
+
const ids = accrual.cleared?.accrualIds;
|
|
37
|
+
if (ids != null && ids.length > 1) {
|
|
38
|
+
return `cleared:${[...ids].sort().join(',')}`;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
return accrual.accrualId;
|
|
41
|
+
}
|
|
42
|
+
function sumUniqueActualMatchingAmounts(accruals) {
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
let sum = 0;
|
|
45
|
+
for (const accrual of accruals) {
|
|
46
|
+
const key = getActualMatchingGroupKey(accrual);
|
|
47
|
+
if (seen.has(key)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
seen.add(key);
|
|
51
|
+
sum += getActualMatchingAmount(accrual);
|
|
52
52
|
}
|
|
53
|
-
return
|
|
53
|
+
return sum;
|
|
54
54
|
}
|
|
55
55
|
function getActualMatchingAmount(accrual) {
|
|
56
56
|
if (isPendingReviewAccrual(accrual)) {
|
|
@@ -58,7 +58,7 @@ function getActualMatchingAmount(accrual) {
|
|
|
58
58
|
accrual.estimatedAmount.amount);
|
|
59
59
|
}
|
|
60
60
|
if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
|
|
61
|
-
return (
|
|
61
|
+
return getClearedMatchedAmount(accrual) ?? accrual.estimatedAmount.amount;
|
|
62
62
|
}
|
|
63
63
|
return accrual.estimatedAmount.amount;
|
|
64
64
|
}
|
|
@@ -149,19 +149,15 @@ function getExpenseAutomationActualMatchingView(state) {
|
|
|
149
149
|
: {
|
|
150
150
|
autoReversed: {
|
|
151
151
|
count: listedAccruals.filter(isAutoReversedAccrual).length,
|
|
152
|
-
amount: listedAccruals
|
|
153
|
-
.filter(isAutoReversedAccrual)
|
|
154
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
152
|
+
amount: sumUniqueActualMatchingAmounts(listedAccruals.filter(isAutoReversedAccrual)),
|
|
155
153
|
},
|
|
156
154
|
pendingReview: {
|
|
157
155
|
count: listedAccruals.filter(isPendingReviewAccrual).length,
|
|
158
|
-
amount: listedAccruals
|
|
159
|
-
.filter(isPendingReviewAccrual)
|
|
160
|
-
.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
|
|
156
|
+
amount: sumUniqueActualMatchingAmounts(listedAccruals.filter(isPendingReviewAccrual)),
|
|
161
157
|
},
|
|
162
158
|
totalThisClose: {
|
|
163
159
|
count: listedAccruals.length,
|
|
164
|
-
amount: listedAccruals
|
|
160
|
+
amount: sumUniqueActualMatchingAmounts(listedAccruals),
|
|
165
161
|
},
|
|
166
162
|
ai: {
|
|
167
163
|
count: listedAccruals.filter((accrual) => accrual.origin === 'agent').length,
|
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-betaAM2",
|
|
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",
|