@zeniai/client-epic-state 5.2.41 → 5.2.42

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 (100) hide show
  1. package/lib/entity/actualMatching/actualMatchingPayload.d.ts +31 -0
  2. package/lib/entity/actualMatching/actualMatchingPayload.js +52 -0
  3. package/lib/entity/actualMatching/actualMatchingReducer.d.ts +9 -0
  4. package/lib/entity/actualMatching/actualMatchingReducer.js +33 -0
  5. package/lib/entity/actualMatching/actualMatchingSelector.d.ts +3 -0
  6. package/lib/entity/actualMatching/actualMatchingSelector.js +6 -0
  7. package/lib/entity/actualMatching/actualMatchingState.d.ts +23 -0
  8. package/lib/entity/actualMatching/actualMatchingState.js +2 -0
  9. package/lib/entity/actualMatching/actualMatchingTypes.d.ts +1 -0
  10. package/lib/entity/actualMatching/actualMatchingTypes.js +2 -0
  11. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +31 -0
  12. package/lib/entity/jeSchedules/jeSchedulesPayload.js +53 -0
  13. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +33 -0
  14. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  15. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  16. package/lib/epic.d.ts +8 -1
  17. package/lib/epic.js +14 -0
  18. package/lib/esm/entity/actualMatching/actualMatchingPayload.js +48 -0
  19. package/lib/esm/entity/actualMatching/actualMatchingReducer.js +30 -0
  20. package/lib/esm/entity/actualMatching/actualMatchingSelector.js +3 -0
  21. package/lib/esm/entity/actualMatching/actualMatchingState.js +1 -0
  22. package/lib/esm/entity/actualMatching/actualMatchingTypes.js +1 -0
  23. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +53 -0
  24. package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
  25. package/lib/esm/epic.js +14 -0
  26. package/lib/esm/index.js +7 -3
  27. package/lib/esm/reducer.js +6 -0
  28. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +25 -12
  29. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic.js +46 -0
  30. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +36 -0
  31. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic.js +7 -0
  32. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +108 -0
  33. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/refreshActualMatchingList.js +16 -0
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic.js +60 -0
  35. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +74 -0
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic.js +78 -0
  37. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -3
  38. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +40 -15
  39. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +19 -8
  40. package/lib/esm/view/expenseAutomationView/expenseAutomationViewReducer.js +2 -1
  41. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +24 -6
  42. package/lib/esm/view/expenseAutomationView/expenseAutomationViewState.js +4 -2
  43. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +68 -0
  44. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +462 -0
  45. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -1
  46. package/lib/esm/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +1 -0
  47. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +426 -0
  48. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +4 -0
  49. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +38 -0
  50. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -1
  51. package/lib/index.d.ts +14 -5
  52. package/lib/index.js +82 -48
  53. package/lib/reducer.d.ts +2 -0
  54. package/lib/reducer.js +6 -0
  55. package/lib/rootStateTypes.d.ts +4 -0
  56. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +25 -12
  57. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
  58. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic.js +50 -0
  59. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.d.ts +12 -0
  60. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +40 -0
  61. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
  62. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic.js +11 -0
  63. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.d.ts +9 -0
  64. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +112 -0
  65. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/refreshActualMatchingList.d.ts +3 -0
  66. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/refreshActualMatchingList.js +19 -0
  67. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic.d.ts +9 -0
  68. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic.js +64 -0
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +78 -0
  71. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic.d.ts +9 -0
  72. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic.js +82 -0
  73. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -1
  74. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -3
  75. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.d.ts +5 -1
  76. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +39 -14
  77. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +18 -7
  78. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +2 -1
  79. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.js +2 -1
  80. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +24 -6
  81. package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -1
  82. package/lib/view/expenseAutomationView/expenseAutomationViewState.js +6 -3
  83. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  84. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +85 -0
  85. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +74 -0
  86. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +79 -0
  87. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +466 -0
  88. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +6 -5
  89. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -1
  90. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +87 -0
  91. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +2 -0
  92. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +11 -0
  93. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +38 -0
  94. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +445 -0
  95. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +4 -0
  96. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +106 -0
  97. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +46 -0
  98. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  99. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -1
  100. package/package.json +1 -1
@@ -0,0 +1,48 @@
1
+ import { toAmount } from '../../commonStateTypes/amount';
2
+ import { stringToUnion } from '../../commonStateTypes/stringToUnion';
3
+ import { toJEOneTimeAccrual, } from '../jeSchedules/jeSchedulesPayload';
4
+ const MATCH_KINDS = [
5
+ 'auto_reversed',
6
+ 'pending_review',
7
+ 'manually_reversed',
8
+ ];
9
+ function toMatchKind(raw) {
10
+ return stringToUnion(raw, MATCH_KINDS);
11
+ }
12
+ export function withInheritedAccrualCurrency(member, fallbackCurrencyCode) {
13
+ if (member.currency != null && member.currency !== '') {
14
+ return member;
15
+ }
16
+ return { ...member, currency: fallbackCurrencyCode };
17
+ }
18
+ function toMatchMemberAccrual(member, matchCurrencyCode) {
19
+ return toJEOneTimeAccrual(withInheritedAccrualCurrency(member, matchCurrencyCode));
20
+ }
21
+ export function toActualMatchingMatch(payload, fallbackCurrency) {
22
+ const currencyCode = payload.currency_code != null && payload.currency_code !== ''
23
+ ? payload.currency_code
24
+ : fallbackCurrency?.currencyCode ?? '';
25
+ const currencySymbol = payload.currency_symbol != null && payload.currency_symbol !== ''
26
+ ? payload.currency_symbol
27
+ : fallbackCurrency != null &&
28
+ currencyCode === fallbackCurrency.currencyCode
29
+ ? fallbackCurrency.currencySymbol
30
+ : currencyCode;
31
+ return {
32
+ matchId: payload.match_id,
33
+ transactionType: (payload.transaction_type || '').toLowerCase(),
34
+ transactionIntegrationId: payload.transaction_integration_id,
35
+ transactionDate: payload.transaction_date ?? undefined,
36
+ vendorId: payload.vendor_id ?? undefined,
37
+ vendorName: payload.vendor_name ?? undefined,
38
+ kind: toMatchKind(payload.kind),
39
+ matchTier: payload.match_tier ?? undefined,
40
+ matchShape: payload.match_shape ?? undefined,
41
+ accruedAmount: toAmount(payload.accrued_amount, currencyCode, currencySymbol),
42
+ actualAmount: toAmount(payload.actual_amount, currencyCode, currencySymbol),
43
+ members: payload.members.map((member) => toMatchMemberAccrual(member, currencyCode)),
44
+ leftovers: payload.leftovers == null
45
+ ? undefined
46
+ : payload.leftovers.map((member) => toMatchMemberAccrual(member, currencyCode)),
47
+ };
48
+ }
@@ -0,0 +1,30 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+ import { clearAll } from '../../rootActions';
3
+ import { toActualMatchingMatch, } from './actualMatchingPayload';
4
+ export const initialState = {
5
+ byMatchId: {},
6
+ };
7
+ const actualMatching = createSlice({
8
+ name: 'actualMatching',
9
+ initialState,
10
+ reducers: {
11
+ updateActualMatchingMatches: {
12
+ prepare(matches, fallbackCurrency) {
13
+ return { payload: { matches, fallbackCurrency } };
14
+ },
15
+ reducer(draft, action) {
16
+ action.payload.matches.forEach((payload) => {
17
+ const match = toActualMatchingMatch(payload, action.payload.fallbackCurrency);
18
+ draft.byMatchId[match.matchId] = match;
19
+ });
20
+ },
21
+ },
22
+ },
23
+ extraReducers: (builder) => {
24
+ builder.addCase(clearAll, (draft) => {
25
+ Object.assign(draft, initialState);
26
+ });
27
+ },
28
+ });
29
+ export const { updateActualMatchingMatches } = actualMatching.actions;
30
+ export default actualMatching.reducer;
@@ -0,0 +1,3 @@
1
+ export function getActualMatchingMatchById(actualMatchingState, matchId) {
2
+ return actualMatchingState.byMatchId[matchId];
3
+ }
@@ -444,6 +444,53 @@ function toJEOneTimeAccrualAiSuggestion(payload, currencyCode) {
444
444
  : undefined,
445
445
  };
446
446
  }
447
+ function toJEOneTimeAccrualCleared(payload, currencyCode) {
448
+ if (payload == null) {
449
+ return undefined;
450
+ }
451
+ return {
452
+ matchedTransactionIntegrationId: payload.matched_transaction_integration_id ?? undefined,
453
+ matchedTransactionId: payload.matched_transaction_id ?? undefined,
454
+ matchedTransactionType: payload.matched_transaction_type ?? undefined,
455
+ matchedLineId: payload.matched_line_id ?? undefined,
456
+ consumedLineIds: payload.consumed_line_ids ?? undefined,
457
+ matchedAmount: payload.matched_amount != null
458
+ ? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
459
+ : undefined,
460
+ groupSum: payload.group_sum != null
461
+ ? toOneTimeAccrualAmount(payload.group_sum, currencyCode)
462
+ : undefined,
463
+ accrualIds: payload.accrual_ids ?? undefined,
464
+ intendedAccrualIds: payload.intended_accrual_ids ?? undefined,
465
+ reversedAt: payload.reversed_at != null ? date(payload.reversed_at) : undefined,
466
+ matchedTransactionDate: payload.matched_transaction_date != null
467
+ ? date(payload.matched_transaction_date)
468
+ : undefined,
469
+ matchTier: payload.match_tier ?? undefined,
470
+ matchShape: payload.match_shape ?? undefined,
471
+ matchedTransactionSyncToken: payload.matched_transaction_sync_token ?? undefined,
472
+ };
473
+ }
474
+ function toJEOneTimeAccrualMatchSuggestion(payload, currencyCode) {
475
+ if (payload == null) {
476
+ return undefined;
477
+ }
478
+ return {
479
+ resolution: payload.resolution ?? undefined,
480
+ matchTier: payload.match_tier ?? undefined,
481
+ matchedTransactionIntegrationId: payload.matched_transaction_integration_id ?? undefined,
482
+ matchedTransactionId: payload.matched_transaction_id ?? undefined,
483
+ matchedTransactionType: payload.matched_transaction_type ?? undefined,
484
+ matchedLineId: payload.matched_line_id ?? undefined,
485
+ matchedAmount: payload.matched_amount != null
486
+ ? toOneTimeAccrualAmount(payload.matched_amount, currencyCode)
487
+ : undefined,
488
+ matchedTransactionDate: payload.matched_transaction_date != null
489
+ ? date(payload.matched_transaction_date)
490
+ : undefined,
491
+ matchedTransactionSyncToken: payload.matched_transaction_sync_token ?? undefined,
492
+ };
493
+ }
447
494
  export function toJEOneTimeAccrual(payload) {
448
495
  return {
449
496
  accrualId: payload._id,
@@ -460,6 +507,8 @@ export function toJEOneTimeAccrual(payload) {
460
507
  profileSnapshot: toJEOneTimeAccrualProfileSnapshot(payload.profile_snapshot, payload.currency),
461
508
  isIgnored: payload.is_ignored === true,
462
509
  aiSuggestion: toJEOneTimeAccrualAiSuggestion(payload.ai_suggestion, payload.currency),
510
+ cleared: toJEOneTimeAccrualCleared(payload.cleared, payload.currency),
511
+ matchSuggestion: toJEOneTimeAccrualMatchSuggestion(payload.match_suggestion, payload.currency),
463
512
  // Exclusive by contract: a scheduled row reverses on expectedReversalDate and bills never
464
513
  // drive it, so the two never need reconciling. Defaulting to on_bill_match matches the
465
514
  // create path's default when the field is absent on an older document.
@@ -475,6 +524,9 @@ export function toJEOneTimeAccrual(payload) {
475
524
  actualReversalPostDate: payload.actual_reversal_post_date != null
476
525
  ? date(payload.actual_reversal_post_date)
477
526
  : undefined,
527
+ reversalPostingDate: payload.reversal_posting_date != null
528
+ ? date(payload.reversal_posting_date)
529
+ : undefined,
478
530
  jeDebitAccountId: payload.je_debit_account_id ?? undefined,
479
531
  jeDebitAccountName: payload.je_debit_account_name ?? undefined,
480
532
  jeDebitAccountingClassId: payload.je_debit_accounting_class_id ?? undefined,
@@ -487,6 +539,7 @@ export function toJEOneTimeAccrual(payload) {
487
539
  transactionIntegrationId: payload.transaction_integration_id ?? undefined,
488
540
  reversalTransactionId: payload.reversal_transaction_id ?? undefined,
489
541
  createdBy: toJEOneTimeAccrualCreator(payload.created_by_user),
542
+ reversedBy: toJEOneTimeAccrualCreator(payload.reversed_by_user),
490
543
  };
491
544
  }
492
545
  // The accrual wire format carries a currency CODE but no symbol, so the symbol has to be derived.
@@ -8,6 +8,8 @@ const ALL_SNACKBAR_MESSAGE_SECTIONS = [
8
8
  'cockpit_month_end_email_attachment_upload',
9
9
  'je_bill_link',
10
10
  'je_posted',
11
+ 'actual_matching_match_and_reverse',
12
+ 'actual_matching_undo_reversal',
11
13
  'audit_score_updated',
12
14
  'people_invite_people',
13
15
  'people_invite_multiple_people',
package/lib/esm/epic.js CHANGED
@@ -204,6 +204,13 @@ import { fetchAccountSettingsListForAccountTypesEpic, } from './view/expenseAuto
204
204
  import { fetchRecommendationForAccountSettingsEpic, } from './view/expenseAutomationView/epics/jeSchedule/accountSettings/fetchRecommendationForAccountSettingsEpic';
205
205
  import { initializeAccountSettingsViewEpic, } from './view/expenseAutomationView/epics/jeSchedule/accountSettings/initializeAccountSettingsViewEpic';
206
206
  import { saveAccountSettingsViewEpic, } from './view/expenseAutomationView/epics/jeSchedule/accountSettings/saveAccountSettingsViewEpic';
207
+ import { fetchActualMatchingEpic as fetchExpenseAutomationActualMatchingEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic';
208
+ import { fetchActualMatchingMatchEpic as fetchExpenseAutomationActualMatchingMatchEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic';
209
+ import { fetchActualMatchingPageEpic as fetchExpenseAutomationActualMatchingPageEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic';
210
+ import { matchAndReverseAccrualsEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic';
211
+ import { searchMatchAccrualsEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic';
212
+ import { searchMatchTransactionsEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic';
213
+ import { undoReversalAccrualsEpic, } from './view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic';
207
214
  import { fetchJeSchedulesPageEpic as fetchExpenseAutomationJESchedulesPageEpic, } from './view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic';
208
215
  import { fetchJeSchedulesEpic as fetchExpenseAutomationJeSchedulesEpic, } from './view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic';
209
216
  import { fetchOneTimeAccrualEpic, } from './view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic';
@@ -1001,6 +1008,9 @@ const ALL_EPICS = [
1001
1008
  fetchEntityRecommendationsByTransactionIdEpic,
1002
1009
  fetchEntityRecommendationsForLineUpdateEpic,
1003
1010
  fetchExcludedResourcesEpic,
1011
+ fetchExpenseAutomationActualMatchingEpic,
1012
+ fetchExpenseAutomationActualMatchingMatchEpic,
1013
+ fetchExpenseAutomationActualMatchingPageEpic,
1004
1014
  fetchExpenseAutomationFluxAnalysisViewEpic,
1005
1015
  fetchExpenseAutomationInitializeTransactionCategorizationViewLocalDataEpic,
1006
1016
  fetchExpenseAutomationJeSchedulesEpic,
@@ -1295,6 +1305,7 @@ const ALL_EPICS = [
1295
1305
  lockChargeCardsEpic,
1296
1306
  markAsCompleteScheduleDetailEpic,
1297
1307
  markTransactionAsNotMiscategorizedEpic,
1308
+ matchAndReverseAccrualsEpic,
1298
1309
  notifyMeForFeatureEpic,
1299
1310
  oneTimeAccrualActionsEpic,
1300
1311
  parallelFetchAccountTransactionListEpic,
@@ -1403,6 +1414,8 @@ const ALL_EPICS = [
1403
1414
  saveVendorFirstReviewViewEpic,
1404
1415
  saveVendorsTabVendorEpic,
1405
1416
  scheduleTenantCreditScoreCronEpic,
1417
+ searchMatchAccrualsEpic,
1418
+ searchMatchTransactionsEpic,
1406
1419
  searchTransactionsForManualMatchEpic,
1407
1420
  searchTransactionsForNewScheduleEpic,
1408
1421
  seedAiCardCreationFormDraftEpic,
@@ -1442,6 +1455,7 @@ const ALL_EPICS = [
1442
1455
  treasuryTransferMoneyEpic,
1443
1456
  triggerAiAccountantJobEpic,
1444
1457
  triggerReviewTabRefetchEpic,
1458
+ undoReversalAccrualsEpic,
1445
1459
  unlinkPaymentAccountEpic,
1446
1460
  unlockChargeCardEpic,
1447
1461
  unlockChargeCardsEpic,
package/lib/esm/index.js CHANGED
@@ -184,10 +184,11 @@ import { updateDashboardLayout } from './view/dashboardLayout/dashboardLayoutRed
184
184
  import uploadAccountStatementIntoDocumentAI from './view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper';
185
185
  import { fetchAllExpenseAutomationTabs, refreshExpenseAutomationCurrentTab, updateCurrentSelectedPeriod, updateCurrentSelectedView, } from './view/expenseAutomationView/expenseAutomationViewReducer';
186
186
  import { getExpenseAutomationView } from './view/expenseAutomationView/expenseAutomationViewSelector';
187
- import { toExpenseAutomationViewType, } from './view/expenseAutomationView/expenseAutomationViewState';
187
+ import { toExpenseAutomationViewType, toExpenseAutomationViewTypeStrict, } from './view/expenseAutomationView/expenseAutomationViewState';
188
188
  import { computeNewScheduleJeDetails } from './view/expenseAutomationView/helpers/newScheduleLocalDataHelper';
189
189
  import { isReviewTransactionBankTransferType, isReviewTransactionBillPaymentType, isReviewTransactionCreditCardCreditType, isReviewTransactionCreditCardPaymentType, isReviewTransactionDepositType, isReviewTransactionExpenseType, } from './view/expenseAutomationView/helpers/reconciliationHelpers';
190
190
  import { MAX_SELECTION_LIMIT, checkIfAllLineItemsAreCategoryClassFilled, getLineItemsByTransactionIdsFromLocalData, isAnyItemWithUncategorizedExpenseAccount, } from './view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper';
191
+ import { ackCloseMatchAfterUndo, clearActualMatchingView as clearExpenseAutomationActualMatchingView, clearMatchNewModal, closeMatchNewModal, fetchActualMatching as fetchExpenseAutomationActualMatching, fetchActualMatchingMatch, fetchActualMatchingPage as fetchExpenseAutomationActualMatchingPage, matchAndReverseAccruals, openMatchNewModal, searchMatchAccruals, searchMatchTransactions, undoReversalAccruals, updateActualMatchingUIState as updateExpenseAutomationActualMatchingUIState, } from './view/expenseAutomationView/reducers/actualMatchingViewReducer';
191
192
  import { clearExpenseAutomationFluxAnalysisView, fetchFluxAnalysisView, reviewFluxAnalysisView, updateFluxAnalysisViewPageMetaData, updateFluxAnalysisViewUIState, updateOperatingExpensesIdsForReview, updateSelectedSectionIdsForReview, } from './view/expenseAutomationView/reducers/fluxAnalysisViewReducer';
192
193
  import { clearJeScheduleLocalData as clearExpenseAutomationJEScheduleLocalData, clearExpenseAutomationJESchedulesView, clearSearchTransactionsForNewSchedule as clearJeSearchTransactionsForNewSchedule, createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedulesPage as fetchExpenseAutomationJESchedulesPage, fetchOneTimeAccrual, ignoreRecommendedJeSchedule as ignoreExpenseAutomationJESchedule, ignoreOneTimeAccrual, initializeAccountSettingsView as initializeJeAccountSettingsView, initializeNewSchedule as initializeJeNewSchedule, initializeJeScheduleLocalData, promoteOneTimeAccrual, removeJeOneTimeAccrualLocalData, removeJeScheduleTransactionKey, resetNewScheduleLocalData as resetJeNewScheduleLocalData, retryJeSchedule as retryExpenseAutomationJESchedule, revertJeSchedule, revertOneTimeAccrual, saveAccountSettings as saveJeAccountSettings, saveAccountSettingsLocalData as saveJeAccountSettingsLocalData, saveNewSchedule as saveJeNewSchedule, saveNewScheduleFailure as saveJeNewScheduleFailure, saveNewScheduleSuccess as saveJeNewScheduleSuccess, searchTransactionsForNewSchedule as searchJeTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure as searchJeTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess as searchJeTransactionsForNewScheduleSuccess, toggleJECreatedGroupCollapsed, toggleJEPendingGroupCollapsed, updateJESchedulesUIState as updateExpenseAutomationJESchedulesUIState, updateJEScheduleTypeFilter, updateNewScheduleLocalData as updateJeNewScheduleLocalData, updateJeOneTimeAccrualLocalData, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, } from './view/expenseAutomationView/reducers/jeSchedulesViewReducer';
193
194
  import { acknowledgeBulkUploadConfirmMatchComplete, bulkUploadAutomatchingTimedOut, bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess, clearBulkUpload, clearBulkUploadBatchDetailsForScopeChange, clearManualSearchResults, clearMissingReceiptsTabNavigation, confirmBulkUploadMatch, confirmBulkUploadMatchFailure, confirmBulkUploadMatchSuccess, fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsFailure, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, fetchBulkUploadBatchesFailure, fetchBulkUploadBatchesSuccess, fetchCompletedTransactions, fetchCompletedTransactionsFailure, fetchCompletedTransactionsSuccess, fetchMissingReceipts as fetchExpenseAutomationMissingReceipts, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, markBatchDetailRefreshAttempted, markMissingReceiptAsDone as markExpenseAutomationMissingReceiptAsDone, pusherBatchStatusUpdate, refreshBatchDetailsForBatchId, requestMissingReceiptsTabNavigation, restoreBulkUploadAutomatchingOnMount, restoreBulkUploadMatchingState, searchTransactionsForManualMatch, searchTransactionsForManualMatchFailure, searchTransactionsForManualMatchSuccess, setBulkUploadCompletedSubTab, setBulkUploadResultsTab, setBulkUploadSortConfig, setBulkUploadUploadedFileCount, storeBatchDetails, updateBulkUploadProgress, updateMissingReceiptUploadState as updateExpenseAutomationMissingReceiptUploadState, updateMissingReceiptsUIState as updateExpenseAutomationMissingReceiptsUIState, uploadMissingReceiptSuccess as uploadExpenseAutomationMissingReceiptSuccess, } from './view/expenseAutomationView/reducers/missingReceiptsViewReducer';
@@ -199,8 +200,9 @@ import { getExpenseAutomationReconciliationView, getLedgerAccountIdsWithStatemen
199
200
  import { getExpenseAutomationTransactionView, getLastTransferEntryReplacement, } from './view/expenseAutomationView/selectors/transactionCategorizationSelector';
200
201
  import { applyTransactionFilters } from './view/expenseAutomationView/transactionFilterHelpers';
201
202
  import { TRANSACTION_FILTER_CATEGORIES, } from './view/expenseAutomationView/transactionFilterTypes';
203
+ import { MATCH_ACCRUAL_SEARCH_LIMIT, MATCH_SEARCH_DEBOUNCE_MS, MATCH_TRANSACTION_SEARCH_PAGE_SIZE, actualMatchingTransactionLineKey, toActualMatchingSortKey as toExpenseAutomationActualMatchingSortKey, toMatchAndReverseResultStatus, toUndoReversalResultStatus, } from './view/expenseAutomationView/types/actualMatchingViewState';
202
204
  import { DEFAULT_COMPLETED_SUB_TAB, toCompletedSubTab, } from './view/expenseAutomationView/types/completedSubTab';
203
- import { toJEScheduleSortKey as toExpenseAutomationJEScheduleSortKey, toJEPageTab, } from './view/expenseAutomationView/types/jeSchedulesViewState';
205
+ import { ALL_JE_PAGE_TABS, toJEScheduleSortKey as toExpenseAutomationJEScheduleSortKey, toJEPageTab, } from './view/expenseAutomationView/types/jeSchedulesViewState';
204
206
  import { BATCH_FILE_STATUSES, isUnmatchedTabFileStatus, toBatchFileStatus, toBatchStatusValue, toBulkUploadPhase, toBulkUploadResultsTab, toBulkUploadSortKey, toMatchSource, toMissingReceiptsTab, } from './view/expenseAutomationView/types/missingReceiptsViewState';
205
207
  import { toMissingReceiptsSortKey as toExpenseAutomationMissingReceiptsSortKey, } from './view/expenseAutomationView/types/missingReceiptsViewState';
206
208
  import { toReconciliationTabsType, } from './view/expenseAutomationView/types/reconciliationViewState';
@@ -489,7 +491,7 @@ export { stringToUnion, stringToUnionStrict };
489
491
  export { fetchMonthEndCloseChecks, fetchMonthClosePerformanceTrend, getMonthEndCloseChecksViewByTenantId, ALL_MONTH_END_CLOSE_CHECKS_FREQUENCY, };
490
492
  export {
491
493
  // Bulk Upload Types
492
- BATCH_FILE_STATUSES, isUnmatchedTabFileStatus, DEFAULT_COMPLETED_SUB_TAB, DEFAULT_TRANSACTION_GROUP, TRANSACTION_GROUPS, toTransactionGroup, toBatchFileStatus, toBatchStatusValue, toBulkUploadPhase, toBulkUploadResultsTab, toBulkUploadSortKey, toCompletedSubTab, toMatchSource, toMissingReceiptsTab, toExpenseAutomationJEScheduleSortKey, toJEPageTab, toggleJECreatedGroupCollapsed, toggleJEPendingGroupCollapsed, updateJEScheduleTypeFilter, getExpenseAutomationView, toExpenseAutomationMissingReceiptsSortKey, toExpenseAutomationTransactionsTabKey, toExpenseAutomationViewType, uploadExpenseAutomationMissingReceiptSuccess, markExpenseAutomationMissingReceiptAsDone, fetchAllExpenseAutomationTabs, refreshExpenseAutomationCurrentTab, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionGroup, fetchExpenseAutomationMissingReceipts,
494
+ BATCH_FILE_STATUSES, isUnmatchedTabFileStatus, DEFAULT_COMPLETED_SUB_TAB, DEFAULT_TRANSACTION_GROUP, TRANSACTION_GROUPS, toTransactionGroup, toBatchFileStatus, toBatchStatusValue, toBulkUploadPhase, toBulkUploadResultsTab, toBulkUploadSortKey, toCompletedSubTab, toMatchSource, toMissingReceiptsTab, actualMatchingTransactionLineKey, ALL_JE_PAGE_TABS, MATCH_ACCRUAL_SEARCH_LIMIT, MATCH_SEARCH_DEBOUNCE_MS, MATCH_TRANSACTION_SEARCH_PAGE_SIZE, toExpenseAutomationJEScheduleSortKey, toExpenseAutomationActualMatchingSortKey, toJEPageTab, toMatchAndReverseResultStatus, toUndoReversalResultStatus, toggleJECreatedGroupCollapsed, toggleJEPendingGroupCollapsed, updateJEScheduleTypeFilter, getExpenseAutomationView, toExpenseAutomationMissingReceiptsSortKey, toExpenseAutomationTransactionsTabKey, toExpenseAutomationViewType, toExpenseAutomationViewTypeStrict, uploadExpenseAutomationMissingReceiptSuccess, markExpenseAutomationMissingReceiptAsDone, fetchAllExpenseAutomationTabs, refreshExpenseAutomationCurrentTab, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionGroup, fetchExpenseAutomationMissingReceipts,
493
495
  // Bulk Upload Actions
494
496
  bulkUploadReceipts, bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, bulkUploadReceiptsFailure, restoreBulkUploadAutomatchingOnMount, restoreBulkUploadMatchingState, updateBulkUploadProgress, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, clearMissingReceiptsTabNavigation, fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatchDetailsFailure, storeBatchDetails, fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, fetchBulkUploadBatches, fetchBulkUploadBatchesSuccess, fetchBulkUploadBatchesFailure, clearBulkUploadBatchDetailsForScopeChange, markBatchDetailRefreshAttempted, refreshBatchDetailsForBatchId, confirmBulkUploadMatch, confirmBulkUploadMatchSuccess, confirmBulkUploadMatchFailure, setBulkUploadResultsTab, setBulkUploadCompletedSubTab, setBulkUploadSortConfig, setBulkUploadUploadedFileCount, clearBulkUpload, searchTransactionsForManualMatch, searchTransactionsForManualMatchSuccess, searchTransactionsForManualMatchFailure, clearManualSearchResults, acknowledgeBulkUploadConfirmMatchComplete, fetchCompletedTransactions, fetchCompletedTransactionsSuccess, fetchCompletedTransactionsFailure, fetchFluxAnalysisView, clearExpenseAutomationFluxAnalysisView, updateOperatingExpensesIdsForReview as updateFluxOperatingExpensesIdsForReview, updateSelectedSectionIdsForReview as updateFluxAnalysisSelectedSectionIdsForReview, reviewFluxAnalysisView, updateExpenseAutomationMissingReceiptUploadState, updateExpenseAutomationMissingReceiptsUIState, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, getExpenseAutomationFluxAnalysisView, updateCurrentSelectedView, updateCurrentSelectedPeriod, getExpenseAutomationTransactionView, getLastTransferEntryReplacement, updateFluxAnalysisViewUIState, updateFluxAnalysisViewPageMetaData, MAX_SELECTION_LIMIT, checkIfAllLineItemsAreCategoryClassFilled, getLineItemsByTransactionIdsFromLocalData, isAnyItemWithUncategorizedExpenseAccount, excludeAccountFromReconciliation, includeAccountInReconciliation, saveExpenseAutomationReconciliationDetail, updateExpenseAutomationReconcileTabListScrollState, updateExpenseAutomationReconReviewTabListSortState, updateExpenseAutomationReconcileTabListSortState, updateExpenseAutomationReconcileTabLocalData, updateExpenseAutomationAccountReconciliationSelectedTab, updateExpenseAutomationAccountReconciliationSelectedAccountId, getExpenseAutomationReconciliationView, getLedgerAccountIdsWithStatementOverrideWarning, getLedgerAccountsForCombinedStatementMapping, getReparseStatementStatusByAccountId, getUnavailableLedgerAccountIds, fetchReconciliationView, uploadAccountStatementIntoDocumentAI, updateExpenseAutomationReconListScrollPosition, setConnectionInProgressForAccountReconciliation, getAccountReconByAccountIdAndSelectedPeriod, toReconciliationTabsType, isAccountReconReport, updateExpenseAutomationReconReviewTabLocalData, updateExpenseAutomationSelectedDrawerAccountId, updateStatementProcessingFailed, saveExpenseAutomationReconciliationReview, updateExpenseAutomationAccountReconciliationLocalData, toReconciliationAccountSource, deleteAccountStatement, deleteCombinedStatement, uploadAccountStatement, parseCombinedStatement, parseStatement, parseStatementSuccess, parseStatementFailure, reparseStatement, reparseStatementSuccess, reparseStatementFailure, resetReparseStatementStatus, updateParsedStatementData, updateNodeCollapseState, updateStatementUploadChosen, submitCombinedStatementUpdate, submitStatementUpdate, clearStatementDateConflict, confirmStatementMapping, updateStatementUpdateLocalData, isReviewTransactionBankTransferType, isReviewTransactionBillPaymentType, isReviewTransactionCreditCardPaymentType, isReviewTransactionDepositType, isReviewTransactionExpenseType, isReviewTransactionCreditCardCreditType, setStatementParseInProgress, setStatementProcessingDismissedToBackground, updateStatementProcessingBackgroundCompletedSteps, };
495
497
  export { computeNewScheduleJeDetails, createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchOneTimeAccrual, getJeNewAccrualAccountsView, ignoreOneTimeAccrual, promoteOneTimeAccrual, revertJeSchedule, revertOneTimeAccrual, getJeNewScheduleSearchTransactionsView, getJeNewScheduleView, };
@@ -660,6 +662,7 @@ export { TIME_SERIES_DURATIONS, convertToTimeSeriesSelectionRange, toTimeSeriesD
660
662
  export { fetchApAging, getApAgingReport, updateApAgingUIState, };
661
663
  export { fetchApAgingDetail, getApAgingDetailForVendor, updateApAgingDetailUIState, };
662
664
  export { clearExpenseAutomationJEScheduleLocalData, clearExpenseAutomationJESchedulesView, clearJeSearchTransactionsForNewSchedule, fetchExpenseAutomationJESchedulesPage, ignoreExpenseAutomationJESchedule, initializeJeAccountSettingsView, initializeJeNewSchedule, initializeJeScheduleLocalData, removeJeScheduleTransactionKey, resetJeNewScheduleLocalData, retryExpenseAutomationJESchedule, saveJeNewSchedule, saveJeNewScheduleFailure, saveJeNewScheduleSuccess, searchJeTransactionsForNewSchedule, searchJeTransactionsForNewScheduleFailure, searchJeTransactionsForNewScheduleSuccess, updateExpenseAutomationJESchedulesUIState, updateJeNewScheduleLocalData, removeJeOneTimeAccrualLocalData, updateJeOneTimeAccrualLocalData, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, };
665
+ export { ackCloseMatchAfterUndo, clearExpenseAutomationActualMatchingView, closeMatchNewModal, clearMatchNewModal, fetchExpenseAutomationActualMatching, fetchActualMatchingMatch, fetchExpenseAutomationActualMatchingPage, matchAndReverseAccruals, openMatchNewModal, searchMatchAccruals, searchMatchTransactions, undoReversalAccruals, updateExpenseAutomationActualMatchingUIState, };
663
666
  export { createNewSchedulesAccrued, deleteScheduleAccruedDetail, cancelScheduleAccruedJournalEntry, fetchScheduleAccruedDetails, fetchScheduleAccruedDetailsPage, resetJEAccruedLinkInLocalData, saveScheduleAccruedDetails, updateAmountsInScheduleAccruedDetail, updatedJEAccruedLinkWithRecommendedLocalData, updatedJELinkInLocalDataAccruedExpenses, fetchRecommendedTransactionRowIndex, clearSelectedJELinkRowIndex, updateLinkBillExpenseLocalData, updateScheduleAccruedDetailsLocalData, updateSelectedJEAccruedScheduleKey, resetSelectedJEAccruedScheduleKey, resetAccruedDetailNewScheduleState, };
664
667
  export { getJEScheduleTransactionKey, ALL_JE_SCHEDULE_IGNORE_REASONS, ALL_JE_SCHEDULE_REVERT_REASONS, ALL_ONE_TIME_ACCRUAL_IGNORE_REASONS, ALL_ONE_TIME_ACCRUAL_REVERT_REASONS, ALL_SCHEDULES_TYPES, getScheduleListReport, getAccruedScheduleListReport, fetchScheduleList, fetchAccruedScheduleList, fetchDownloadSchedules, fetchSchedulesAccount, updateScheduleListLocalData, getFetchStateForScheduleAccountList, toScheduleTypesType, toScheduleTypesTypeStrict, toScheduleListTabsFileTypeStrict, toScheduleSubTabType, updateScheduleListSubTab, updateScheduleListSearchText, updateScheduleListScrollState, updateScheduleListSortState, updateSelectedJEScheduleKey, fetchScheduleDetails, getScheduleDetailsView, getAccruedScheduleDetailsView, fetchScheduleDetailsPage, saveScheduleDetails, deleteScheduleDetail, createNewSchedules, updateScheduleDetailsLocalData, updateScheduleListDownloadState, updateAccruedJEScheduleAccruedByListKey, updatedSelectedJELinkRowIndex, getQBOUrlForLink, getThirdPartyIDFromQBOURL, updatedJELinkInLocalData, updateAmountsInScheduleDetail, resetJELinkInLocalData, updatedJELinkWithRecommendedLocalData, getFetchStateForScheduleListByType, getDefaultSelectedTimeframeForScheduleType, markAsCompleteScheduleDetail, resetMarkAsCompleteStatus, fetchVendorTabView, updateVendorTabViewTab, getVendorTabView, };
665
668
  export { toVendorFirstReviewViewColumnKeyType, getGlobalMerchantAutoCompleteResults, getVendorFirstReviewView, getVendorFirstReviewAttachmentView, fetchVendorFirstReviewView, fetchVendorFirstReviewAttachments, updateVendorFirstReviewViewScrollYOffset, resetVendorFirstReviewLocalData, updateVendorFirstReviewViewPageToken, clearRecentlySavedErroredVendorData, saveVendorFirstReviewView, updateVendorFirstReviewViewLocalData, updateVendorFirstReviewSortUiState, fetchGlobalMerchantAutoCompleteView, clearGlobalMerchantAutoCompleteResults, updateReviewVendorDetailLocalData, saveVendorDetailsView, getVendorDetailSelectorView, };
@@ -863,3 +866,4 @@ export { getInvoicingOnboardingGateView } from './view/invoicing/invoicingConfig
863
866
  // Accrued JE schedules are not a discriminated union member, so consumers need this guard to
864
867
  // narrow a JEScheduleRow before reading baseTransaction / recurringAmount.
865
868
  export { getExpenseAutomationJEOneTimeAccrualDetailView, getJEScheduleRowType, isAccruedScheduleRow, isAiAccountantSchedule, isExistingTabRow, isOneTimeAccrualRow, isRenderableOneTimeAccrual, isPendingReviewRow, } from './view/expenseAutomationView/selectors/jeSchedulesViewSelector';
869
+ export { getActualMatchingAmount, getActualMatchingReversalDate, getCloseMatchAfterUndo, parseActualMatchingMatchId, getExpenseAutomationActualMatchingMatchView, getExpenseAutomationActualMatchingView, isAutoReversedAccrual, isManuallyReversedAccrual, isPendingReviewAccrual, } from './view/expenseAutomationView/selectors/actualMatchingViewSelector';
@@ -42,6 +42,7 @@ import invoicingSubscription, { initialState as initialInvoicingSubscriptionStat
42
42
  import invoicingTransaction, { initialState as initialInvoicingTransactionState, } from './entity/invoicing/invoicingTransaction/invoicingTransactionReducer';
43
43
  import invoicingPlan, { initialState as initialInvoicingPlanState, } from './entity/invoicing/plan/planReducer';
44
44
  import invoicingProduct, { initialState as initialInvoicingProductState, } from './entity/invoicing/product/productReducer';
45
+ import actualMatching, { initialState as initialActualMatchingState, } from './entity/actualMatching/actualMatchingReducer';
45
46
  import jeSchedules, { initialState as initialJESchedulesState, } from './entity/jeSchedules/jeSchedulesReducer';
46
47
  import merchant, { initialState as initialMerchantState, } from './entity/merchant/merchantReducer';
47
48
  import monthEndCloseChecks, { initialState as initialMonthEndCloseChecksState, } from './entity/monthEndCloseChecks/monthEndCloseChecksReducer';
@@ -118,6 +119,7 @@ import creditAgentView, { initialState as initialCreditAgentViewState, } from '.
118
119
  import dashboard, { initialState as initialDashboardState, } from './view/dashboard/dashboardReducer';
119
120
  import dashboardLayout, { initialState as initialDashboardLayoutState, } from './view/dashboardLayout/dashboardLayoutReducer';
120
121
  import expenseAutomationView, { initialState as initialExpenseAutomationViewState, } from './view/expenseAutomationView/expenseAutomationViewReducer';
122
+ import expenseAutomationActualMatchingView, { initialState as initialExpenseAutomationActualMatchingViewState, } from './view/expenseAutomationView/reducers/actualMatchingViewReducer';
121
123
  import expenseAutomationFluxAnalysisView, { initialState as initialExpenseAutomationFluxAnalysisViewState, } from './view/expenseAutomationView/reducers/fluxAnalysisViewReducer';
122
124
  import expenseAutomationJESchedulesView, { initialState as initialExpenseAutomationJESchedulesViewState, } from './view/expenseAutomationView/reducers/jeSchedulesViewReducer';
123
125
  import expenseAutomationMissingReceiptsView, { initialState as initialExpenseAutomationMissingReceiptsViewState, } from './view/expenseAutomationView/reducers/missingReceiptsViewReducer';
@@ -279,6 +281,7 @@ const initialEntitiesState = {
279
281
  accountingSummaryState: initialAccountingSummaryState,
280
282
  accountReconState: initialAccountReconState,
281
283
  accountState: initialAccountState,
284
+ actualMatchingState: initialActualMatchingState,
282
285
  addressState: initialAddressState,
283
286
  aiAccountantCustomerState: initialAiAccountantCustomerState,
284
287
  aiCfoState: initialAiCfoState,
@@ -421,6 +424,7 @@ const initialViewsState = {
421
424
  entityAutoCompleteState: initialEntityAutoCompleteState,
422
425
  entityRecommendationState: initialEntityRecommendationState,
423
426
  expenseAutomationFluxAnalysisViewState: initialExpenseAutomationFluxAnalysisViewState,
427
+ expenseAutomationActualMatchingViewState: initialExpenseAutomationActualMatchingViewState,
424
428
  expenseAutomationJESchedulesViewState: initialExpenseAutomationJESchedulesViewState,
425
429
  expenseAutomationMissingReceiptsViewState: initialExpenseAutomationMissingReceiptsViewState,
426
430
  expenseAutomationReconciliationViewState: initialExpenseAutomationReconciliationViewState,
@@ -563,6 +567,7 @@ const entityReducers = {
563
567
  accountReconState: accountRecon,
564
568
  accountingSummaryState: accountingSummary,
565
569
  accountState: account,
570
+ actualMatchingState: actualMatching,
566
571
  addressState: address,
567
572
  aiAccountantCustomerState: aiAccountantCustomer,
568
573
  aiCfoState: aiCfo,
@@ -705,6 +710,7 @@ const viewReducers = {
705
710
  entityAutoCompleteState: entityAutoComplete,
706
711
  entityRecommendationState: recommendation,
707
712
  expenseAutomationFluxAnalysisViewState: expenseAutomationFluxAnalysisView,
713
+ expenseAutomationActualMatchingViewState: expenseAutomationActualMatchingView,
708
714
  expenseAutomationJESchedulesViewState: expenseAutomationJESchedulesView,
709
715
  expenseAutomationMissingReceiptsViewState: expenseAutomationMissingReceiptsView,
710
716
  expenseAutomationReconciliationViewState: expenseAutomationReconciliationView,
@@ -10,7 +10,7 @@ import { fetchReconciliation } from '../../reducers/reconciliationViewReducer';
10
10
  import { fetchTransactionCategorizationView } from '../../reducers/transactionsViewReducer';
11
11
  import { getJESchedulePeriodTabKey } from '../../types/jeSchedulesViewState';
12
12
  export const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe(filter(fetchAllExpenseAutomationTabs.match), switchMap((action) => {
13
- const { cacheOverride, refreshViewInBackground } = action.payload;
13
+ const { cacheOverride, refreshViewInBackground, isAccrualEnabled } = action.payload;
14
14
  const state = state$.value;
15
15
  const { monthEndCloseChecksState } = state;
16
16
  const { monthEndCloseChecksByTenantId } = monthEndCloseChecksState;
@@ -35,7 +35,7 @@ export const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.
35
35
  amount: 75.0,
36
36
  currencyCode: 'USD',
37
37
  currencySymbol: '$',
38
- }, cacheOverride, refreshViewInBackground), fetchFluxAnalysisView(selectedPeriod, cacheOverride, refreshViewInBackground, null), fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
38
+ }, cacheOverride, refreshViewInBackground), fetchFluxAnalysisView(selectedPeriod, cacheOverride, refreshViewInBackground, null), fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride, isAccrualEnabled));
39
39
  if (reconciliationEnabled) {
40
40
  actions.push(fetchReconciliation(selectedPeriod, undefined, cacheOverride, refreshViewInBackground));
41
41
  }
@@ -61,16 +61,29 @@ export const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.
61
61
  fetchActions.push(fetchFluxAnalysisView(selectedPeriod, cacheOverride, refreshViewInBackground, null));
62
62
  }
63
63
  // The two JE tabs cache separately, so only the tab actually being shown decides whether a
64
- // fetch is still needed.
65
- const jeSchedulesPeriodTabKey = getJESchedulePeriodTabKey(state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab, monthYearPeriodId);
66
- if (state.expenseAutomationJESchedulesViewState.fetchState !==
67
- 'In-Progress' &&
68
- (!state.expenseAutomationJESchedulesViewState.hasValidState() ||
69
- state.expenseAutomationJESchedulesViewState
70
- .jeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null ||
71
- state.expenseAutomationJESchedulesViewState
72
- .failedJeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null)) {
73
- fetchActions.push(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
64
+ // fetch is still needed. Actual Matching is a third tab on the same page with its own
65
+ // endpoint; fetchJeSchedulesPage carries isAccrualEnabled so the prefetch epic can warm AM.
66
+ const selectedPageTab = state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab;
67
+ if (selectedPageTab === 'actual_matching') {
68
+ const actualMatchingPeriodKeys = state.expenseAutomationActualMatchingViewState.matchIdsByPeriod[monthYearPeriodId];
69
+ // `fetchState` is global across months. Skipping on In-Progress would
70
+ // drop October while September is still loading; September's success
71
+ // then writes the old month and October stays Not-Started with no request.
72
+ if (actualMatchingPeriodKeys == null) {
73
+ fetchActions.push(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride, isAccrualEnabled));
74
+ }
75
+ }
76
+ else {
77
+ const jeSchedulesPeriodTabKey = getJESchedulePeriodTabKey(selectedPageTab, monthYearPeriodId);
78
+ if (state.expenseAutomationJESchedulesViewState.fetchState !==
79
+ 'In-Progress' &&
80
+ (!state.expenseAutomationJESchedulesViewState.hasValidState() ||
81
+ state.expenseAutomationJESchedulesViewState
82
+ .jeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null ||
83
+ state.expenseAutomationJESchedulesViewState
84
+ .failedJeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null)) {
85
+ fetchActions.push(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride, isAccrualEnabled));
86
+ }
74
87
  }
75
88
  if (state.expenseAutomationReconciliationViewState.fetchState !==
76
89
  'In-Progress' &&
@@ -0,0 +1,46 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, filter, mergeMap, switchMap, takeUntil, } from 'rxjs/operators';
3
+ import { updateActualMatchingMatches } from '../../../../../entity/actualMatching/actualMatchingReducer';
4
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
5
+ import { clearAll } from '../../../../../rootActions';
6
+ import { toServiceMonthFromPeriod, } from '../../../payload/actualMatchingPayload';
7
+ import { fetchActualMatching, fetchActualMatchingFailure, fetchActualMatchingSuccess, } from '../../../reducers/actualMatchingViewReducer';
8
+ import { getTenantDisplayCurrency } from '../../../selectors/actualMatchingViewSelector';
9
+ export const fetchActualMatchingEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchActualMatching.match), switchMap((action) => {
10
+ const state = state$.value;
11
+ const { period, refreshViewInBackground } = action.payload;
12
+ // Key the store write off the requested month. Using the selected period
13
+ // would park a prefetch for October under September's slot.
14
+ const requestPeriod = {
15
+ month: period.start.month,
16
+ year: period.start.year,
17
+ };
18
+ const serviceMonth = toServiceMonthFromPeriod(period);
19
+ return zeniAPI
20
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/actual-matching?service_month=${encodeURIComponent(serviceMonth)}`)
21
+ .pipe(mergeMap((response) => {
22
+ if (isSuccessResponse(response) && response.data != null) {
23
+ const matches = response.data.matches;
24
+ const updateActions = [];
25
+ if (matches.length > 0) {
26
+ updateActions.push(updateActualMatchingMatches(matches, getTenantDisplayCurrency(state)));
27
+ }
28
+ updateActions.push(fetchActualMatchingSuccess({
29
+ matchIds: matches.map((match) => match.match_id),
30
+ selectedPeriod: requestPeriod,
31
+ refreshViewInBackground,
32
+ }));
33
+ return from(updateActions);
34
+ }
35
+ return of(fetchActualMatchingFailure({
36
+ status: response.status,
37
+ selectedPeriod: requestPeriod,
38
+ refreshViewInBackground,
39
+ }));
40
+ }), catchError((error) => of(fetchActualMatchingFailure({
41
+ status: createZeniAPIStatus('Unexpected Error', 'fetch actual matching REST API call errored out' +
42
+ JSON.stringify(error)),
43
+ selectedPeriod: requestPeriod,
44
+ refreshViewInBackground,
45
+ }))), takeUntil(actions$.pipe(filter(clearAll.match))));
46
+ }));
@@ -0,0 +1,36 @@
1
+ import { from } from 'rxjs';
2
+ import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
3
+ import { updateActualMatchingMatches } from '../../../../../entity/actualMatching/actualMatchingReducer';
4
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
5
+ import { clearAll } from '../../../../../rootActions';
6
+ import { fetchActualMatchingMatch, fetchActualMatchingMatchFailure, fetchActualMatchingMatchSuccess, } from '../../../reducers/actualMatchingViewReducer';
7
+ import { getTenantDisplayCurrency } from '../../../selectors/actualMatchingViewSelector';
8
+ export const fetchActualMatchingMatchEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchActualMatchingMatch.match), mergeMap((action) => {
9
+ const { matchId, refreshViewInBackground } = action.payload;
10
+ return zeniAPI
11
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/actual-matching/${encodeURIComponent(matchId)}`)
12
+ .pipe(mergeMap((response) => {
13
+ if (isSuccessResponse(response) && response.data != null) {
14
+ return from([
15
+ updateActualMatchingMatches([response.data], getTenantDisplayCurrency(state$.value)),
16
+ fetchActualMatchingMatchSuccess({
17
+ matchId,
18
+ refreshViewInBackground,
19
+ }),
20
+ ]);
21
+ }
22
+ return from([
23
+ fetchActualMatchingMatchFailure({
24
+ matchId,
25
+ refreshViewInBackground,
26
+ status: response.status,
27
+ }),
28
+ ]);
29
+ }), catchError((error) => from([
30
+ fetchActualMatchingMatchFailure({
31
+ matchId,
32
+ refreshViewInBackground,
33
+ status: createZeniAPIStatus('Unexpected Error', `Fetch actual matching match REST API call errored out ${JSON.stringify(error)}`),
34
+ }),
35
+ ])), takeUntil(actions$.pipe(filter(clearAll.match))));
36
+ }));
@@ -0,0 +1,7 @@
1
+ import { of } from 'rxjs';
2
+ import { filter, mergeMap } from 'rxjs/operators';
3
+ import { fetchActualMatching, fetchActualMatchingPage, } from '../../../reducers/actualMatchingViewReducer';
4
+ export const fetchActualMatchingPageEpic = (actions$) => actions$.pipe(filter(fetchActualMatchingPage.match), mergeMap((action) => {
5
+ const { period, refreshViewInBackground } = action.payload;
6
+ return of(fetchActualMatching(period, refreshViewInBackground));
7
+ }));
@@ -0,0 +1,108 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, exhaustMap, filter, mergeMap, takeUntil } from 'rxjs/operators';
3
+ import { getActualMatchingMatchById } from '../../../../../entity/actualMatching/actualMatchingSelector';
4
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
+ import { createZeniAPIStatus, isSuccessResponse } from '../../../../../responsePayload';
6
+ import { clearAll } from '../../../../../rootActions';
7
+ import { toMatchAndReverseResult, } from '../../../payload/actualMatchingPayload';
8
+ import { clearMatchNewModal, fetchActualMatchingMatch, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess, } from '../../../reducers/actualMatchingViewReducer';
9
+ import { isMatchAndReverseCompleteStatus, } from '../../../types/actualMatchingViewState';
10
+ import { refreshActualMatchingList } from './refreshActualMatchingList';
11
+ function isMatchFailedStatus(status) {
12
+ return (status === 'conflict' || status === 'claim_lost' || status === 'error');
13
+ }
14
+ function matchAndReverseSnackbar(results, vendorName) {
15
+ const reversedCount = results.filter((result) => result.status === 'reversed').length;
16
+ const failedCount = results.filter((result) => isMatchFailedStatus(result.status)).length;
17
+ const variables = [
18
+ { variableName: '_count_', variableValue: String(reversedCount) },
19
+ { variableName: '_vendor_name_', variableValue: vendorName },
20
+ ];
21
+ if (results.length === 0 || (reversedCount === 0 && failedCount > 0)) {
22
+ return openSnackbar({
23
+ messageSection: 'actual_matching_match_and_reverse',
24
+ messageText: 'failed',
25
+ type: 'error',
26
+ variables,
27
+ });
28
+ }
29
+ if (reversedCount > 0 && failedCount === 0) {
30
+ return openSnackbar({
31
+ messageSection: 'actual_matching_match_and_reverse',
32
+ messageText: 'success',
33
+ type: 'success',
34
+ variables,
35
+ });
36
+ }
37
+ if (reversedCount > 0 && failedCount > 0) {
38
+ return openSnackbar({
39
+ messageSection: 'actual_matching_match_and_reverse',
40
+ messageText: 'notification',
41
+ type: 'warning',
42
+ variables,
43
+ });
44
+ }
45
+ return null;
46
+ }
47
+ function matchAndReverseHttpFailSnackbar(vendorName) {
48
+ return openSnackbar({
49
+ messageSection: 'actual_matching_match_and_reverse',
50
+ messageText: 'failed',
51
+ type: 'error',
52
+ variables: [
53
+ { variableName: '_count_', variableValue: '0' },
54
+ { variableName: '_vendor_name_', variableValue: vendorName },
55
+ ],
56
+ });
57
+ }
58
+ function matchVendorName(state, matchId) {
59
+ return getActualMatchingMatchById(state.actualMatchingState, matchId)?.vendorName ?? '';
60
+ }
61
+ export const matchAndReverseAccrualsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(matchAndReverseAccruals.match),
62
+ // Posts reversing JEs; drop duplicate clicks while a request is in flight.
63
+ exhaustMap((action) => {
64
+ const { transactionId, transactionIntegrationId, transactionType, lineIds, accrualIds, transactionSyncToken, } = action.payload;
65
+ const body = {
66
+ transaction_id: transactionId,
67
+ transaction_integration_id: transactionIntegrationId,
68
+ transaction_type: transactionType,
69
+ line_ids: lineIds,
70
+ transaction_sync_token: transactionSyncToken,
71
+ accrual_ids: accrualIds,
72
+ };
73
+ // Key leftover results and snackbar vendor to the confirmed bill, not the
74
+ // row Match New was opened from (user can pick a different txn).
75
+ const matchId = `${transactionType.toLowerCase()}:${transactionIntegrationId}`;
76
+ const vendorName = matchVendorName(state$.value, matchId);
77
+ return zeniAPI
78
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/match-and-reverse`, body)
79
+ .pipe(mergeMap((response) => {
80
+ if (isSuccessResponse(response) && response.data != null) {
81
+ const results = response.data.results.map(toMatchAndReverseResult);
82
+ const successActions = [
83
+ matchAndReverseAccrualsSuccess({ matchId, results }),
84
+ ];
85
+ const occupancyChanged = results.some((result) => isMatchAndReverseCompleteStatus(result.status));
86
+ const allComplete = results.length > 0 &&
87
+ results.every((result) => isMatchAndReverseCompleteStatus(result.status));
88
+ if (occupancyChanged) {
89
+ // List + detail: list can omit leftovers; detail GET always
90
+ // writes intended occupancy so Continue match prefills the
91
+ // remaining leftover set instead of a stale cached row.
92
+ successActions.push(...refreshActualMatchingList(state$.value), fetchActualMatchingMatch(matchId, true));
93
+ }
94
+ const snackbar = matchAndReverseSnackbar(results, vendorName);
95
+ if (snackbar != null) {
96
+ successActions.push(snackbar);
97
+ }
98
+ if (allComplete) {
99
+ successActions.push(clearMatchNewModal());
100
+ }
101
+ return from(successActions);
102
+ }
103
+ return of(matchAndReverseAccrualsFailure({ status: response.status }), matchAndReverseHttpFailSnackbar(vendorName));
104
+ }), catchError((error) => of(matchAndReverseAccrualsFailure({
105
+ status: createZeniAPIStatus('Unexpected Error', 'Match and reverse accruals REST API call errored out' +
106
+ JSON.stringify(error)),
107
+ }), matchAndReverseHttpFailSnackbar(vendorName))), takeUntil(actions$.pipe(filter(clearAll.match))));
108
+ }));
@@ -0,0 +1,16 @@
1
+ import { convertToPeriod, toAbsoluteDay, } from '../../../../../commonStateTypes/timePeriod';
2
+ import { fetchActualMatching } from '../../../reducers/actualMatchingViewReducer';
3
+ import { getSelectedMonthYearForCurrentTenant } from '../../../selectors/actualMatchingViewSelector';
4
+ export function refreshActualMatchingList(state) {
5
+ const selectedMonthYear = getSelectedMonthYearForCurrentTenant(state);
6
+ if (selectedMonthYear == null) {
7
+ return [];
8
+ }
9
+ const period = convertToPeriod(selectedMonthYear);
10
+ const start = toAbsoluteDay(period.start);
11
+ const end = toAbsoluteDay(period.end);
12
+ if (start == null || end == null) {
13
+ return [];
14
+ }
15
+ return [fetchActualMatching({ start, end }, true)];
16
+ }