@zeniai/client-epic-state 5.2.11-beta0ND → 5.2.11-betaAM2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +29 -27
  2. package/lib/entity/invoicing/invoicingCommonPayload.js +75 -37
  3. package/lib/entity/invoicing/product/productPayload.d.ts +0 -10
  4. package/lib/entity/invoicing/product/productPayload.js +2 -14
  5. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
  6. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  7. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +97 -1
  8. package/lib/entity/jeSchedules/jeSchedulesPayload.js +209 -0
  9. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  10. package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  11. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  12. package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
  13. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +140 -1
  14. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  15. package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
  16. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  17. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  18. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  19. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  20. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  21. package/lib/epic.d.ts +15 -3
  22. package/lib/epic.js +31 -12
  23. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +73 -33
  24. package/lib/esm/entity/invoicing/product/productPayload.js +2 -14
  25. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  26. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +209 -1
  27. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  28. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
  29. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
  30. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  31. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  32. package/lib/esm/epic.js +27 -8
  33. package/lib/esm/index.js +23 -14
  34. package/lib/esm/reducer.js +3 -0
  35. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +46 -0
  36. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +7 -0
  37. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +50 -0
  38. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +44 -0
  39. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +44 -0
  40. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
  41. package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  43. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  44. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
  45. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  46. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +104 -0
  47. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  48. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +136 -0
  49. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
  50. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +180 -0
  51. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
  52. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +33 -0
  53. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
  54. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  55. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +35 -0
  56. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  57. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +260 -0
  58. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +319 -29
  59. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
  60. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +162 -0
  61. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  62. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  63. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +297 -22
  64. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +22 -0
  65. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -5
  66. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
  67. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
  68. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +0 -40
  69. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +92 -0
  70. package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -25
  71. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +0 -41
  72. package/lib/esm/view/recommendation/recommendationReducer.js +1 -16
  73. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  74. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  75. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  76. package/lib/index.d.ts +29 -22
  77. package/lib/index.js +116 -56
  78. package/lib/reducer.d.ts +1 -0
  79. package/lib/reducer.js +3 -0
  80. package/lib/rootStateTypes.d.ts +2 -0
  81. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
  82. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +50 -0
  83. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
  84. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +11 -0
  85. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +8 -0
  86. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +54 -0
  87. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +8 -0
  88. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +48 -0
  89. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
  90. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +48 -0
  91. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
  92. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
  93. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
  94. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
  95. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  96. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  97. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
  98. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +21 -0
  99. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
  100. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  101. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +9 -0
  102. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -0
  103. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  104. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
  105. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +9 -0
  106. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +140 -0
  107. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  108. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
  109. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +13 -0
  110. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +187 -0
  111. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
  112. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
  113. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +7 -0
  114. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +37 -0
  115. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
  116. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  117. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  118. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  119. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +66 -0
  120. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +40 -0
  121. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +86 -3
  122. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  123. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +53 -0
  124. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +264 -0
  125. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +93 -12
  126. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +321 -29
  127. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  128. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  129. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +58 -0
  130. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +2 -0
  131. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
  132. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  133. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
  134. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
  135. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +9 -0
  136. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +172 -0
  137. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  138. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  139. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  140. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
  141. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +305 -21
  142. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +76 -0
  143. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +27 -0
  144. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  145. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
  146. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +11 -7
  147. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +2 -2
  148. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +1 -12
  149. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
  150. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
  151. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +1 -10
  152. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +1 -43
  153. package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +12 -0
  154. package/lib/view/invoicing/settingsView/settingsViewEpics.js +99 -0
  155. package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +1 -4
  156. package/lib/view/invoicing/settingsView/settingsViewReducer.js +2 -26
  157. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +0 -35
  158. package/lib/view/invoicing/settingsView/settingsViewSelector.js +1 -43
  159. package/lib/view/invoicing/settingsView/settingsViewState.d.ts +0 -8
  160. package/lib/view/recommendation/recommendationPayload.d.ts +0 -34
  161. package/lib/view/recommendation/recommendationReducer.d.ts +1 -2
  162. package/lib/view/recommendation/recommendationReducer.js +2 -17
  163. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  164. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  165. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
  166. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  167. package/package.json +1 -1
  168. package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -27
  169. package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -19
  170. package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -19
  171. package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -39
  172. package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -25
  173. package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -48
  174. package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +0 -52
  175. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +0 -6
  176. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -31
  177. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +0 -6
  178. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -23
  179. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +0 -6
  180. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -23
  181. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +0 -6
  182. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -43
  183. package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +0 -5
  184. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +0 -11
  185. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -29
  186. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +0 -34
  187. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -53
  188. package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +0 -7
  189. package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +0 -56
  190. /package/lib/esm/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js} +0 -0
  191. /package/lib/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js} +0 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchOneTimeAccrualEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
7
+ const responsePayload_1 = require("../../../../responsePayload");
8
+ const rootActions_1 = require("../../../../rootActions");
9
+ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
10
+ /**
11
+ * Read one accrual by id so its detail page can render from a URL alone.
12
+ *
13
+ * Every other row on this page arrives with the JE Schedules list, and the accrual detail page used
14
+ * to render only from what that list had already put in the store -- so opening its URL directly, on
15
+ * a refresh or a shared link, had nothing to render and showed not-found. This is the read that
16
+ * makes the URL self-sufficient.
17
+ *
18
+ * The response is the same `{accrual}` envelope promote / ignore / revert return, and it goes through
19
+ * the same `updateJEOneTimeAccruals`, so a page loaded cold holds exactly the entity a page reached
20
+ * through the list holds.
21
+ */
22
+ const fetchOneTimeAccrualEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.fetchOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
23
+ const { accrualId } = action.payload;
24
+ return zeniAPI
25
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`)
26
+ .pipe((0, operators_1.mergeMap)((response) => {
27
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
28
+ return (0, rxjs_1.from)([
29
+ (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
30
+ (0, jeSchedulesViewReducer_1.fetchOneTimeAccrualSuccess)({ accrualId }),
31
+ ]);
32
+ }
33
+ // A deleted or ignored accrual answers 404 here, the same as an id that never existed.
34
+ // Both end as an error state the page turns into not-found, rather than a spinner that
35
+ // never resolves.
36
+ return (0, rxjs_1.from)([
37
+ (0, jeSchedulesViewReducer_1.fetchOneTimeAccrualFailure)({ accrualId, status: response.status }),
38
+ ]);
39
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
40
+ (0, jeSchedulesViewReducer_1.fetchOneTimeAccrualFailure)({
41
+ accrualId,
42
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Fetch one-time accrual REST API call errored out ${JSON.stringify(error)}`),
43
+ }),
44
+ ])),
45
+ // A tenant switch clears the store while this request is in flight. Without this the old
46
+ // tenant's accrual is written back into the freshly cleared store.
47
+ (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
48
+ }));
49
+ exports.fetchOneTimeAccrualEpic = fetchOneTimeAccrualEpic;
@@ -14,13 +14,25 @@ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer"
14
14
  const ignoreRecommendedJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.ignoreRecommendedJeSchedule.match), (0, operators_1.mergeMap)((action) => {
15
15
  const state = state$.value;
16
16
  const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
17
- const { scheduleType, jeScheduleTransactionKey } = action.payload;
17
+ const { scheduleType, jeScheduleTransactionKey, reason, note } = action.payload;
18
18
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
19
19
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
20
20
  const actions = [];
21
21
  const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleTransactionKey, state);
22
+ const ignorePayload = (0, jeSchedulesPayload_1.prepareIgnoreSchedulePayload)(scheduleType, jeScheduleTransactionState, state);
23
+ // The gateway reads reason/note from je_schedules[0].feedback and nowhere else, and rejects
24
+ // anything but those two keys inside it — `action` is stamped server-side.
22
25
  const payload = {
23
- ...(0, jeSchedulesPayload_1.prepareIgnoreSchedulePayload)(scheduleType, jeScheduleTransactionState, state),
26
+ ...ignorePayload,
27
+ je_schedules: ignorePayload.je_schedules.map((schedule, index) => index === 0
28
+ ? {
29
+ ...schedule,
30
+ feedback: {
31
+ reason,
32
+ ...(note != null && note !== '' ? { note } : {}),
33
+ },
34
+ }
35
+ : schedule),
24
36
  };
25
37
  const queryParam = {
26
38
  je_schedule_type: scheduleType,
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { updateJEOneTimeAccruals } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
3
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { clearAll } from '../../../../../rootActions';
6
+ import { ZeniAPI } from '../../../../../zeniAPI';
7
+ import { createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedules } from '../../../reducers/jeSchedulesViewReducer';
8
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof createOneTimeAccrual> | ReturnType<typeof createOneTimeAccrualSuccess> | ReturnType<typeof createOneTimeAccrualFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
9
+ export declare const createOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOneTimeAccrualEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const timePeriod_1 = require("../../../../../commonStateTypes/timePeriod");
7
+ const jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
8
+ const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
9
+ const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
10
+ const rootActions_1 = require("../../../../../rootActions");
11
+ const responsePayload_1 = require("../../../../../responsePayload");
12
+ const jeSchedulesPayload_1 = require("../../../payload/jeSchedulesPayload");
13
+ const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
14
+ const createOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.createOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
15
+ const state = state$.value;
16
+ const { localData } = action.payload;
17
+ /*
18
+ * Idempotency for the create. agent-je dedupes on this: the same key again returns the
19
+ * existing accrual rather than posting a second JE to QBO.
20
+ *
21
+ * Body `request_id` rather than the `Idempotency-Key` header the API doc prefers, on Mohit's
22
+ * call (2026-08-24). The header cannot reach the service from a browser -- common's
23
+ * Access-Control-Allow-Headers does not list it, so cross-origin preflight rejects the
24
+ * request. Same meaning either way; the header simply wins when both are sent.
25
+ *
26
+ * Minted here, per create action, and deliberately not held in local data or the form: a new
27
+ * Save must produce a new key, and only a retry of *this* request may reuse one. Nothing
28
+ * retries today -- if a retry operator is ever added below, it has to sit inside this
29
+ * mergeMap so the key is not re-minted, or the guarantee is silently lost.
30
+ */
31
+ const requestId = crypto.randomUUID();
32
+ const payload = {
33
+ ...(0, jeSchedulesPayload_1.prepareCreateOneTimeAccrualPayload)(state, localData),
34
+ request_id: requestId,
35
+ };
36
+ // convertToPeriod destructures, so an unset period would throw here and take the epic
37
+ // subscription down for the whole session — a missed refresh is the cheaper failure.
38
+ const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
39
+ const selectedPeriod = selectedMonthYear != null
40
+ ? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
41
+ : undefined;
42
+ const periodStart = selectedPeriod != null
43
+ ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
44
+ : undefined;
45
+ const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
46
+ return zeniAPI
47
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
48
+ .pipe((0, operators_1.mergeMap)((response) => {
49
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
50
+ const successActions = [
51
+ (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
52
+ (0, jeSchedulesViewReducer_1.createOneTimeAccrualSuccess)(),
53
+ (0, snackbarReducer_1.openSnackbar)({
54
+ messageSection: 'create_schedule',
55
+ messageText: 'success',
56
+ type: 'success',
57
+ variables: [
58
+ {
59
+ variableName: '_vendor_name_',
60
+ variableValue: localData.vendorName,
61
+ },
62
+ ],
63
+ }),
64
+ ];
65
+ // The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
66
+ // per fetch, and the backend decides whether a freshly posted accrual belongs to
67
+ // Review or Existing — so refetch rather than guess which bucket to insert into.
68
+ if (periodStart != null && periodEnd != null) {
69
+ successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
70
+ }
71
+ return (0, rxjs_1.from)(successActions);
72
+ }
73
+ return (0, rxjs_1.from)([
74
+ (0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({ status: response.status }),
75
+ (0, snackbarReducer_1.openSnackbar)({
76
+ messageSection: 'create_schedule',
77
+ messageText: 'failed',
78
+ type: 'error',
79
+ variables: [
80
+ {
81
+ variableName: '_api-error_',
82
+ variableValue: response.status.message,
83
+ },
84
+ ],
85
+ }),
86
+ ]);
87
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
88
+ (0, snackbarReducer_1.openSnackbar)({
89
+ messageSection: 'create_schedule',
90
+ messageText: 'failed',
91
+ type: 'error',
92
+ variables: [
93
+ {
94
+ variableName: '_api-error_',
95
+ variableValue: JSON.stringify(error),
96
+ },
97
+ ],
98
+ }),
99
+ (0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({
100
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
101
+ }),
102
+ ])),
103
+ // A tenant switch clears the store while this request is still in flight.
104
+ // Without this the old tenant's response is written back into the freshly
105
+ // cleared store and stays on screen under the new tenant.
106
+ (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
107
+ }));
108
+ exports.createOneTimeAccrualEpic = createOneTimeAccrualEpic;
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../../reducer';
4
+ import { fetchAccountList } from '../../../../accountList/accountListReducer';
5
+ import { fetchClassList } from '../../../../classList/classListReducer';
6
+ import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData } from '../../../reducers/jeSchedulesViewReducer';
7
+ export type ActionType = ReturnType<typeof clearSearchTransactionsForNewSchedule> | ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchClassList> | ReturnType<typeof initializeNewSchedule> | ReturnType<typeof resetNewScheduleLocalData>;
8
+ export declare const initializeNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeNewScheduleEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const accountListReducer_1 = require("../../../../accountList/accountListReducer");
7
+ const classListReducer_1 = require("../../../../classList/classListReducer");
8
+ const scheduleListHelper_1 = require("../../../../scheduleView/scheduleListView/scheduleListHelper");
9
+ const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
10
+ const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.initializeNewSchedule.match), (0, operators_1.mergeMap)((action) => {
11
+ const newScheduleActions = [];
12
+ const accountType = (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)();
13
+ const { accountListState, classListState } = state$.value;
14
+ if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
15
+ 'Not-Started') {
16
+ newScheduleActions.push((0, accountListReducer_1.fetchAccountList)(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
17
+ }
18
+ if (classListState.fetchState === 'Not-Started') {
19
+ newScheduleActions.push((0, classListReducer_1.fetchClassList)());
20
+ }
21
+ // The account and class fetches above are idempotent (both guard on 'Not-Started'), so they
22
+ // can run on every open. Clearing what the user entered cannot, so it is opt-in.
23
+ if (action.payload.shouldResetEnteredData) {
24
+ newScheduleActions.push((0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType: action.payload.scheduleType }));
25
+ newScheduleActions.push((0, jeSchedulesViewReducer_1.clearSearchTransactionsForNewSchedule)());
26
+ }
27
+ return (0, rxjs_1.from)(newScheduleActions);
28
+ }));
29
+ exports.initializeNewScheduleEpic = initializeNewScheduleEpic;
@@ -0,0 +1,9 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { clearAll } from '../../../../../rootActions';
3
+ import { updateJESchedules, updateJESchedulesDetails } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
4
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
+ import { RootState } from '../../../../../reducer';
6
+ import { ZeniAPI } from '../../../../../zeniAPI';
7
+ import { fetchJeSchedules, resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
8
+ export type ActionType = ReturnType<typeof saveNewSchedule> | ReturnType<typeof saveNewScheduleSuccess> | ReturnType<typeof saveNewScheduleFailure> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof resetNewScheduleLocalData> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof clearAll> | ReturnType<typeof openSnackbar>;
9
+ export declare const saveNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveNewScheduleEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const timePeriod_1 = require("../../../../../commonStateTypes/timePeriod");
7
+ const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
8
+ const rootActions_1 = require("../../../../../rootActions");
9
+ const jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
10
+ const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedulesTypes");
11
+ const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
12
+ const transactionSelector_1 = require("../../../../../entity/transaction/transactionSelector");
13
+ const responsePayload_1 = require("../../../../../responsePayload");
14
+ const newScheduleLocalDataHelper_1 = require("../../../helpers/newScheduleLocalDataHelper");
15
+ const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
16
+ const FAILURE_REASON_MESSAGES = {
17
+ missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
18
+ missing_vendor: 'Select a vendor before saving this schedule.',
19
+ };
20
+ const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.saveNewSchedule.match), (0, operators_1.mergeMap)((action) => {
21
+ const { scheduleType } = action.payload;
22
+ const state = state$.value;
23
+ const localData = state.expenseAutomationJESchedulesViewState.newSchedule
24
+ .newScheduleState[scheduleType];
25
+ const { selectedBaseTransactionId } = localData;
26
+ const transaction = selectedBaseTransactionId != null
27
+ ? (0, transactionSelector_1.getScheduleTransactionById)(state.transactionState, (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)(selectedBaseTransactionId))
28
+ : undefined;
29
+ if (transaction == null) {
30
+ return (0, rxjs_1.from)([
31
+ (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
32
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No base transaction selected for this schedule.'),
33
+ }),
34
+ (0, snackbarReducer_1.openSnackbar)({
35
+ messageSection: 'create_schedule',
36
+ messageText: 'failed',
37
+ type: 'error',
38
+ variables: [
39
+ {
40
+ variableName: '_api-error_',
41
+ variableValue: 'No base transaction selected.',
42
+ },
43
+ ],
44
+ }),
45
+ ]);
46
+ }
47
+ const result = (0, newScheduleLocalDataHelper_1.prepareNewSchedulePayload)(transaction, localData, scheduleType);
48
+ if (!result.ok) {
49
+ const message = FAILURE_REASON_MESSAGES[result.reason];
50
+ return (0, rxjs_1.from)([
51
+ (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
52
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', message),
53
+ }),
54
+ (0, snackbarReducer_1.openSnackbar)({
55
+ messageSection: 'create_schedule',
56
+ messageText: 'failed',
57
+ type: 'error',
58
+ variables: [{ variableName: '_api-error_', variableValue: message }],
59
+ }),
60
+ ]);
61
+ }
62
+ const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
63
+ const queryParam = {
64
+ je_schedule_type: scheduleType,
65
+ };
66
+ const payload = { ...result.payload };
67
+ // convertToPeriod destructures, so an unset period would throw here and take the epic
68
+ // subscription down for the whole session -- a missed refresh is the cheaper failure.
69
+ const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
70
+ const selectedPeriod = selectedMonthYear != null
71
+ ? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
72
+ : undefined;
73
+ const periodStart = selectedPeriod != null
74
+ ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
75
+ : undefined;
76
+ const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
77
+ return zeniAPI
78
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
79
+ .pipe((0, operators_1.mergeMap)((response) => {
80
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
81
+ const successActions = [
82
+ (0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules),
83
+ (0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries),
84
+ (0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType }),
85
+ (0, jeSchedulesViewReducer_1.saveNewScheduleSuccess)(),
86
+ (0, snackbarReducer_1.openSnackbar)({
87
+ messageSection: 'create_schedule',
88
+ messageText: 'success',
89
+ type: 'success',
90
+ variables: [
91
+ { variableName: '_vendor_name_', variableValue: vendorName },
92
+ ],
93
+ }),
94
+ ];
95
+ // Writing the entity is not enough: the list reads
96
+ // jeScheduleTransactionKeysByPeriodAndTab, which is rebuilt wholesale per fetch, so
97
+ // without this the new schedule stays invisible until some later fetch. The page
98
+ // only refetches when the save also changes tab, so saving from the tab the row
99
+ // lands on showed nothing. Same reasoning as createOneTimeAccrualEpic.
100
+ if (periodStart != null && periodEnd != null) {
101
+ successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
102
+ }
103
+ return (0, rxjs_1.from)(successActions);
104
+ }
105
+ return (0, rxjs_1.from)([
106
+ (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({ status: response.status }),
107
+ (0, snackbarReducer_1.openSnackbar)({
108
+ messageSection: 'create_schedule',
109
+ messageText: 'failed',
110
+ type: 'error',
111
+ variables: [
112
+ {
113
+ variableName: '_api-error_',
114
+ variableValue: response.status.message,
115
+ },
116
+ ],
117
+ }),
118
+ ]);
119
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
120
+ (0, snackbarReducer_1.openSnackbar)({
121
+ messageSection: 'create_schedule',
122
+ messageText: 'failed',
123
+ type: 'error',
124
+ variables: [
125
+ {
126
+ variableName: '_api-error_',
127
+ variableValue: JSON.stringify(error),
128
+ },
129
+ ],
130
+ }),
131
+ (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
132
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
133
+ }),
134
+ ])),
135
+ // A tenant switch clears the store while this request is still in flight.
136
+ // Without this the old tenant's response is written back into the freshly
137
+ // cleared store and stays on screen under the new tenant.
138
+ (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
139
+ }));
140
+ exports.saveNewScheduleEpic = saveNewScheduleEpic;
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
7
+ export type ActionType = ReturnType<typeof searchTransactionsForNewSchedule> | ReturnType<typeof searchTransactionsForNewScheduleSuccess> | ReturnType<typeof searchTransactionsForNewScheduleFailure> | ReturnType<typeof updateScheduleTransactions>;
8
+ export declare const searchTransactionsForNewScheduleEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchTransactionsForNewScheduleEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedulesTypes");
7
+ const transactionType_1 = require("../../../../../entity/transaction/stateTypes/transactionType");
8
+ const transactionReducer_1 = require("../../../../../entity/transaction/transactionReducer");
9
+ const responsePayload_1 = require("../../../../../responsePayload");
10
+ const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
11
+ const jeSchedulesViewState_1 = require("../../../types/jeSchedulesViewState");
12
+ /**
13
+ * Dropdown-sized result set. The endpoint is paginated — it takes a `page_token` $skip offset and
14
+ * returns `next_page_token` — but nothing here reads or sends those, so this is the whole result
15
+ * set the form ever sees. 20 rather than the backend's default of 10 because a text search for one
16
+ * known transaction was running out of room; the cap server-side is 100 if this needs raising again
17
+ * before infinite scroll is wired up.
18
+ */
19
+ const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 20;
20
+ /** Fallback when the backend sends a null currency for a search result. */
21
+ const DEFAULT_CURRENCY_CODE = 'USD';
22
+ const DEFAULT_CURRENCY_SYMBOL = '$';
23
+ const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
24
+ const searchActions$ = actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.searchTransactionsForNewSchedule.match));
25
+ /** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
26
+ const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH));
27
+ const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length >= jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH), (0, operators_1.debounceTime)(300));
28
+ return (0, rxjs_1.merge)(newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
29
+ const query = action.payload.query.trim();
30
+ if (query.length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
31
+ return rxjs_1.EMPTY;
32
+ }
33
+ const queryParam = {
34
+ page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
35
+ search_text: query,
36
+ je_schedule_type: action.payload.scheduleType,
37
+ };
38
+ return zeniAPI
39
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
40
+ .pipe((0, operators_1.mergeMap)((response) => {
41
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
42
+ const { transactions } = response.data;
43
+ const transactionsPerCurrency = {};
44
+ transactions.forEach((transaction) => {
45
+ const { currency_code, currency_symbol } = transaction;
46
+ const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
47
+ const existing = transactionsPerCurrency[currencyCode];
48
+ transactionsPerCurrency[currencyCode] =
49
+ existing != null
50
+ ? {
51
+ currencySymbol: existing.currencySymbol,
52
+ transactions: [...existing.transactions, transaction],
53
+ }
54
+ : {
55
+ currencySymbol: currency_code == null
56
+ ? DEFAULT_CURRENCY_SYMBOL
57
+ : currency_symbol,
58
+ transactions: [transaction],
59
+ };
60
+ });
61
+ const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
62
+ const perCurrency = transactionsPerCurrency[currencyCode];
63
+ return (0, transactionReducer_1.updateScheduleTransactions)(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
64
+ });
65
+ actionsOut.push((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleSuccess)({
66
+ searchResults: transactions.map((transaction) => (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)({
67
+ id: transaction.transaction_id,
68
+ type: (0, transactionType_1.toTransactionType)(transaction.transaction_type),
69
+ lineId: transaction.line_id,
70
+ })),
71
+ }));
72
+ return (0, rxjs_1.from)(actionsOut);
73
+ }
74
+ return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
75
+ status: response.status,
76
+ }));
77
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
78
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for new schedule errored: ' +
79
+ JSON.stringify(error)),
80
+ }))));
81
+ }));
82
+ };
83
+ exports.searchTransactionsForNewScheduleEpic = searchTransactionsForNewScheduleEpic;
@@ -0,0 +1,13 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
+ import { RootState } from '../../../../reducer';
6
+ import { clearAll } from '../../../../rootActions';
7
+ import { ZeniAPI } from '../../../../zeniAPI';
8
+ import { fetchJeSchedules, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertOneTimeAccrual } from '../../reducers/jeSchedulesViewReducer';
9
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof promoteOneTimeAccrual> | ReturnType<typeof revertOneTimeAccrual> | ReturnType<typeof ignoreOneTimeAccrual> | ReturnType<typeof oneTimeAccrualActionSuccess> | ReturnType<typeof oneTimeAccrualActionFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
10
+ export declare const promoteOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
11
+ export declare const ignoreOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
12
+ export declare const revertOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
13
+ export declare const oneTimeAccrualActionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;