@zeniai/client-epic-state 5.2.34 → 5.2.35-beta10MM

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 (115) hide show
  1. package/lib/entity/actualMatching/actualMatchingPayload.d.ts +31 -0
  2. package/lib/entity/actualMatching/actualMatchingPayload.js +50 -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/aiCfo/aiCfoReducer.js +78 -4
  12. package/lib/entity/aiCfo/aiCfoState.d.ts +16 -0
  13. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +31 -0
  14. package/lib/entity/jeSchedules/jeSchedulesPayload.js +53 -0
  15. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +33 -0
  16. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  17. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  18. package/lib/epic.d.ts +8 -1
  19. package/lib/epic.js +14 -0
  20. package/lib/esm/entity/actualMatching/actualMatchingPayload.js +46 -0
  21. package/lib/esm/entity/actualMatching/actualMatchingReducer.js +30 -0
  22. package/lib/esm/entity/actualMatching/actualMatchingSelector.js +3 -0
  23. package/lib/esm/entity/actualMatching/actualMatchingState.js +1 -0
  24. package/lib/esm/entity/actualMatching/actualMatchingTypes.js +1 -0
  25. package/lib/esm/entity/aiCfo/aiCfoReducer.js +79 -5
  26. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +53 -0
  27. package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
  28. package/lib/esm/epic.js +14 -0
  29. package/lib/esm/index.js +7 -3
  30. package/lib/esm/reducer.js +6 -0
  31. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +44 -0
  32. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingMatchEpic.js +36 -0
  33. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +7 -0
  34. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +107 -0
  35. package/lib/esm/view/expenseAutomationView/epics/actualMatching/refreshActualMatchingList.js +16 -0
  36. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +54 -0
  37. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +74 -0
  38. package/lib/esm/view/expenseAutomationView/epics/actualMatching/undoReversalAccrualsEpic.js +76 -0
  39. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +25 -12
  40. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -3
  41. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +35 -15
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +8 -3
  43. package/lib/esm/view/expenseAutomationView/expenseAutomationViewReducer.js +2 -1
  44. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +24 -6
  45. package/lib/esm/view/expenseAutomationView/expenseAutomationViewState.js +4 -2
  46. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +68 -0
  47. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +434 -0
  48. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -1
  49. package/lib/esm/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +1 -0
  50. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +426 -0
  51. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +4 -0
  52. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +35 -0
  53. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -1
  54. package/lib/esm/view/financeStatement/financeStatementReducer.js +17 -27
  55. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +4 -0
  56. package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +3 -3
  57. package/lib/index.d.ts +15 -6
  58. package/lib/index.js +82 -48
  59. package/lib/reducer.d.ts +2 -0
  60. package/lib/reducer.js +6 -0
  61. package/lib/rootStateTypes.d.ts +4 -0
  62. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
  63. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +48 -0
  64. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingMatchEpic.d.ts +12 -0
  65. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingMatchEpic.js +40 -0
  66. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
  67. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +11 -0
  68. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +9 -0
  69. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +111 -0
  70. package/lib/view/expenseAutomationView/epics/actualMatching/refreshActualMatchingList.d.ts +3 -0
  71. package/lib/view/expenseAutomationView/epics/actualMatching/refreshActualMatchingList.js +19 -0
  72. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +9 -0
  73. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +58 -0
  74. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
  75. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +78 -0
  76. package/lib/view/expenseAutomationView/epics/actualMatching/undoReversalAccrualsEpic.d.ts +9 -0
  77. package/lib/view/expenseAutomationView/epics/actualMatching/undoReversalAccrualsEpic.js +80 -0
  78. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +25 -12
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -1
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -3
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.d.ts +5 -1
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +34 -14
  83. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +8 -3
  84. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +2 -1
  85. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.js +2 -1
  86. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +24 -6
  87. package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -1
  88. package/lib/view/expenseAutomationView/expenseAutomationViewState.js +6 -3
  89. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  90. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +85 -0
  91. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +74 -0
  92. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +79 -0
  93. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +438 -0
  94. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +6 -5
  95. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -1
  96. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +87 -0
  97. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +2 -0
  98. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +11 -0
  99. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +38 -0
  100. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +445 -0
  101. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +4 -0
  102. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +105 -0
  103. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +42 -0
  104. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  105. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -1
  106. package/lib/view/financeStatement/financeStatementReducer.js +17 -27
  107. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.d.ts +1 -11
  108. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +4 -0
  109. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +1 -2
  110. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +1 -2
  111. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +15 -1
  112. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +1 -1
  113. package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +1 -1
  114. package/lib/view/spendManagement/billPay/billList/billListSelector.js +2 -2
  115. package/package.json +1 -1
package/lib/reducer.d.ts CHANGED
@@ -67,6 +67,7 @@ declare const reducers: import("redux").Reducer<import("redux").CombinedState<{
67
67
  entityAutoCompleteState: import("./view/autoComplete/entityAutoCompleteState").EntityAutoCompleteState;
68
68
  entityRecommendationState: import("./view/recommendation/recommendationState").EntityRecommendationState;
69
69
  expenseAutomationFluxAnalysisViewState: import("./view/expenseAutomationView/types/fluxAnalysisViewState").FluxAnalysisViewState;
70
+ expenseAutomationActualMatchingViewState: import("./view/expenseAutomationView/types/actualMatchingViewState").ActualMatchingViewState;
70
71
  expenseAutomationJESchedulesViewState: import("./view/expenseAutomationView/types/jeSchedulesViewState").JESchedulesViewState;
71
72
  expenseAutomationMissingReceiptsViewState: import(".").ExpenseAutomationMissingReceiptsViewState;
72
73
  expenseAutomationReconciliationViewState: import("./view/expenseAutomationView/types/reconciliationViewState").ReconciliationViewState;
@@ -203,6 +204,7 @@ declare const reducers: import("redux").Reducer<import("redux").CombinedState<{
203
204
  accountReconState: import("./entity/accountRecon/accountReconState").AccountReconState;
204
205
  accountingSummaryState: import("./entity/portfolio/accountingSummary/accountingSummaryState").AccountingSummaryState;
205
206
  accountState: import("./entity/account/accountState").AccountState;
207
+ actualMatchingState: import("./entity/actualMatching/actualMatchingState").ActualMatchingState;
206
208
  addressState: import("./entity/address/addressState").AddressState;
207
209
  aiAccountantCustomerState: import(".").AiAccountantCustomerState;
208
210
  aiCfoState: import(".").AiCfoState;
package/lib/reducer.js CHANGED
@@ -81,6 +81,7 @@ const invoicingSubscriptionReducer_1 = __importStar(require("./entity/invoicing/
81
81
  const invoicingTransactionReducer_1 = __importStar(require("./entity/invoicing/invoicingTransaction/invoicingTransactionReducer"));
82
82
  const planReducer_1 = __importStar(require("./entity/invoicing/plan/planReducer"));
83
83
  const productReducer_1 = __importStar(require("./entity/invoicing/product/productReducer"));
84
+ const actualMatchingReducer_1 = __importStar(require("./entity/actualMatching/actualMatchingReducer"));
84
85
  const jeSchedulesReducer_1 = __importStar(require("./entity/jeSchedules/jeSchedulesReducer"));
85
86
  const merchantReducer_1 = __importStar(require("./entity/merchant/merchantReducer"));
86
87
  const monthEndCloseChecksReducer_1 = __importStar(require("./entity/monthEndCloseChecks/monthEndCloseChecksReducer"));
@@ -157,6 +158,7 @@ const creditAgentViewReducer_1 = __importStar(require("./view/creditAgentView/cr
157
158
  const dashboardReducer_1 = __importStar(require("./view/dashboard/dashboardReducer"));
158
159
  const dashboardLayoutReducer_1 = __importStar(require("./view/dashboardLayout/dashboardLayoutReducer"));
159
160
  const expenseAutomationViewReducer_1 = __importStar(require("./view/expenseAutomationView/expenseAutomationViewReducer"));
161
+ const actualMatchingViewReducer_1 = __importStar(require("./view/expenseAutomationView/reducers/actualMatchingViewReducer"));
160
162
  const fluxAnalysisViewReducer_1 = __importStar(require("./view/expenseAutomationView/reducers/fluxAnalysisViewReducer"));
161
163
  const jeSchedulesViewReducer_1 = __importStar(require("./view/expenseAutomationView/reducers/jeSchedulesViewReducer"));
162
164
  const missingReceiptsViewReducer_1 = __importStar(require("./view/expenseAutomationView/reducers/missingReceiptsViewReducer"));
@@ -318,6 +320,7 @@ const initialEntitiesState = {
318
320
  accountingSummaryState: accountingSummaryReducer_1.initialState,
319
321
  accountReconState: accountReconReducer_1.initialState,
320
322
  accountState: accountReducer_1.initialState,
323
+ actualMatchingState: actualMatchingReducer_1.initialState,
321
324
  addressState: addressReducer_1.initialState,
322
325
  aiAccountantCustomerState: aiAccountantCustomerReducer_1.initialAiAccountantCustomerState,
323
326
  aiCfoState: aiCfoReducer_1.initialAiCfoState,
@@ -460,6 +463,7 @@ const initialViewsState = {
460
463
  entityAutoCompleteState: entityAutoCompleteReducer_1.initialState,
461
464
  entityRecommendationState: recommendationReducer_1.initialState,
462
465
  expenseAutomationFluxAnalysisViewState: fluxAnalysisViewReducer_1.initialState,
466
+ expenseAutomationActualMatchingViewState: actualMatchingViewReducer_1.initialState,
463
467
  expenseAutomationJESchedulesViewState: jeSchedulesViewReducer_1.initialState,
464
468
  expenseAutomationMissingReceiptsViewState: missingReceiptsViewReducer_1.initialState,
465
469
  expenseAutomationReconciliationViewState: reconciliationViewReducer_1.initialState,
@@ -602,6 +606,7 @@ const entityReducers = {
602
606
  accountReconState: accountReconReducer_1.default,
603
607
  accountingSummaryState: accountingSummaryReducer_1.default,
604
608
  accountState: accountReducer_1.default,
609
+ actualMatchingState: actualMatchingReducer_1.default,
605
610
  addressState: addressReducer_1.default,
606
611
  aiAccountantCustomerState: aiAccountantCustomerReducer_1.default,
607
612
  aiCfoState: aiCfoReducer_1.default,
@@ -744,6 +749,7 @@ const viewReducers = {
744
749
  entityAutoCompleteState: entityAutoCompleteReducer_1.default,
745
750
  entityRecommendationState: recommendationReducer_1.default,
746
751
  expenseAutomationFluxAnalysisViewState: fluxAnalysisViewReducer_1.default,
752
+ expenseAutomationActualMatchingViewState: actualMatchingViewReducer_1.default,
747
753
  expenseAutomationJESchedulesViewState: jeSchedulesViewReducer_1.default,
748
754
  expenseAutomationMissingReceiptsViewState: missingReceiptsViewReducer_1.default,
749
755
  expenseAutomationReconciliationViewState: reconciliationViewReducer_1.default,
@@ -41,6 +41,7 @@ import { InvoicingSubscriptionState } from './entity/invoicing/invoicingSubscrip
41
41
  import { InvoicingTransactionState } from './entity/invoicing/invoicingTransaction/invoicingTransactionState';
42
42
  import { InvoicingPlanState } from './entity/invoicing/plan/planState';
43
43
  import { InvoicingProductState } from './entity/invoicing/product/productState';
44
+ import { ActualMatchingState } from './entity/actualMatching/actualMatchingState';
44
45
  import { JESchedulesState } from './entity/jeSchedules/jeSchedulesState';
45
46
  import { MerchantState } from './entity/merchant/merchant';
46
47
  import { MonthEndCloseChecksState } from './entity/monthEndCloseChecks/monthEndCloseChecksState';
@@ -116,6 +117,7 @@ import { CreditAgentViewState } from './view/creditAgentView/creditAgentViewStat
116
117
  import { DashboardState } from './view/dashboard/dashboardState';
117
118
  import { DashboardLayoutState } from './view/dashboardLayout/dashboardLayoutState';
118
119
  import { ExpenseAutomationViewState } from './view/expenseAutomationView/expenseAutomationViewState';
120
+ import { ActualMatchingViewState as ExpenseAutomationActualMatchingViewState } from './view/expenseAutomationView/types/actualMatchingViewState';
119
121
  import { FluxAnalysisViewState as ExpenseAutomationFluxAnalysisViewState } from './view/expenseAutomationView/types/fluxAnalysisViewState';
120
122
  import { JESchedulesViewState as ExpenseAutomationJESchedulesViewState } from './view/expenseAutomationView/types/jeSchedulesViewState';
121
123
  import { MissingReceiptsViewState as ExpenseAutomationMissingReceiptsViewState } from './view/expenseAutomationView/types/missingReceiptsViewState';
@@ -275,6 +277,7 @@ export type EntitiesState = {
275
277
  accountingSummaryState: AccountingSummaryState;
276
278
  accountReconState: AccountReconState;
277
279
  accountState: AccountState;
280
+ actualMatchingState: ActualMatchingState;
278
281
  addressState: AddressState;
279
282
  aiAccountantCustomerState: AiAccountantCustomerState;
280
283
  aiCfoState: AiCfoState;
@@ -421,6 +424,7 @@ export type ViewsState = {
421
424
  editRemiDetailViewState: EditRemiDetailViewState;
422
425
  entityAutoCompleteState: EntityAutoCompleteState;
423
426
  entityRecommendationState: EntityRecommendationState;
427
+ expenseAutomationActualMatchingViewState: ExpenseAutomationActualMatchingViewState;
424
428
  expenseAutomationFluxAnalysisViewState: ExpenseAutomationFluxAnalysisViewState;
425
429
  expenseAutomationJESchedulesViewState: ExpenseAutomationJESchedulesViewState;
426
430
  expenseAutomationMissingReceiptsViewState: ExpenseAutomationMissingReceiptsViewState;
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateActualMatchingMatches } from '../../../../entity/actualMatching/actualMatchingReducer';
4
+ import { clearAll } from '../../../../rootActions';
5
+ import { RootState } from '../../../../rootStateTypes';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { fetchActualMatching, fetchActualMatchingFailure, fetchActualMatchingSuccess } from '../../reducers/actualMatchingViewReducer';
8
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof fetchActualMatching> | ReturnType<typeof fetchActualMatchingFailure> | ReturnType<typeof fetchActualMatchingSuccess> | ReturnType<typeof updateActualMatchingMatches>;
9
+ export declare const fetchActualMatchingEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchActualMatchingEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const actualMatchingReducer_1 = require("../../../../entity/actualMatching/actualMatchingReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const rootActions_1 = require("../../../../rootActions");
9
+ const actualMatchingPayload_1 = require("../../payload/actualMatchingPayload");
10
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
11
+ const actualMatchingViewSelector_1 = require("../../selectors/actualMatchingViewSelector");
12
+ const fetchActualMatchingEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.fetchActualMatching.match), (0, operators_1.switchMap)((action) => {
13
+ const state = state$.value;
14
+ const { period, refreshViewInBackground } = action.payload;
15
+ const selectedPeriod = (0, actualMatchingViewSelector_1.getSelectedMonthYearForCurrentTenant)(state) ?? {
16
+ month: period.start.month,
17
+ year: period.start.year,
18
+ };
19
+ const serviceMonth = (0, actualMatchingPayload_1.toServiceMonthFromPeriod)(period);
20
+ return zeniAPI
21
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/actual-matching?service_month=${encodeURIComponent(serviceMonth)}`)
22
+ .pipe((0, operators_1.mergeMap)((response) => {
23
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
24
+ const matches = response.data.matches;
25
+ const updateActions = [];
26
+ if (matches.length > 0) {
27
+ updateActions.push((0, actualMatchingReducer_1.updateActualMatchingMatches)(matches, (0, actualMatchingViewSelector_1.getTenantDisplayCurrency)(state)));
28
+ }
29
+ updateActions.push((0, actualMatchingViewReducer_1.fetchActualMatchingSuccess)({
30
+ matchIds: matches.map((match) => match.match_id),
31
+ selectedPeriod,
32
+ refreshViewInBackground,
33
+ }));
34
+ return (0, rxjs_1.from)(updateActions);
35
+ }
36
+ return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.fetchActualMatchingFailure)({
37
+ status: response.status,
38
+ selectedPeriod,
39
+ refreshViewInBackground,
40
+ }));
41
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, actualMatchingViewReducer_1.fetchActualMatchingFailure)({
42
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch actual matching REST API call errored out' +
43
+ JSON.stringify(error)),
44
+ selectedPeriod,
45
+ refreshViewInBackground,
46
+ }))), (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
47
+ }));
48
+ exports.fetchActualMatchingEpic = fetchActualMatchingEpic;
@@ -0,0 +1,12 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { ActualMatchingMatchPayload } from '../../../../entity/actualMatching/actualMatchingPayload';
4
+ import { updateActualMatchingMatches } from '../../../../entity/actualMatching/actualMatchingReducer';
5
+ import { ZeniAPIResponse } from '../../../../responsePayload';
6
+ import { clearAll } from '../../../../rootActions';
7
+ import { RootState } from '../../../../rootStateTypes';
8
+ import { ZeniAPI } from '../../../../zeniAPI';
9
+ import { fetchActualMatchingMatch, fetchActualMatchingMatchFailure, fetchActualMatchingMatchSuccess } from '../../reducers/actualMatchingViewReducer';
10
+ export type ActualMatchingMatchResponse = ZeniAPIResponse<ActualMatchingMatchPayload>;
11
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof fetchActualMatchingMatch> | ReturnType<typeof fetchActualMatchingMatchFailure> | ReturnType<typeof fetchActualMatchingMatchSuccess> | ReturnType<typeof updateActualMatchingMatches>;
12
+ export declare const fetchActualMatchingMatchEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchActualMatchingMatchEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const actualMatchingReducer_1 = require("../../../../entity/actualMatching/actualMatchingReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const rootActions_1 = require("../../../../rootActions");
9
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
10
+ const actualMatchingViewSelector_1 = require("../../selectors/actualMatchingViewSelector");
11
+ const fetchActualMatchingMatchEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.fetchActualMatchingMatch.match), (0, operators_1.mergeMap)((action) => {
12
+ const { matchId, refreshViewInBackground } = action.payload;
13
+ return zeniAPI
14
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/actual-matching/${encodeURIComponent(matchId)}`)
15
+ .pipe((0, operators_1.mergeMap)((response) => {
16
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
17
+ return (0, rxjs_1.from)([
18
+ (0, actualMatchingReducer_1.updateActualMatchingMatches)([response.data], (0, actualMatchingViewSelector_1.getTenantDisplayCurrency)(state$.value)),
19
+ (0, actualMatchingViewReducer_1.fetchActualMatchingMatchSuccess)({
20
+ matchId,
21
+ refreshViewInBackground,
22
+ }),
23
+ ]);
24
+ }
25
+ return (0, rxjs_1.from)([
26
+ (0, actualMatchingViewReducer_1.fetchActualMatchingMatchFailure)({
27
+ matchId,
28
+ refreshViewInBackground,
29
+ status: response.status,
30
+ }),
31
+ ]);
32
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
33
+ (0, actualMatchingViewReducer_1.fetchActualMatchingMatchFailure)({
34
+ matchId,
35
+ refreshViewInBackground,
36
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Fetch actual matching match REST API call errored out ${JSON.stringify(error)}`),
37
+ }),
38
+ ])), (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
39
+ }));
40
+ exports.fetchActualMatchingMatchEpic = fetchActualMatchingMatchEpic;
@@ -0,0 +1,5 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { fetchActualMatching, fetchActualMatchingPage } from '../../reducers/actualMatchingViewReducer';
4
+ export type ActionType = ReturnType<typeof fetchActualMatching> | ReturnType<typeof fetchActualMatchingPage>;
5
+ export declare const fetchActualMatchingPageEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchActualMatchingPageEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
7
+ const fetchActualMatchingPageEpic = (actions$) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.fetchActualMatchingPage.match), (0, operators_1.mergeMap)((action) => {
8
+ const { period, refreshViewInBackground } = action.payload;
9
+ return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.fetchActualMatching)(period, refreshViewInBackground));
10
+ }));
11
+ exports.fetchActualMatchingPageEpic = fetchActualMatchingPageEpic;
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
+ import { clearAll } from '../../../../rootActions';
5
+ import { RootState } from '../../../../rootStateTypes';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { clearMatchNewModal, fetchActualMatching, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess } from '../../reducers/actualMatchingViewReducer';
8
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof clearMatchNewModal> | ReturnType<typeof fetchActualMatching> | ReturnType<typeof matchAndReverseAccruals> | ReturnType<typeof matchAndReverseAccrualsFailure> | ReturnType<typeof matchAndReverseAccrualsSuccess> | ReturnType<typeof openSnackbar>;
9
+ export declare const matchAndReverseAccrualsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchAndReverseAccrualsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const actualMatchingSelector_1 = require("../../../../entity/actualMatching/actualMatchingSelector");
7
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
8
+ const responsePayload_1 = require("../../../../responsePayload");
9
+ const rootActions_1 = require("../../../../rootActions");
10
+ const actualMatchingPayload_1 = require("../../payload/actualMatchingPayload");
11
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
12
+ const refreshActualMatchingList_1 = require("./refreshActualMatchingList");
13
+ function isMatchCompleteStatus(status) {
14
+ return status === 'reversed' || status === 'noop';
15
+ }
16
+ function isMatchFailedStatus(status) {
17
+ return (status === 'conflict' || status === 'claim_lost' || status === 'error');
18
+ }
19
+ function matchAndReverseSnackbar(results, vendorName) {
20
+ const reversedCount = results.filter((result) => result.status === 'reversed').length;
21
+ const failedCount = results.filter((result) => isMatchFailedStatus(result.status)).length;
22
+ const variables = [
23
+ { variableName: '_count_', variableValue: String(reversedCount) },
24
+ { variableName: '_vendor_name_', variableValue: vendorName },
25
+ ];
26
+ if (results.length === 0 || (reversedCount === 0 && failedCount > 0)) {
27
+ return (0, snackbarReducer_1.openSnackbar)({
28
+ messageSection: 'actual_matching_match_and_reverse',
29
+ messageText: 'failed',
30
+ type: 'error',
31
+ variables,
32
+ });
33
+ }
34
+ if (reversedCount > 0 && failedCount === 0) {
35
+ return (0, snackbarReducer_1.openSnackbar)({
36
+ messageSection: 'actual_matching_match_and_reverse',
37
+ messageText: 'success',
38
+ type: 'success',
39
+ variables,
40
+ });
41
+ }
42
+ if (reversedCount > 0 && failedCount > 0) {
43
+ return (0, snackbarReducer_1.openSnackbar)({
44
+ messageSection: 'actual_matching_match_and_reverse',
45
+ messageText: 'notification',
46
+ type: 'warning',
47
+ variables,
48
+ });
49
+ }
50
+ return null;
51
+ }
52
+ function matchAndReverseHttpFailSnackbar(vendorName) {
53
+ return (0, snackbarReducer_1.openSnackbar)({
54
+ messageSection: 'actual_matching_match_and_reverse',
55
+ messageText: 'failed',
56
+ type: 'error',
57
+ variables: [
58
+ { variableName: '_count_', variableValue: '0' },
59
+ { variableName: '_vendor_name_', variableValue: vendorName },
60
+ ],
61
+ });
62
+ }
63
+ function matchVendorName(state, matchId) {
64
+ return (0, actualMatchingSelector_1.getActualMatchingMatchById)(state.actualMatchingState, matchId)?.vendorName ?? '';
65
+ }
66
+ const matchAndReverseAccrualsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.matchAndReverseAccruals.match),
67
+ // Posts reversing JEs; drop duplicate clicks while a request is in flight.
68
+ (0, operators_1.exhaustMap)((action) => {
69
+ const { transactionId, transactionIntegrationId, transactionType, lineIds, accrualIds, transactionSyncToken, } = action.payload;
70
+ const body = {
71
+ transaction_id: transactionId,
72
+ transaction_integration_id: transactionIntegrationId,
73
+ transaction_type: transactionType,
74
+ line_ids: lineIds,
75
+ transaction_sync_token: transactionSyncToken,
76
+ accrual_ids: accrualIds,
77
+ };
78
+ // Key leftover results and snackbar vendor to the confirmed bill, not the
79
+ // row Match New was opened from (user can pick a different txn).
80
+ const matchId = `${transactionType.toLowerCase()}:${transactionIntegrationId}`;
81
+ const vendorName = matchVendorName(state$.value, matchId);
82
+ return zeniAPI
83
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/match-and-reverse`, body)
84
+ .pipe((0, operators_1.mergeMap)((response) => {
85
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
86
+ const results = response.data.results.map(actualMatchingPayload_1.toMatchAndReverseResult);
87
+ const successActions = [
88
+ (0, actualMatchingViewReducer_1.matchAndReverseAccrualsSuccess)({ matchId, results }),
89
+ ];
90
+ const occupancyChanged = results.some((result) => isMatchCompleteStatus(result.status));
91
+ const allComplete = results.length > 0 &&
92
+ results.every((result) => isMatchCompleteStatus(result.status));
93
+ if (occupancyChanged) {
94
+ successActions.push(...(0, refreshActualMatchingList_1.refreshActualMatchingList)(state$.value));
95
+ }
96
+ const snackbar = matchAndReverseSnackbar(results, vendorName);
97
+ if (snackbar != null) {
98
+ successActions.push(snackbar);
99
+ }
100
+ if (allComplete) {
101
+ successActions.push((0, actualMatchingViewReducer_1.clearMatchNewModal)());
102
+ }
103
+ return (0, rxjs_1.from)(successActions);
104
+ }
105
+ return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.matchAndReverseAccrualsFailure)({ status: response.status }), matchAndReverseHttpFailSnackbar(vendorName));
106
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, actualMatchingViewReducer_1.matchAndReverseAccrualsFailure)({
107
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Match and reverse accruals REST API call errored out' +
108
+ JSON.stringify(error)),
109
+ }), matchAndReverseHttpFailSnackbar(vendorName))), (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
110
+ }));
111
+ exports.matchAndReverseAccrualsEpic = matchAndReverseAccrualsEpic;
@@ -0,0 +1,3 @@
1
+ import { RootState } from '../../../../rootStateTypes';
2
+ import { fetchActualMatching } from '../../reducers/actualMatchingViewReducer';
3
+ export declare function refreshActualMatchingList(state: RootState): ReturnType<typeof fetchActualMatching>[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refreshActualMatchingList = refreshActualMatchingList;
4
+ const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
5
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
6
+ const actualMatchingViewSelector_1 = require("../../selectors/actualMatchingViewSelector");
7
+ function refreshActualMatchingList(state) {
8
+ const selectedMonthYear = (0, actualMatchingViewSelector_1.getSelectedMonthYearForCurrentTenant)(state);
9
+ if (selectedMonthYear == null) {
10
+ return [];
11
+ }
12
+ const period = (0, timePeriod_1.convertToPeriod)(selectedMonthYear);
13
+ const start = (0, timePeriod_1.toAbsoluteDay)(period.start);
14
+ const end = (0, timePeriod_1.toAbsoluteDay)(period.end);
15
+ if (start == null || end == null) {
16
+ return [];
17
+ }
18
+ return [(0, actualMatchingViewReducer_1.fetchActualMatching)({ start, end }, true)];
19
+ }
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
+ import { clearAll } from '../../../../rootActions';
5
+ import { RootState } from '../../../../rootStateTypes';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { searchMatchAccruals, searchMatchAccrualsFailure, searchMatchAccrualsSuccess } from '../../reducers/actualMatchingViewReducer';
8
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof searchMatchAccruals> | ReturnType<typeof searchMatchAccrualsFailure> | ReturnType<typeof searchMatchAccrualsSuccess> | ReturnType<typeof updateJEOneTimeAccruals>;
9
+ export declare const searchMatchAccrualsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchMatchAccrualsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const actualMatchingPayload_1 = require("../../../../entity/actualMatching/actualMatchingPayload");
7
+ const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
8
+ const responsePayload_1 = require("../../../../responsePayload");
9
+ const rootActions_1 = require("../../../../rootActions");
10
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
11
+ const actualMatchingViewSelector_1 = require("../../selectors/actualMatchingViewSelector");
12
+ const actualMatchingViewState_1 = require("../../types/actualMatchingViewState");
13
+ const searchMatchAccrualsEpic = (actions$, state$, zeniAPI) => {
14
+ const searchActions$ = actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.searchMatchAccruals.match));
15
+ const pagination$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken != null));
16
+ const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken == null), (0, operators_1.debounceTime)(actualMatchingViewState_1.MATCH_SEARCH_DEBOUNCE_MS));
17
+ return (0, rxjs_1.merge)(pagination$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
18
+ const { query, pageToken } = action.payload;
19
+ const offset = pageToken != null && pageToken.length > 0 ? Number(pageToken) : 0;
20
+ const searchText = encodeURIComponent(query);
21
+ const limit = actualMatchingViewState_1.MATCH_ACCRUAL_SEARCH_LIMIT;
22
+ return zeniAPI
23
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals?status=posted&reversal_policy=on_bill_match&search_text=${searchText}&limit=${limit}&offset=${offset}`)
24
+ .pipe((0, operators_1.mergeMap)((response) => {
25
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
26
+ const accruals = response.data.accruals;
27
+ const append = pageToken != null;
28
+ const nextOffset = offset + accruals.length;
29
+ const total = response.data.total ?? nextOffset;
30
+ const nextPageToken = nextOffset < total ? String(nextOffset) : null;
31
+ // toJEOneTimeAccrual still defaults a missing code to USD. Stamp
32
+ // tenant currency first, same as list members.
33
+ const fallbackCurrencyCode = (0, actualMatchingViewSelector_1.getTenantDisplayCurrency)(state$.value)?.currencyCode ?? '';
34
+ const stampedAccruals = accruals.map((accrual) => (0, actualMatchingPayload_1.withInheritedAccrualCurrency)(accrual, fallbackCurrencyCode));
35
+ const actionsOut = [];
36
+ if (stampedAccruals.length > 0) {
37
+ actionsOut.push((0, jeSchedulesReducer_1.updateJEOneTimeAccruals)(stampedAccruals));
38
+ }
39
+ actionsOut.push((0, actualMatchingViewReducer_1.searchMatchAccrualsSuccess)({
40
+ append,
41
+ nextPageToken,
42
+ results: stampedAccruals,
43
+ }));
44
+ return (0, rxjs_1.from)(actionsOut);
45
+ }
46
+ return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.searchMatchAccrualsFailure)({
47
+ error: response.status,
48
+ }));
49
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, actualMatchingViewReducer_1.searchMatchAccrualsFailure)({
50
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search match accruals REST API call errored out' +
51
+ JSON.stringify(error)),
52
+ }))),
53
+ // On the HTTP stream only. Wrapping the outer merge would complete
54
+ // the epic on the first `clearAll` and drop later searches.
55
+ (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
56
+ }));
57
+ };
58
+ exports.searchMatchAccrualsEpic = searchMatchAccrualsEpic;
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { clearAll } from '../../../../rootActions';
4
+ import { RootState } from '../../../../rootStateTypes';
5
+ import { ZeniAPI } from '../../../../zeniAPI';
6
+ import { openMatchNewModal, searchMatchAccruals, searchMatchTransactions, searchMatchTransactionsFailure, searchMatchTransactionsSuccess } from '../../reducers/actualMatchingViewReducer';
7
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof openMatchNewModal> | ReturnType<typeof searchMatchAccruals> | ReturnType<typeof searchMatchTransactions> | ReturnType<typeof searchMatchTransactionsFailure> | ReturnType<typeof searchMatchTransactionsSuccess>;
8
+ export declare const searchMatchTransactionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchMatchTransactionsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const actualMatchingSelector_1 = require("../../../../entity/actualMatching/actualMatchingSelector");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const rootActions_1 = require("../../../../rootActions");
9
+ const actualMatchingPayload_1 = require("../../payload/actualMatchingPayload");
10
+ const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
11
+ const actualMatchingViewSelector_1 = require("../../selectors/actualMatchingViewSelector");
12
+ const actualMatchingViewState_1 = require("../../types/actualMatchingViewState");
13
+ const searchMatchTransactionsEpic = (actions$, state$, zeniAPI) => {
14
+ const openModal$ = actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.openMatchNewModal.match), (0, operators_1.mergeMap)((action) => {
15
+ const matchId = action.payload.matchId;
16
+ if (matchId == null || matchId === '') {
17
+ return (0, rxjs_1.from)([
18
+ (0, actualMatchingViewReducer_1.searchMatchTransactions)(''),
19
+ (0, actualMatchingViewReducer_1.searchMatchAccruals)(''),
20
+ ]);
21
+ }
22
+ const match = (0, actualMatchingSelector_1.getActualMatchingMatchById)(state$.value.actualMatchingState, matchId);
23
+ const parsed = (0, actualMatchingViewSelector_1.parseActualMatchingMatchId)(matchId);
24
+ const transactionType = match?.transactionType != null && match.transactionType !== ''
25
+ ? match.transactionType
26
+ : parsed?.transactionType;
27
+ const transactionIntegrationId = match?.transactionIntegrationId != null &&
28
+ match.transactionIntegrationId !== ''
29
+ ? match.transactionIntegrationId
30
+ : parsed?.transactionIntegrationId;
31
+ return (0, rxjs_1.from)([
32
+ (0, actualMatchingViewReducer_1.searchMatchTransactions)('', undefined, transactionType, transactionIntegrationId),
33
+ ]);
34
+ }));
35
+ const searchActions$ = actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.searchMatchTransactions.match));
36
+ const pagination$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken != null));
37
+ const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.pageToken == null), (0, operators_1.debounceTime)(actualMatchingViewState_1.MATCH_SEARCH_DEBOUNCE_MS));
38
+ const search$ = (0, rxjs_1.merge)(pagination$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
39
+ const { query, pageToken, transactionType, transactionIntegrationId } = action.payload;
40
+ const queryParam = {
41
+ search_text: query,
42
+ page_size: actualMatchingViewState_1.MATCH_TRANSACTION_SEARCH_PAGE_SIZE,
43
+ ...(pageToken != null ? { page_token: pageToken } : {}),
44
+ ...(transactionType != null && transactionType !== ''
45
+ ? { transaction_type: transactionType }
46
+ : {}),
47
+ ...(transactionIntegrationId != null && transactionIntegrationId !== ''
48
+ ? { transaction_integration_id: transactionIntegrationId }
49
+ : {}),
50
+ };
51
+ return zeniAPI
52
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/match-transaction-search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
53
+ .pipe((0, operators_1.mergeMap)((response) => {
54
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
55
+ const { transactions, next_page_token } = response.data;
56
+ const append = pageToken != null;
57
+ const fallbackCurrency = (0, actualMatchingViewSelector_1.getTenantDisplayCurrency)(state$.value);
58
+ const results = transactions.map((transaction) => (0, actualMatchingPayload_1.toActualMatchingTransactionSearchResult)(transaction, fallbackCurrency));
59
+ return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.searchMatchTransactionsSuccess)({
60
+ append,
61
+ nextPageToken: next_page_token ?? null,
62
+ results,
63
+ }));
64
+ }
65
+ return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.searchMatchTransactionsFailure)({
66
+ error: response.status,
67
+ }));
68
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, actualMatchingViewReducer_1.searchMatchTransactionsFailure)({
69
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search match transactions REST API call errored out' +
70
+ JSON.stringify(error)),
71
+ }))),
72
+ // On the HTTP stream only. Wrapping `merge(openModal$, search$)`
73
+ // would complete the epic on the first `clearAll` and drop later searches.
74
+ (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
75
+ }));
76
+ return (0, rxjs_1.merge)(openModal$, search$);
77
+ };
78
+ exports.searchMatchTransactionsEpic = searchMatchTransactionsEpic;
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
+ import { clearAll } from '../../../../rootActions';
5
+ import { RootState } from '../../../../rootStateTypes';
6
+ import { ZeniAPI } from '../../../../zeniAPI';
7
+ import { fetchActualMatching, fetchActualMatchingMatch, undoReversalAccruals, undoReversalAccrualsFailure, undoReversalAccrualsSuccess } from '../../reducers/actualMatchingViewReducer';
8
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof fetchActualMatching> | ReturnType<typeof fetchActualMatchingMatch> | ReturnType<typeof openSnackbar> | ReturnType<typeof undoReversalAccruals> | ReturnType<typeof undoReversalAccrualsFailure> | ReturnType<typeof undoReversalAccrualsSuccess>;
9
+ export declare const undoReversalAccrualsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;