@zeniai/client-epic-state 5.2.7-betaRD2 → 5.2.8-betaAK0

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 (162) hide show
  1. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +36 -2
  2. package/lib/entity/invoicing/invoicingCommonPayload.js +89 -11
  3. package/lib/entity/invoicing/product/productPayload.d.ts +10 -0
  4. package/lib/entity/invoicing/product/productPayload.js +14 -2
  5. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +0 -1
  6. package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
  7. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -66
  8. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -135
  9. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
  10. package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  11. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -11
  12. package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -38
  13. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -79
  14. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -24
  15. package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -88
  16. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  17. package/lib/entity/snackbar/snackbarTypes.js +0 -3
  18. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
  19. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  20. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
  21. package/lib/epic.d.ts +1 -9
  22. package/lib/epic.js +0 -16
  23. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +86 -10
  24. package/lib/esm/entity/invoicing/product/productPayload.js +14 -2
  25. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
  26. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -135
  27. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  28. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -36
  29. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -78
  30. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
  31. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  32. package/lib/esm/epic.js +0 -16
  33. package/lib/esm/index.js +8 -14
  34. package/lib/esm/view/accountList/accountListReducer.js +0 -1
  35. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +5 -41
  37. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  38. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +0 -55
  39. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -306
  40. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -294
  41. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
  42. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +24 -9
  43. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +2 -1
  44. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
  45. package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +2 -0
  46. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +10 -5
  47. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +47 -3
  48. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +17 -2
  49. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +7 -3
  50. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  51. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  52. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  53. package/lib/index.d.ts +12 -17
  54. package/lib/index.js +47 -91
  55. package/lib/view/accountList/accountListReducer.js +0 -1
  56. package/lib/view/accountList/accountListState.d.ts +1 -1
  57. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  58. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -3
  59. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -39
  60. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  61. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  62. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +3 -72
  63. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -58
  64. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +12 -91
  65. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -308
  66. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  67. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  68. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +7 -36
  69. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +0 -34
  70. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -302
  71. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  72. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -82
  73. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  74. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  75. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +12 -1
  76. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +24 -9
  77. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +5 -0
  78. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +1 -0
  79. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
  80. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +1 -0
  81. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +2 -0
  82. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +10 -5
  83. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +19 -2
  84. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +52 -4
  85. package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +1 -1
  86. package/lib/view/invoicing/settingsView/settingsViewEpics.js +17 -2
  87. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +11 -4
  88. package/lib/view/invoicing/settingsView/settingsViewSelector.js +7 -3
  89. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  90. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  91. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +2 -4
  92. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  93. package/package.json +1 -1
  94. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
  95. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  96. package/lib/entity/invoicing/coupon/couponConstants.d.ts +0 -11
  97. package/lib/entity/invoicing/coupon/couponConstants.js +0 -29
  98. package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  99. package/lib/esm/entity/invoicing/coupon/couponConstants.js +0 -26
  100. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -45
  101. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -99
  102. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
  103. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
  104. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -79
  105. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -139
  106. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -106
  107. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -22
  108. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
  109. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
  110. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -106
  111. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -25
  112. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -15
  113. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -18
  114. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -18
  115. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -18
  116. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -16
  117. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -1
  118. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -60
  119. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -12
  120. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -1
  121. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +0 -20
  122. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -49
  123. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +0 -8
  124. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -103
  125. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
  126. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -29
  127. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -45
  128. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -114
  129. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
  130. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -83
  131. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +0 -12
  132. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -146
  133. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +0 -64
  134. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -110
  135. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
  136. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -26
  137. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
  138. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
  139. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -42
  140. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
  141. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -21
  142. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -112
  143. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +0 -6
  144. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -29
  145. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +0 -6
  146. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -19
  147. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +0 -8
  148. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -22
  149. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +0 -8
  150. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -22
  151. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +0 -8
  152. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -22
  153. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +0 -13
  154. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -20
  155. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +0 -11
  156. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -2
  157. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +0 -7
  158. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -64
  159. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +0 -12
  160. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -15
  161. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +0 -9
  162. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -2
@@ -1,45 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, takeUntil } from 'rxjs/operators';
3
- import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
- import { clearAll } from '../../../../rootActions';
6
- import { fetchOneTimeAccrual, fetchOneTimeAccrualFailure, fetchOneTimeAccrualSuccess, } from '../../reducers/jeSchedulesViewReducer';
7
- /**
8
- * Read one accrual by id so its detail page can render from a URL alone.
9
- *
10
- * Every other row on this page arrives with the JE Schedules list, and the accrual detail page used
11
- * to render only from what that list had already put in the store -- so opening its URL directly, on
12
- * a refresh or a shared link, had nothing to render and showed not-found. This is the read that
13
- * makes the URL self-sufficient.
14
- *
15
- * The response is the same `{accrual}` envelope promote / ignore / revert return, and it goes through
16
- * the same `updateJEOneTimeAccruals`, so a page loaded cold holds exactly the entity a page reached
17
- * through the list holds.
18
- */
19
- export const fetchOneTimeAccrualEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchOneTimeAccrual.match), mergeMap((action) => {
20
- const { accrualId } = action.payload;
21
- return zeniAPI
22
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`)
23
- .pipe(mergeMap((response) => {
24
- if (isSuccessResponse(response) && response.data != null) {
25
- return from([
26
- updateJEOneTimeAccruals([response.data.accrual]),
27
- fetchOneTimeAccrualSuccess({ accrualId }),
28
- ]);
29
- }
30
- // A deleted or ignored accrual answers 404 here, the same as an id that never existed.
31
- // Both end as an error state the page turns into not-found, rather than a spinner that
32
- // never resolves.
33
- return from([
34
- fetchOneTimeAccrualFailure({ accrualId, status: response.status }),
35
- ]);
36
- }), catchError((error) => from([
37
- fetchOneTimeAccrualFailure({
38
- accrualId,
39
- status: createZeniAPIStatus('Unexpected Error', `Fetch one-time accrual REST API call errored out ${JSON.stringify(error)}`),
40
- }),
41
- ])),
42
- // A tenant switch clears the store while this request is in flight. Without this the old
43
- // tenant's accrual is written back into the freshly cleared store.
44
- takeUntil(actions$.pipe(filter(clearAll.match))));
45
- }));
@@ -1,99 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { convertToPeriod, toAbsoluteDay, } from '../../../../../commonStateTypes/timePeriod';
4
- import { updateJEOneTimeAccruals } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
5
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
6
- import { getCurrentTenant } from '../../../../../entity/tenant/tenantSelector';
7
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
8
- import { prepareCreateOneTimeAccrualPayload, } from '../../../payload/jeSchedulesPayload';
9
- import { createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedules, } from '../../../reducers/jeSchedulesViewReducer';
10
- export const createOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(createOneTimeAccrual.match), mergeMap((action) => {
11
- const state = state$.value;
12
- const { localData } = action.payload;
13
- /*
14
- * Idempotency for the create. agent-je dedupes on this: the same key again returns the
15
- * existing accrual rather than posting a second JE to QBO.
16
- *
17
- * Body `request_id` rather than the `Idempotency-Key` header the API doc prefers, on Mohit's
18
- * call (2026-08-24). The header cannot reach the service from a browser -- common's
19
- * Access-Control-Allow-Headers does not list it, so cross-origin preflight rejects the
20
- * request. Same meaning either way; the header simply wins when both are sent.
21
- *
22
- * Minted here, per create action, and deliberately not held in local data or the form: a new
23
- * Save must produce a new key, and only a retry of *this* request may reuse one. Nothing
24
- * retries today -- if a retry operator is ever added below, it has to sit inside this
25
- * mergeMap so the key is not re-minted, or the guarantee is silently lost.
26
- */
27
- const requestId = crypto.randomUUID();
28
- const payload = {
29
- ...prepareCreateOneTimeAccrualPayload(state, localData),
30
- request_id: requestId,
31
- };
32
- // convertToPeriod destructures, so an unset period would throw here and take the epic
33
- // subscription down for the whole session — a missed refresh is the cheaper failure.
34
- const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[getCurrentTenant(state).tenantId];
35
- const selectedPeriod = selectedMonthYear != null
36
- ? convertToPeriod(selectedMonthYear)
37
- : undefined;
38
- const periodStart = selectedPeriod != null
39
- ? toAbsoluteDay(selectedPeriod.start)
40
- : undefined;
41
- const periodEnd = selectedPeriod != null ? toAbsoluteDay(selectedPeriod.end) : undefined;
42
- return zeniAPI
43
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
44
- .pipe(mergeMap((response) => {
45
- if (isSuccessResponse(response) && response.data != null) {
46
- const successActions = [
47
- updateJEOneTimeAccruals([response.data.accrual]),
48
- createOneTimeAccrualSuccess(),
49
- openSnackbar({
50
- messageSection: 'create_schedule',
51
- messageText: 'success',
52
- type: 'success',
53
- variables: [
54
- {
55
- variableName: '_vendor_name_',
56
- variableValue: localData.vendorName,
57
- },
58
- ],
59
- }),
60
- ];
61
- // The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
62
- // per fetch, and the backend decides whether a freshly posted accrual belongs to
63
- // Review or Existing — so refetch rather than guess which bucket to insert into.
64
- if (periodStart != null && periodEnd != null) {
65
- successActions.push(fetchJeSchedules({ start: periodStart, end: periodEnd }, true));
66
- }
67
- return from(successActions);
68
- }
69
- return from([
70
- createOneTimeAccrualFailure({ status: response.status }),
71
- openSnackbar({
72
- messageSection: 'create_schedule',
73
- messageText: 'failed',
74
- type: 'error',
75
- variables: [
76
- {
77
- variableName: '_api-error_',
78
- variableValue: response.status.message,
79
- },
80
- ],
81
- }),
82
- ]);
83
- }), catchError((error) => from([
84
- openSnackbar({
85
- messageSection: 'create_schedule',
86
- messageText: 'failed',
87
- type: 'error',
88
- variables: [
89
- {
90
- variableName: '_api-error_',
91
- variableValue: JSON.stringify(error),
92
- },
93
- ],
94
- }),
95
- createOneTimeAccrualFailure({
96
- status: createZeniAPIStatus('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
97
- }),
98
- ])));
99
- }));
@@ -1,25 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { filter, mergeMap } from 'rxjs/operators';
3
- import { fetchAccountList } from '../../../../accountList/accountListReducer';
4
- import { fetchClassList } from '../../../../classList/classListReducer';
5
- import { getAccountsTypesForScheduleEpics } from '../../../../scheduleView/scheduleListView/scheduleListHelper';
6
- import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData, } from '../../../reducers/jeSchedulesViewReducer';
7
- export const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe(filter(initializeNewSchedule.match), mergeMap((action) => {
8
- const newScheduleActions = [];
9
- const accountType = getAccountsTypesForScheduleEpics();
10
- const { accountListState, classListState } = state$.value;
11
- if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
12
- 'Not-Started') {
13
- newScheduleActions.push(fetchAccountList(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
14
- }
15
- if (classListState.fetchState === 'Not-Started') {
16
- newScheduleActions.push(fetchClassList());
17
- }
18
- // The account and class fetches above are idempotent (both guard on 'Not-Started'), so they
19
- // can run on every open. Clearing what the user entered cannot, so it is opt-in.
20
- if (action.payload.shouldResetEnteredData) {
21
- newScheduleActions.push(resetNewScheduleLocalData({ scheduleType: action.payload.scheduleType }));
22
- newScheduleActions.push(clearSearchTransactionsForNewSchedule());
23
- }
24
- return from(newScheduleActions);
25
- }));
@@ -1,110 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { updateJESchedules, updateJESchedulesDetails, } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
4
- import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/jeSchedulesTypes';
5
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
6
- import { getScheduleTransactionById } from '../../../../../entity/transaction/transactionSelector';
7
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
8
- import { prepareNewSchedulePayload, } from '../../../helpers/newScheduleLocalDataHelper';
9
- import { resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
10
- const FAILURE_REASON_MESSAGES = {
11
- missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
12
- missing_vendor: 'Select a vendor before saving this schedule.',
13
- };
14
- export const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveNewSchedule.match), mergeMap((action) => {
15
- const { scheduleType } = action.payload;
16
- const state = state$.value;
17
- const localData = state.expenseAutomationJESchedulesViewState.newSchedule
18
- .newScheduleState[scheduleType];
19
- const { selectedBaseTransactionId } = localData;
20
- const transaction = selectedBaseTransactionId != null
21
- ? getScheduleTransactionById(state.transactionState, getJEScheduleTransactionKey(selectedBaseTransactionId))
22
- : undefined;
23
- if (transaction == null) {
24
- return from([
25
- saveNewScheduleFailure({
26
- status: createZeniAPIStatus('Unexpected Error', 'No base transaction selected for this schedule.'),
27
- }),
28
- openSnackbar({
29
- messageSection: 'create_schedule',
30
- messageText: 'failed',
31
- type: 'error',
32
- variables: [
33
- {
34
- variableName: '_api-error_',
35
- variableValue: 'No base transaction selected.',
36
- },
37
- ],
38
- }),
39
- ]);
40
- }
41
- const result = prepareNewSchedulePayload(transaction, localData, scheduleType);
42
- if (!result.ok) {
43
- const message = FAILURE_REASON_MESSAGES[result.reason];
44
- return from([
45
- saveNewScheduleFailure({
46
- status: createZeniAPIStatus('Unexpected Error', message),
47
- }),
48
- openSnackbar({
49
- messageSection: 'create_schedule',
50
- messageText: 'failed',
51
- type: 'error',
52
- variables: [{ variableName: '_api-error_', variableValue: message }],
53
- }),
54
- ]);
55
- }
56
- const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
57
- const queryParam = {
58
- je_schedule_type: scheduleType,
59
- };
60
- const payload = { ...result.payload };
61
- return zeniAPI
62
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
63
- .pipe(mergeMap((response) => {
64
- if (isSuccessResponse(response) && response.data != null) {
65
- return from([
66
- updateJESchedules(response.data.je_schedules),
67
- updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries),
68
- resetNewScheduleLocalData({ scheduleType }),
69
- saveNewScheduleSuccess(),
70
- openSnackbar({
71
- messageSection: 'create_schedule',
72
- messageText: 'success',
73
- type: 'success',
74
- variables: [
75
- { variableName: '_vendor_name_', variableValue: vendorName },
76
- ],
77
- }),
78
- ]);
79
- }
80
- return from([
81
- saveNewScheduleFailure({ status: response.status }),
82
- openSnackbar({
83
- messageSection: 'create_schedule',
84
- messageText: 'failed',
85
- type: 'error',
86
- variables: [
87
- {
88
- variableName: '_api-error_',
89
- variableValue: response.status.message,
90
- },
91
- ],
92
- }),
93
- ]);
94
- }), catchError((error) => from([
95
- openSnackbar({
96
- messageSection: 'create_schedule',
97
- messageText: 'failed',
98
- type: 'error',
99
- variables: [
100
- {
101
- variableName: '_api-error_',
102
- variableValue: JSON.stringify(error),
103
- },
104
- ],
105
- }),
106
- saveNewScheduleFailure({
107
- status: createZeniAPIStatus('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
108
- }),
109
- ])));
110
- }));
@@ -1,79 +0,0 @@
1
- import { EMPTY, from, merge, of } from 'rxjs';
2
- import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
3
- import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/jeSchedulesTypes';
4
- import { toTransactionType } from '../../../../../entity/transaction/stateTypes/transactionType';
5
- import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
6
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
7
- import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
8
- import { MIN_NEW_SCHEDULE_SEARCH_LENGTH } from '../../../types/jeSchedulesViewState';
9
- /**
10
- * Dropdown-sized result set. The endpoint is paginated — it takes a `page_token` $skip offset and
11
- * returns `next_page_token` — but nothing here reads or sends those, so this is the whole result
12
- * set the form ever sees. 20 rather than the backend's default of 10 because a text search for one
13
- * known transaction was running out of room; the cap server-side is 100 if this needs raising again
14
- * before infinite scroll is wired up.
15
- */
16
- const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 20;
17
- /** Fallback when the backend sends a null currency for a search result. */
18
- const DEFAULT_CURRENCY_CODE = 'USD';
19
- const DEFAULT_CURRENCY_SYMBOL = '$';
20
- export const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
21
- const searchActions$ = actions$.pipe(filter(searchTransactionsForNewSchedule.match));
22
- /** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
23
- const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length < MIN_NEW_SCHEDULE_SEARCH_LENGTH));
24
- const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length >= MIN_NEW_SCHEDULE_SEARCH_LENGTH), debounceTime(300));
25
- return merge(newSearchTooShortOrClear$, newSearchDebounced$).pipe(switchMap((action) => {
26
- const query = action.payload.query.trim();
27
- if (query.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
28
- return EMPTY;
29
- }
30
- const queryParam = {
31
- page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
32
- search_text: query,
33
- je_schedule_type: action.payload.scheduleType,
34
- };
35
- return zeniAPI
36
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
37
- .pipe(mergeMap((response) => {
38
- if (isSuccessResponse(response) && response.data != null) {
39
- const { transactions } = response.data;
40
- const transactionsPerCurrency = {};
41
- transactions.forEach((transaction) => {
42
- const { currency_code, currency_symbol } = transaction;
43
- const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
44
- const existing = transactionsPerCurrency[currencyCode];
45
- transactionsPerCurrency[currencyCode] =
46
- existing != null
47
- ? {
48
- currencySymbol: existing.currencySymbol,
49
- transactions: [...existing.transactions, transaction],
50
- }
51
- : {
52
- currencySymbol: currency_code == null
53
- ? DEFAULT_CURRENCY_SYMBOL
54
- : currency_symbol,
55
- transactions: [transaction],
56
- };
57
- });
58
- const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
59
- const perCurrency = transactionsPerCurrency[currencyCode];
60
- return updateScheduleTransactions(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
61
- });
62
- actionsOut.push(searchTransactionsForNewScheduleSuccess({
63
- searchResults: transactions.map((transaction) => getJEScheduleTransactionKey({
64
- id: transaction.transaction_id,
65
- type: toTransactionType(transaction.transaction_type),
66
- lineId: transaction.line_id,
67
- })),
68
- }));
69
- return from(actionsOut);
70
- }
71
- return of(searchTransactionsForNewScheduleFailure({
72
- status: response.status,
73
- }));
74
- }), catchError((error) => of(searchTransactionsForNewScheduleFailure({
75
- status: createZeniAPIStatus('Unexpected Error', 'Search transactions for new schedule errored: ' +
76
- JSON.stringify(error)),
77
- }))));
78
- }));
79
- };
@@ -1,139 +0,0 @@
1
- import { from, merge } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
4
- import { generateJEOneTimeAccrualKey } from '../../../../entity/jeSchedules/jeScheduleHelper';
5
- import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
6
- import { getJEOneTimeAccrualByKey } from '../../../../entity/jeSchedules/jeSchedulesSelector';
7
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
8
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
9
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
10
- import { fetchJeSchedules, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertOneTimeAccrual, } from '../../reducers/jeSchedulesViewReducer';
11
- /**
12
- * The page the accrual came from, so a promoted or ignored row lands in the right bucket. Guarded
13
- * because convertToPeriod destructures: an unset period would throw and take the epic subscription
14
- * down for the session, and a missed refresh is the cheaper failure.
15
- */
16
- function refreshCurrentPage(state) {
17
- const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[getCurrentTenant(state).tenantId];
18
- if (selectedMonthYear == null) {
19
- return [];
20
- }
21
- const period = convertToPeriod(selectedMonthYear);
22
- const start = toAbsoluteDay(period.start);
23
- const end = toAbsoluteDay(period.end);
24
- if (start == null || end == null) {
25
- return [];
26
- }
27
- return [fetchJeSchedules({ start, end }, true)];
28
- }
29
- function failureActions(accrualId, message, status) {
30
- return [
31
- oneTimeAccrualActionFailure({
32
- accrualId,
33
- status: status ?? createZeniAPIStatus('Unexpected Error', message),
34
- }),
35
- openSnackbar({
36
- messageSection: 'save_schedule',
37
- messageText: 'failed',
38
- type: 'error',
39
- variables: [{ variableName: '_api-error_', variableValue: message }],
40
- }),
41
- ];
42
- }
43
- export const promoteOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(promoteOneTimeAccrual.match), mergeMap((action) => {
44
- const state = state$.value;
45
- const { accrualId, amount } = action.payload;
46
- const accrual = getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState);
47
- if (accrual?.jeDebitAccountId == null ||
48
- accrual.jeCreditAccountId == null) {
49
- // Promote posts a journal entry, so it cannot proceed without both sides of it.
50
- return from(failureActions(accrualId, 'This accrual is missing an expense or liability account.'));
51
- }
52
- // vendor_id, vendor_name and service_month are deliberately absent: promote takes them from
53
- // the stored draft and ignores them in the body, so sending them would imply a reassignment
54
- // that never happens.
55
- const payload = {
56
- amount,
57
- memo: accrual.memo,
58
- je_debit_account_id: accrual.jeDebitAccountId,
59
- je_credit_account_id: accrual.jeCreditAccountId,
60
- };
61
- return zeniAPI
62
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`, { ...payload })
63
- .pipe(mergeMap((response) => {
64
- if (isSuccessResponse(response) && response.data != null) {
65
- return from([
66
- updateJEOneTimeAccruals([response.data.accrual]),
67
- oneTimeAccrualActionSuccess({ accrualId }),
68
- openSnackbar({
69
- messageSection: 'save_schedule',
70
- messageText: 'success',
71
- type: 'success',
72
- variables: [
73
- {
74
- variableName: '_vendor_name_',
75
- variableValue: accrual.vendorName,
76
- },
77
- ],
78
- }),
79
- ...refreshCurrentPage(state),
80
- ]);
81
- }
82
- return from(failureActions(accrualId, response.status.message, response.status));
83
- }), catchError((error) => from(failureActions(accrualId, `Promote accrual REST API call errored out ${JSON.stringify(error)}`))));
84
- }));
85
- export const ignoreOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(ignoreOneTimeAccrual.match), mergeMap((action) => {
86
- const state = state$.value;
87
- const { accrualId, reason, note } = action.payload;
88
- // `scope` is deliberately never sent: the API returns 400 on it, which is why the design's
89
- // "Apply to" selector cannot be built yet.
90
- const payload = {
91
- reason,
92
- ...(note != null && note !== '' ? { note } : {}),
93
- };
94
- return zeniAPI
95
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/ignore`, { ...payload })
96
- .pipe(mergeMap((response) => {
97
- if (isSuccessResponse(response) && response.data != null) {
98
- return from([
99
- updateJEOneTimeAccruals([response.data.accrual]),
100
- oneTimeAccrualActionSuccess({ accrualId }),
101
- openSnackbar({
102
- messageSection: 'ignore_accrual',
103
- messageText: 'success',
104
- type: 'success',
105
- }),
106
- ...refreshCurrentPage(state),
107
- ]);
108
- }
109
- return from(failureActions(accrualId, response.status.message, response.status));
110
- }), catchError((error) => from(failureActions(accrualId, `Ignore accrual REST API call errored out ${JSON.stringify(error)}`))));
111
- }));
112
- export const revertOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(revertOneTimeAccrual.match), mergeMap((action) => {
113
- const state = state$.value;
114
- const { accrualId, reason, note } = action.payload;
115
- // Deletes the accrual's journal entry in QBO and soft-deletes the row. `scope` is never sent:
116
- // the endpoint 400s on it, exactly as ignore does.
117
- const payload = {
118
- reason,
119
- ...(note != null && note !== '' ? { note } : {}),
120
- };
121
- return zeniAPI
122
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/revert`, { ...payload })
123
- .pipe(mergeMap((response) => {
124
- if (isSuccessResponse(response) && response.data != null) {
125
- return from([
126
- updateJEOneTimeAccruals([response.data.accrual]),
127
- oneTimeAccrualActionSuccess({ accrualId }),
128
- openSnackbar({
129
- messageSection: 'revert_accrual',
130
- messageText: 'success',
131
- type: 'success',
132
- }),
133
- ...refreshCurrentPage(state),
134
- ]);
135
- }
136
- return from(failureActions(accrualId, response.status.message, response.status));
137
- }), catchError((error) => from(failureActions(accrualId, `Revert accrual REST API call errored out ${JSON.stringify(error)}`))));
138
- }));
139
- export const oneTimeAccrualActionsEpic = (actions$, state$, zeniAPI) => merge(promoteOneTimeAccrualEpic(actions$, state$, zeniAPI), ignoreOneTimeAccrualEpic(actions$, state$, zeniAPI), revertOneTimeAccrualEpic(actions$, state$, zeniAPI));
@@ -1,106 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
6
- import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
7
- import { removeJeAccruedScheduleKey, removeJeScheduleTransactionKey, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess, } from '../../reducers/jeSchedulesViewReducer';
8
- /**
9
- * Undo a posted prepaid / fixed-asset / accrued schedule: deletes its posted QBO journal entry, then
10
- * soft-deletes the scheduled entries and the schedule itself.
11
- *
12
- * Two or more posted journal entries answer 409 and leave the schedule intact, so the failure is
13
- * surfaced rather than swallowed. Accrued has one extra rejection of its own — the endpoint refuses
14
- * once a bill has been linked, because the reversal is already on the books — and that arrives the
15
- * same way, as an error on the row.
16
- *
17
- * A one-time accrual is not this action: it is a Mongo row behind the accruals gateway, and goes
18
- * through revertOneTimeAccrual instead. So `accrued_expenses` here always means an accrued
19
- * *schedule*, which is what makes it a safe discriminator for the removal below.
20
- */
21
- export const revertJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(revertJeSchedule.match), mergeMap((action) => {
22
- const state = state$.value;
23
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
24
- const { jeScheduleId, jeScheduleTransactionKey, reason, note, scheduleType } = action.payload;
25
- const currentTenant = getCurrentTenant(state);
26
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
27
- // Feedback nested under je_schedules[0], the same shape ignore takes -- the two endpoints were
28
- // made symmetric server-side. A flat {reason, note} body, which this epic used to send while
29
- // revert validated the whole body as feedback, now answers 400 "Request body must contain at
30
- // least one of je_schedules".
31
- //
32
- // Only the id and the feedback: the rest of the fat blob is read from Datastore, not the
33
- // request. The id is optional server-side but sent anyway, because it is validated against the
34
- // URL and so turns a mismatch into a 400 rather than a revert of the wrong schedule.
35
- // `action` is stamped server-side.
36
- const payload = {
37
- je_schedules: [
38
- {
39
- je_schedule_id: jeScheduleId,
40
- feedback: {
41
- reason,
42
- ...(note != null && note !== '' ? { note } : {}),
43
- },
44
- },
45
- ],
46
- };
47
- return zeniAPI
48
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/revert`, payload)
49
- .pipe(mergeMap((response) => {
50
- if (isSuccessResponse(response) && response.data != null) {
51
- // Deliberately not written to the entity store. A reverted schedule is soft-deleted,
52
- // so the endpoint returns its flat entity json -- `vendor_id` as a bare field, no
53
- // nested `vendor` or `base_transaction` -- rather than the list DTO those mappers
54
- // expect. Feeding it to updateJESchedules threw inside doUpdateVendors on
55
- // `payload.vendor.vendor_id`, and because that happens mid-dispatch it killed the
56
- // rest of this array: the row kept spinning and no snackbar appeared. The row is
57
- // removed from the list below regardless, so there is nothing worth storing.
58
- return from([
59
- revertJeScheduleSuccess({ jeScheduleTransactionKey }),
60
- // Accrued keys live in their own per-tab map, so the transaction-key removal cannot
61
- // reach them -- a reverted accrued schedule would sit on the list until the next
62
- // fetch. The key carried here is a JEScheduleKey for that type.
63
- scheduleType === 'accrued_expenses'
64
- ? removeJeAccruedScheduleKey(jeScheduleTransactionKey)
65
- : removeJeScheduleTransactionKey(jeScheduleTransactionKey, selectedPeriod),
66
- fetchMonthEndCloseChecks({
67
- tenantId: currentTenant.tenantId,
68
- period: selectedPeriod,
69
- refreshViewInBackground: true,
70
- }),
71
- openSnackbar({
72
- messageSection: 'revert_schedule',
73
- messageText: 'success',
74
- type: 'success',
75
- }),
76
- ]);
77
- }
78
- return from([
79
- revertJeScheduleFailure({
80
- jeScheduleTransactionKey,
81
- status: response.status,
82
- }),
83
- openSnackbar({
84
- messageSection: 'revert_schedule',
85
- messageText: 'failed',
86
- type: 'error',
87
- variables: [
88
- {
89
- variableName: '_api-error_',
90
- variableValue: response.status.message,
91
- },
92
- ],
93
- }),
94
- ]);
95
- }), catchError((error) => from([
96
- revertJeScheduleFailure({
97
- jeScheduleTransactionKey,
98
- status: createZeniAPIStatus('Unexpected Error', `Revert schedule REST API call errored out ${JSON.stringify(error)}`),
99
- }),
100
- openSnackbar({
101
- messageSection: 'revert_schedule',
102
- messageText: 'failed',
103
- type: 'error',
104
- }),
105
- ])));
106
- }));
@@ -1,22 +0,0 @@
1
- import { EMPTY, of } from 'rxjs';
2
- import { filter, mergeMap } from 'rxjs/operators';
3
- import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
4
- import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
- import { fetchJeSchedulesPage, updateJESchedulesUIState, } from '../../reducers/jeSchedulesViewReducer';
6
- export const switchJESchedulesTabEpic = (actions$, state$) => actions$.pipe(filter(updateJESchedulesUIState.match), filter((action) => action.payload.selectedPageTab != null), mergeMap(() => {
7
- const state = state$.value;
8
- const { fetchState, refreshStatus } = state.expenseAutomationJESchedulesViewState;
9
- if (fetchState === 'In-Progress' ||
10
- refreshStatus.fetchState === 'In-Progress') {
11
- return EMPTY;
12
- }
13
- const currentTenant = getCurrentTenant(state);
14
- const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
15
- const period = convertToPeriod(selectedPeriod);
16
- const timePeriodStart = toAbsoluteDay(period.start);
17
- const timePeriodEnd = toAbsoluteDay(period.end);
18
- if (timePeriodStart == null || timePeriodEnd == null) {
19
- return EMPTY;
20
- }
21
- return of(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, true));
22
- }));