@zeniai/client-epic-state 5.2.22-betaAM1 → 5.2.22-betaRD0

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.
Files changed (78) hide show
  1. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +0 -24
  2. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -40
  3. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -26
  4. package/lib/epic.d.ts +2 -6
  5. package/lib/epic.js +2 -10
  6. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -40
  7. package/lib/esm/epic.js +2 -10
  8. package/lib/esm/index.js +4 -8
  9. package/lib/esm/reducer.js +0 -3
  10. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +11 -28
  11. package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +1 -9
  12. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +45 -7
  13. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +13 -6
  14. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +35 -0
  15. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -5
  16. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +7 -22
  17. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -1
  18. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +31 -7
  19. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +1 -3
  20. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -5
  21. package/lib/index.d.ts +6 -11
  22. package/lib/index.js +49 -73
  23. package/lib/reducer.d.ts +0 -1
  24. package/lib/reducer.js +0 -3
  25. package/lib/rootStateTypes.d.ts +0 -2
  26. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +1 -2
  27. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +11 -28
  28. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +1 -2
  29. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +1 -9
  30. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +1 -1
  31. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +45 -7
  32. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +2 -2
  33. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +12 -5
  34. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.d.ts +12 -0
  35. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +39 -0
  36. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +1 -2
  37. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -5
  38. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +7 -22
  39. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +54 -1
  40. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +3 -3
  41. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +13 -8
  42. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +33 -9
  43. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +0 -2
  44. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +2 -0
  45. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +1 -3
  46. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +3 -1
  47. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -5
  48. package/package.json +1 -1
  49. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +0 -46
  50. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +0 -7
  51. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +0 -50
  52. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +0 -44
  53. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +0 -44
  54. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +0 -60
  55. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +0 -260
  56. package/lib/esm/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +0 -1
  57. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +0 -200
  58. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +0 -22
  59. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +0 -9
  60. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +0 -50
  61. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +0 -5
  62. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +0 -11
  63. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +0 -8
  64. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +0 -54
  65. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +0 -8
  66. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +0 -48
  67. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +0 -8
  68. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +0 -48
  69. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +0 -72
  70. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +0 -65
  71. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +0 -53
  72. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +0 -264
  73. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +0 -59
  74. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +0 -2
  75. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +0 -11
  76. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +0 -212
  77. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +0 -81
  78. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +0 -27
@@ -1,212 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isAutoReversedAccrual = isAutoReversedAccrual;
7
- exports.isManuallyReversedAccrual = isManuallyReversedAccrual;
8
- exports.isPendingReviewAccrual = isPendingReviewAccrual;
9
- exports.getClearedAllocatedActualAmount = getClearedAllocatedActualAmount;
10
- exports.getActualMatchingAmount = getActualMatchingAmount;
11
- exports.getActualMatchingReversalDate = getActualMatchingReversalDate;
12
- exports.getExpenseAutomationActualMatchingView = getExpenseAutomationActualMatchingView;
13
- const orderBy_1 = __importDefault(require("lodash/orderBy"));
14
- const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
15
- const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
16
- const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
17
- function isAutoReversedAccrual(accrual) {
18
- return (accrual.accrualStatus === 'reversed' &&
19
- accrual.reversalTrigger === 'bill_match');
20
- }
21
- function isManuallyReversedAccrual(accrual) {
22
- return (accrual.accrualStatus === 'reversed' &&
23
- accrual.reversalTrigger === 'manual_reverse');
24
- }
25
- function isPendingReviewAccrual(accrual) {
26
- if (accrual.accrualStatus !== 'posted' || accrual.matchSuggestion == null) {
27
- return false;
28
- }
29
- const resolution = accrual.matchSuggestion.resolution;
30
- return resolution == null || resolution.length === 0;
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
- }
55
- function getActualMatchingAmount(accrual) {
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;
64
- }
65
- function getActualMatchingReversalDate(accrual) {
66
- if (!isAutoReversedAccrual(accrual) && !isManuallyReversedAccrual(accrual)) {
67
- return undefined;
68
- }
69
- return accrual.actualReversalPostDate ?? accrual.cleared?.reversedAt;
70
- }
71
- function toActualMatchingRow(accrual, kind) {
72
- return {
73
- ...accrual,
74
- kind,
75
- reversalDate: kind === 'pending_review'
76
- ? undefined
77
- : getActualMatchingReversalDate(accrual),
78
- };
79
- }
80
- function matchesSearch(accrual, searchString) {
81
- const trimmed = searchString.trim().toLowerCase();
82
- if (trimmed.length === 0) {
83
- return true;
84
- }
85
- return (accrual.vendorName.toLowerCase().includes(trimmed) ||
86
- accrual.memo.toLowerCase().includes(trimmed));
87
- }
88
- function getActualMatchingSortValue(row, sortKey) {
89
- switch (sortKey) {
90
- case 'vendor':
91
- return row.vendorName.toLowerCase();
92
- case 'date':
93
- return row.reversalDate?.valueOf();
94
- case 'amount':
95
- return getActualMatchingAmount(row);
96
- case 'category':
97
- return row.jeDebitAccountName?.toLowerCase();
98
- case 'class':
99
- return row.jeDebitAccountingClassName?.toLowerCase();
100
- case 'type':
101
- return (row.cleared?.matchedTransactionType ??
102
- row.matchSuggestion?.matchedTransactionType)?.toLowerCase();
103
- case 'lifecycle':
104
- return row.kind;
105
- default:
106
- return undefined;
107
- }
108
- }
109
- function sortActualMatchingRows(rows, uiState) {
110
- const lodashOrder = uiState.sortOrder === 'ascending' ? 'asc' : 'desc';
111
- return (0, orderBy_1.default)(rows, [(row) => getActualMatchingSortValue(row, uiState.sortKey)], [lodashOrder]);
112
- }
113
- function emptyKpiSummary() {
114
- return {
115
- autoReversed: { count: 0, amount: 0 },
116
- pendingReview: { count: 0, amount: 0 },
117
- totalThisClose: { count: 0, amount: 0 },
118
- ai: { count: 0 },
119
- manual: { count: 0 },
120
- };
121
- }
122
- function getExpenseAutomationActualMatchingView(state) {
123
- const { expenseAutomationActualMatchingViewState, expenseAutomationViewState } = state;
124
- const { accrualKeysByPeriod, fetchState, error, refreshStatus, uiState, matchModal, } = expenseAutomationActualMatchingViewState;
125
- const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
126
- const selectedPeriod = expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
127
- const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : undefined;
128
- const accrualKeys = monthYearPeriodId != null
129
- ? accrualKeysByPeriod[monthYearPeriodId]
130
- : undefined;
131
- const accruals = (accrualKeys ?? [])
132
- .map((key) => (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(key, state.jeSchedulesState))
133
- .filter((accrual) => accrual != null);
134
- const filtered = accruals.filter((accrual) => matchesSearch(accrual, uiState.searchString));
135
- const autoReversed = sortActualMatchingRows(filtered
136
- .filter(isAutoReversedAccrual)
137
- .map((accrual) => toActualMatchingRow(accrual, 'auto_reversed')), uiState);
138
- const pendingReview = sortActualMatchingRows(filtered
139
- .filter(isPendingReviewAccrual)
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
148
- ? emptyKpiSummary()
149
- : {
150
- autoReversed: {
151
- count: listedAccruals.filter(isAutoReversedAccrual).length,
152
- amount: listedAccruals
153
- .filter(isAutoReversedAccrual)
154
- .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
155
- },
156
- pendingReview: {
157
- count: listedAccruals.filter(isPendingReviewAccrual).length,
158
- amount: listedAccruals
159
- .filter(isPendingReviewAccrual)
160
- .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
161
- },
162
- totalThisClose: {
163
- count: listedAccruals.length,
164
- amount: listedAccruals.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
165
- },
166
- ai: {
167
- count: listedAccruals.filter((accrual) => accrual.origin === 'agent').length,
168
- },
169
- manual: {
170
- count: listedAccruals.filter((accrual) => accrual.origin === 'human').length,
171
- },
172
- };
173
- const accrualSearchResults = matchModal.accrualSearch.results
174
- .map((key) => (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(key, state.jeSchedulesState))
175
- .filter((accrual) => accrual != null);
176
- return {
177
- fetchState,
178
- error,
179
- autoReversed,
180
- pendingReview,
181
- manuallyReversed,
182
- kpiSummary,
183
- uiState,
184
- refreshStatus,
185
- hasLoadedForSelectedPeriod: accrualKeys != null,
186
- matchModal: {
187
- isOpen: matchModal.isOpen,
188
- confirmStatus: matchModal.confirmStatus,
189
- lastBatchResults: matchModal.lastBatchResults,
190
- transactionSearch: {
191
- query: matchModal.transactionSearch.query,
192
- results: matchModal.transactionSearch.results,
193
- fetchState: {
194
- fetchState: matchModal.transactionSearch.fetchState,
195
- error: matchModal.transactionSearch.error,
196
- },
197
- nextPageToken: matchModal.transactionSearch.nextPageToken,
198
- isLoadingMore: matchModal.transactionSearch.isLoadingMore,
199
- },
200
- accrualSearch: {
201
- query: matchModal.accrualSearch.query,
202
- results: accrualSearchResults,
203
- fetchState: {
204
- fetchState: matchModal.accrualSearch.fetchState,
205
- error: matchModal.accrualSearch.error,
206
- },
207
- nextPageToken: matchModal.accrualSearch.nextPageToken,
208
- isLoadingMore: matchModal.accrualSearch.isLoadingMore,
209
- },
210
- },
211
- };
212
- }
@@ -1,81 +0,0 @@
1
- import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
2
- import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
3
- import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
- import { JEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeSchedulesTypes';
5
- export declare const toActualMatchingSortKey: (v: string) => "type" | "date" | "vendor" | "category" | "class" | "amount" | "lifecycle";
6
- export type ActualMatchingSortKey = ReturnType<typeof toActualMatchingSortKey>;
7
- export declare const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
8
- export declare const MATCH_ACCRUAL_SEARCH_LIMIT = 50;
9
- export declare const MATCH_SEARCH_DEBOUNCE_MS = 300;
10
- export declare const toMatchAndReverseResultStatus: (v: string) => "error" | "reversed" | "noop" | "conflict" | "claim_lost";
11
- export type MatchAndReverseResultStatus = ReturnType<typeof toMatchAndReverseResultStatus>;
12
- export interface ActualMatchingViewUIState {
13
- scrollPosition: {
14
- scrollTop: number;
15
- scrollLeft?: number;
16
- } | undefined;
17
- searchString: string;
18
- sortKey: ActualMatchingSortKey;
19
- sortOrder: SortOrder;
20
- }
21
- /**
22
- * Sibling of Missing Receipts `MatchCandidate`. Confirm needs `lineId` and
23
- * `transactionIntegrationId` on every row — those fields are required here.
24
- */
25
- export interface ActualMatchingTransactionSearchResult {
26
- amount: number;
27
- currencyCode: string;
28
- currencySymbol: string;
29
- lineId: string;
30
- transactionDate: string;
31
- transactionId: ID;
32
- transactionIntegrationId: string;
33
- transactionType: string;
34
- vendorName: string;
35
- accountDescription?: string;
36
- accountId?: ID;
37
- accountingClassId?: ID;
38
- accountingClassName?: string;
39
- accountName?: string;
40
- transactionDescription?: string;
41
- transactionMemo?: string;
42
- transactionTypeName?: string;
43
- vendorId?: ID;
44
- }
45
- export interface MatchAndReverseResult {
46
- accrualId: ID;
47
- status: MatchAndReverseResultStatus;
48
- reason?: string;
49
- }
50
- export interface MatchAndReverseAccrualsParams {
51
- accrualIds: ID[];
52
- lineId: string;
53
- transactionId: ID;
54
- transactionIntegrationId: string;
55
- transactionType: string;
56
- }
57
- export interface ActualMatchingTransactionSearchState extends FetchStateAndError {
58
- isLoadingMore: boolean;
59
- nextPageToken: string | null;
60
- query: string;
61
- results: ActualMatchingTransactionSearchResult[];
62
- }
63
- export interface ActualMatchingAccrualSearchState extends FetchStateAndError {
64
- isLoadingMore: boolean;
65
- nextPageToken: string | null;
66
- query: string;
67
- results: JEOneTimeAccrualKey[];
68
- }
69
- export interface ActualMatchingMatchModalState {
70
- accrualSearch: ActualMatchingAccrualSearchState;
71
- confirmStatus: FetchStateAndError;
72
- isOpen: boolean;
73
- transactionSearch: ActualMatchingTransactionSearchState;
74
- lastBatchResults?: MatchAndReverseResult[];
75
- }
76
- export interface ActualMatchingViewState extends FetchedState {
77
- accrualKeysByPeriod: Record<MonthYearPeriodId, JEOneTimeAccrualKey[]>;
78
- matchModal: ActualMatchingMatchModalState;
79
- refreshStatus: FetchStateAndError;
80
- uiState: ActualMatchingViewUIState;
81
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toMatchAndReverseResultStatus = exports.MATCH_SEARCH_DEBOUNCE_MS = exports.MATCH_ACCRUAL_SEARCH_LIMIT = exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = exports.toActualMatchingSortKey = void 0;
4
- const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
- const ACTUAL_MATCHING_SORT_KEYS = [
6
- 'vendor',
7
- 'date',
8
- 'amount',
9
- 'category',
10
- 'class',
11
- 'type',
12
- 'lifecycle',
13
- ];
14
- const toActualMatchingSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, ACTUAL_MATCHING_SORT_KEYS);
15
- exports.toActualMatchingSortKey = toActualMatchingSortKey;
16
- exports.MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
17
- exports.MATCH_ACCRUAL_SEARCH_LIMIT = 50;
18
- exports.MATCH_SEARCH_DEBOUNCE_MS = 300;
19
- const MATCH_AND_REVERSE_RESULT_STATUSES = [
20
- 'reversed',
21
- 'noop',
22
- 'conflict',
23
- 'claim_lost',
24
- 'error',
25
- ];
26
- const toMatchAndReverseResultStatus = (v) => (0, stringToUnion_1.stringToUnion)(v, MATCH_AND_REVERSE_RESULT_STATUSES);
27
- exports.toMatchAndReverseResultStatus = toMatchAndReverseResultStatus;