@zeniai/client-epic-state 5.2.11-betaAM6 → 5.2.11-betaAM7

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.
@@ -128,7 +128,9 @@ export interface JEOneTimeAccrualAiSuggestionPayload {
128
128
  memo?: string | null;
129
129
  }
130
130
  export interface JEOneTimeAccrualClearedPayload {
131
+ accrual_ids?: string[] | null;
131
132
  consumed_line_ids?: string[] | null;
133
+ group_sum?: number | null;
132
134
  match_shape?: string | null;
133
135
  match_tier?: string | null;
134
136
  matched_amount?: number | null;
@@ -465,6 +465,10 @@ function toJEOneTimeAccrualCleared(payload, currencyCode) {
465
465
  matchedAmount: payload.matched_amount != null
466
466
  ? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
467
467
  : undefined,
468
+ groupSum: payload.group_sum != null
469
+ ? toOneTimeAccrualAmount(payload.group_sum, currencyCode)
470
+ : undefined,
471
+ accrualIds: payload.accrual_ids ?? undefined,
468
472
  reversedAt: payload.reversed_at != null ? (0, zeniDayJS_1.date)(payload.reversed_at) : undefined,
469
473
  matchTier: payload.match_tier ?? undefined,
470
474
  matchShape: payload.match_shape ?? undefined,
@@ -199,7 +199,9 @@ export interface JEOneTimeAccrualAiSuggestion {
199
199
  }
200
200
  /** Cleared-bill stamp written when an accrual is matched and reversed. */
201
201
  export interface JEOneTimeAccrualCleared {
202
+ accrualIds?: ID[];
202
203
  consumedLineIds?: string[];
204
+ groupSum?: Amount;
203
205
  matchedAmount?: Amount;
204
206
  matchedLineId?: string;
205
207
  matchedTransactionId?: string;
@@ -454,6 +454,10 @@ function toJEOneTimeAccrualCleared(payload, currencyCode) {
454
454
  matchedAmount: payload.matched_amount != null
455
455
  ? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
456
456
  : undefined,
457
+ groupSum: payload.group_sum != null
458
+ ? toOneTimeAccrualAmount(payload.group_sum, currencyCode)
459
+ : undefined,
460
+ accrualIds: payload.accrual_ids ?? undefined,
457
461
  reversedAt: payload.reversed_at != null ? date(payload.reversed_at) : undefined,
458
462
  matchTier: payload.match_tier ?? undefined,
459
463
  matchShape: payload.match_shape ?? undefined,
@@ -17,10 +17,38 @@ export function isPendingReviewAccrual(accrual) {
17
17
  const resolution = accrual.matchSuggestion.resolution;
18
18
  return resolution == null || resolution.length === 0;
19
19
  }
20
+ function isGroupedClearedMatch(accrual) {
21
+ const groupSum = accrual.cleared?.groupSum?.amount;
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);
42
+ }
20
43
  export function getActualMatchingAmount(accrual) {
21
- return (accrual.cleared?.matchedAmount?.amount ??
22
- accrual.matchSuggestion?.matchedAmount?.amount ??
23
- accrual.estimatedAmount.amount);
44
+ if (isPendingReviewAccrual(accrual)) {
45
+ return (accrual.matchSuggestion?.matchedAmount?.amount ??
46
+ accrual.estimatedAmount.amount);
47
+ }
48
+ if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
49
+ return (getClearedAllocatedActualAmount(accrual) ?? accrual.estimatedAmount.amount);
50
+ }
51
+ return accrual.estimatedAmount.amount;
24
52
  }
25
53
  export function getActualMatchingReversalDate(accrual) {
26
54
  if (!isAutoReversedAccrual(accrual) && !isManuallyReversedAccrual(accrual)) {
@@ -124,12 +152,10 @@ export function getExpenseAutomationActualMatchingView(state) {
124
152
  amount: listedAccruals.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
125
153
  },
126
154
  ai: {
127
- count: listedAccruals.filter((accrual) => accrual.origin === 'agent')
128
- .length,
155
+ count: listedAccruals.filter((accrual) => accrual.origin === 'agent').length,
129
156
  },
130
157
  manual: {
131
- count: listedAccruals.filter((accrual) => accrual.origin === 'human')
132
- .length,
158
+ count: listedAccruals.filter((accrual) => accrual.origin === 'human').length,
133
159
  },
134
160
  };
135
161
  const accrualSearchResults = matchModal.accrualSearch.results
@@ -9,7 +9,7 @@ const ACTUAL_MATCHING_SORT_KEYS = [
9
9
  'lifecycle',
10
10
  ];
11
11
  export const toActualMatchingSortKey = (v) => stringToUnion(v, ACTUAL_MATCHING_SORT_KEYS);
12
- export const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 10;
12
+ export const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
13
13
  export const MATCH_ACCRUAL_SEARCH_LIMIT = 50;
14
14
  export const MATCH_SEARCH_DEBOUNCE_MS = 300;
15
15
  const MATCH_AND_REVERSE_RESULT_STATUSES = [
@@ -5,6 +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 getClearedAllocatedActualAmount(accrual: JEOneTimeAccrual): number | undefined;
8
9
  export declare function getActualMatchingAmount(accrual: JEOneTimeAccrual): number;
9
10
  export declare function getActualMatchingReversalDate(accrual: JEOneTimeAccrual): ZeniDate | undefined;
10
11
  export declare function getExpenseAutomationActualMatchingView(state: RootState): ExpenseAutomationActualMatchingViewSelector;
@@ -6,6 +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.getClearedAllocatedActualAmount = getClearedAllocatedActualAmount;
9
10
  exports.getActualMatchingAmount = getActualMatchingAmount;
10
11
  exports.getActualMatchingReversalDate = getActualMatchingReversalDate;
11
12
  exports.getExpenseAutomationActualMatchingView = getExpenseAutomationActualMatchingView;
@@ -28,10 +29,38 @@ function isPendingReviewAccrual(accrual) {
28
29
  const resolution = accrual.matchSuggestion.resolution;
29
30
  return resolution == null || resolution.length === 0;
30
31
  }
32
+ function isGroupedClearedMatch(accrual) {
33
+ const groupSum = accrual.cleared?.groupSum?.amount;
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);
54
+ }
31
55
  function getActualMatchingAmount(accrual) {
32
- return (accrual.cleared?.matchedAmount?.amount ??
33
- accrual.matchSuggestion?.matchedAmount?.amount ??
34
- accrual.estimatedAmount.amount);
56
+ if (isPendingReviewAccrual(accrual)) {
57
+ return (accrual.matchSuggestion?.matchedAmount?.amount ??
58
+ accrual.estimatedAmount.amount);
59
+ }
60
+ if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
61
+ return (getClearedAllocatedActualAmount(accrual) ?? accrual.estimatedAmount.amount);
62
+ }
63
+ return accrual.estimatedAmount.amount;
35
64
  }
36
65
  function getActualMatchingReversalDate(accrual) {
37
66
  if (!isAutoReversedAccrual(accrual) && !isManuallyReversedAccrual(accrual)) {
@@ -135,12 +164,10 @@ function getExpenseAutomationActualMatchingView(state) {
135
164
  amount: listedAccruals.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
136
165
  },
137
166
  ai: {
138
- count: listedAccruals.filter((accrual) => accrual.origin === 'agent')
139
- .length,
167
+ count: listedAccruals.filter((accrual) => accrual.origin === 'agent').length,
140
168
  },
141
169
  manual: {
142
- count: listedAccruals.filter((accrual) => accrual.origin === 'human')
143
- .length,
170
+ count: listedAccruals.filter((accrual) => accrual.origin === 'human').length,
144
171
  },
145
172
  };
146
173
  const accrualSearchResults = matchModal.accrualSearch.results
@@ -4,7 +4,7 @@ import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
4
  import { JEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeSchedulesTypes';
5
5
  export declare const toActualMatchingSortKey: (v: string) => "type" | "date" | "vendor" | "category" | "class" | "amount" | "lifecycle";
6
6
  export type ActualMatchingSortKey = ReturnType<typeof toActualMatchingSortKey>;
7
- export declare const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 10;
7
+ export declare const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
8
8
  export declare const MATCH_ACCRUAL_SEARCH_LIMIT = 50;
9
9
  export declare const MATCH_SEARCH_DEBOUNCE_MS = 300;
10
10
  export declare const toMatchAndReverseResultStatus: (v: string) => "error" | "reversed" | "noop" | "conflict" | "claim_lost";
@@ -13,7 +13,7 @@ const ACTUAL_MATCHING_SORT_KEYS = [
13
13
  ];
14
14
  const toActualMatchingSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, ACTUAL_MATCHING_SORT_KEYS);
15
15
  exports.toActualMatchingSortKey = toActualMatchingSortKey;
16
- exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 10;
16
+ exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
17
17
  exports.MATCH_ACCRUAL_SEARCH_LIMIT = 50;
18
18
  exports.MATCH_SEARCH_DEBOUNCE_MS = 300;
19
19
  const MATCH_AND_REVERSE_RESULT_STATUSES = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.11-betaAM6",
3
+ "version": "5.2.11-betaAM7",
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",