@zeniai/client-epic-state 5.2.10-betaRD1 → 5.2.11

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 (145) hide show
  1. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +0 -1
  2. package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
  3. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -66
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -135
  5. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
  6. package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -11
  8. package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -38
  9. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -79
  10. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -24
  11. package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -88
  12. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  13. package/lib/entity/snackbar/snackbarTypes.js +0 -3
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  16. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
  17. package/lib/epic.d.ts +1 -9
  18. package/lib/epic.js +0 -16
  19. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
  20. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -135
  21. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  22. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -36
  23. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -78
  24. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
  25. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  26. package/lib/esm/epic.js +0 -16
  27. package/lib/esm/index.js +8 -14
  28. package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
  29. package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
  30. package/lib/esm/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
  31. package/lib/esm/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
  32. package/lib/esm/view/companyMonthEndReportView/monthEndTemplateData.js +32 -0
  33. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +5 -41
  35. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  36. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +0 -55
  37. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -306
  38. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -294
  39. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
  40. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  41. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  42. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  43. package/lib/index.d.ts +14 -18
  44. package/lib/index.js +47 -91
  45. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +8 -0
  46. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +6 -2
  47. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
  48. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +2 -0
  49. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
  50. package/lib/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
  51. package/lib/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
  52. package/lib/view/companyMonthEndReportView/monthEndTemplateData.d.ts +16 -0
  53. package/lib/view/companyMonthEndReportView/monthEndTemplateData.js +36 -0
  54. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  55. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -3
  56. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -39
  57. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  58. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  59. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +3 -72
  60. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -58
  61. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +12 -91
  62. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -308
  63. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  64. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  65. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +7 -36
  66. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +0 -34
  67. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -302
  68. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  69. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -82
  70. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  71. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  72. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  73. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  74. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +2 -4
  75. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  76. package/package.json +1 -1
  77. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
  78. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  79. package/lib/entity/invoicing/coupon/couponConstants.d.ts +0 -11
  80. package/lib/entity/invoicing/coupon/couponConstants.js +0 -29
  81. package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  82. package/lib/esm/entity/invoicing/coupon/couponConstants.js +0 -26
  83. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -45
  84. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -99
  85. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
  86. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
  87. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -79
  88. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -139
  89. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -106
  90. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -22
  91. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
  92. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
  93. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -106
  94. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -25
  95. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -15
  96. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -18
  97. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -18
  98. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -18
  99. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -16
  100. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -1
  101. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -60
  102. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -12
  103. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -1
  104. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +0 -20
  105. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -49
  106. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +0 -8
  107. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -103
  108. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
  109. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -29
  110. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -45
  111. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -114
  112. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
  113. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -83
  114. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +0 -12
  115. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -146
  116. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +0 -64
  117. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -110
  118. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
  119. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -26
  120. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
  121. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
  122. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -42
  123. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
  124. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -21
  125. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -112
  126. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +0 -6
  127. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -29
  128. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +0 -6
  129. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -19
  130. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +0 -8
  131. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -22
  132. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +0 -8
  133. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -22
  134. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +0 -8
  135. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -22
  136. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +0 -13
  137. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -20
  138. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +0 -11
  139. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -2
  140. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +0 -7
  141. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -64
  142. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +0 -12
  143. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -15
  144. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +0 -9
  145. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -2
@@ -1,49 +0,0 @@
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;
@@ -1,8 +0,0 @@
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 { ZeniAPI } from '../../../../../zeniAPI';
6
- import { createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedules } from '../../../reducers/jeSchedulesViewReducer';
7
- export type ActionType = ReturnType<typeof createOneTimeAccrual> | ReturnType<typeof createOneTimeAccrualSuccess> | ReturnType<typeof createOneTimeAccrualFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
8
- export declare const createOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -1,103 +0,0 @@
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 responsePayload_1 = require("../../../../../responsePayload");
11
- const jeSchedulesPayload_1 = require("../../../payload/jeSchedulesPayload");
12
- const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
13
- const createOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.createOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
14
- const state = state$.value;
15
- const { localData } = action.payload;
16
- /*
17
- * Idempotency for the create. agent-je dedupes on this: the same key again returns the
18
- * existing accrual rather than posting a second JE to QBO.
19
- *
20
- * Body `request_id` rather than the `Idempotency-Key` header the API doc prefers, on Mohit's
21
- * call (2026-08-24). The header cannot reach the service from a browser -- common's
22
- * Access-Control-Allow-Headers does not list it, so cross-origin preflight rejects the
23
- * request. Same meaning either way; the header simply wins when both are sent.
24
- *
25
- * Minted here, per create action, and deliberately not held in local data or the form: a new
26
- * Save must produce a new key, and only a retry of *this* request may reuse one. Nothing
27
- * retries today -- if a retry operator is ever added below, it has to sit inside this
28
- * mergeMap so the key is not re-minted, or the guarantee is silently lost.
29
- */
30
- const requestId = crypto.randomUUID();
31
- const payload = {
32
- ...(0, jeSchedulesPayload_1.prepareCreateOneTimeAccrualPayload)(state, localData),
33
- request_id: requestId,
34
- };
35
- // convertToPeriod destructures, so an unset period would throw here and take the epic
36
- // subscription down for the whole session — a missed refresh is the cheaper failure.
37
- const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
38
- const selectedPeriod = selectedMonthYear != null
39
- ? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
40
- : undefined;
41
- const periodStart = selectedPeriod != null
42
- ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
43
- : undefined;
44
- const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
45
- return zeniAPI
46
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
47
- .pipe((0, operators_1.mergeMap)((response) => {
48
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
49
- const successActions = [
50
- (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
51
- (0, jeSchedulesViewReducer_1.createOneTimeAccrualSuccess)(),
52
- (0, snackbarReducer_1.openSnackbar)({
53
- messageSection: 'create_schedule',
54
- messageText: 'success',
55
- type: 'success',
56
- variables: [
57
- {
58
- variableName: '_vendor_name_',
59
- variableValue: localData.vendorName,
60
- },
61
- ],
62
- }),
63
- ];
64
- // The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
65
- // per fetch, and the backend decides whether a freshly posted accrual belongs to
66
- // Review or Existing — so refetch rather than guess which bucket to insert into.
67
- if (periodStart != null && periodEnd != null) {
68
- successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
69
- }
70
- return (0, rxjs_1.from)(successActions);
71
- }
72
- return (0, rxjs_1.from)([
73
- (0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({ status: response.status }),
74
- (0, snackbarReducer_1.openSnackbar)({
75
- messageSection: 'create_schedule',
76
- messageText: 'failed',
77
- type: 'error',
78
- variables: [
79
- {
80
- variableName: '_api-error_',
81
- variableValue: response.status.message,
82
- },
83
- ],
84
- }),
85
- ]);
86
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
87
- (0, snackbarReducer_1.openSnackbar)({
88
- messageSection: 'create_schedule',
89
- messageText: 'failed',
90
- type: 'error',
91
- variables: [
92
- {
93
- variableName: '_api-error_',
94
- variableValue: JSON.stringify(error),
95
- },
96
- ],
97
- }),
98
- (0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({
99
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
100
- }),
101
- ])));
102
- }));
103
- exports.createOneTimeAccrualEpic = createOneTimeAccrualEpic;
@@ -1,8 +0,0 @@
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>;
@@ -1,29 +0,0 @@
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;
@@ -1,45 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { updateJESchedules, updateJESchedulesDetails } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
3
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
4
- import { RootState } from '../../../../../reducer';
5
- import { ZeniAPI } from '../../../../../zeniAPI';
6
- import { resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
7
- export type ActionType = ReturnType<typeof saveNewSchedule> | ReturnType<typeof saveNewScheduleSuccess> | ReturnType<typeof saveNewScheduleFailure> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof resetNewScheduleLocalData> | ReturnType<typeof openSnackbar>;
8
- export declare const saveNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
9
- payload: {
10
- messageSection: import("../../../../..").SnackbarMessageSections;
11
- messageText: import("../../../../..").SnackbarMessageSectionTexts;
12
- type: import("../../../../..").SnackbarMessageType;
13
- showStatusIcon?: boolean;
14
- variables?: {
15
- variableName: string;
16
- variableValue: string;
17
- }[];
18
- };
19
- type: "snackbar/openSnackbar";
20
- } | {
21
- payload: {
22
- jeSchedulesTransactionsPayload: import("../../../../../entity/jeSchedules/jeSchedulesPayload").JEScheduledTransactionPayload[];
23
- };
24
- type: "jeSchedules/updateJESchedules";
25
- } | {
26
- payload: {
27
- jeSchedulesPayload: import("../../../../../entity/jeSchedules/jeSchedulesPayload").JEScheduledTransactionPayload[];
28
- scheduledJEntriesPayload: import("../../../../../entity/jeSchedules/jeSchedulesPayload").ScheduledJournalEntryPayload[] | undefined;
29
- updateType: import("../../../../..").UpdateType;
30
- };
31
- type: "jeSchedules/updateJESchedulesDetails";
32
- } | {
33
- payload: {
34
- scheduleType: "prepaid_expenses" | "fixed_assets";
35
- };
36
- type: "expenseAutomationJESchedulesView/resetNewScheduleLocalData";
37
- } | {
38
- payload: undefined;
39
- type: "expenseAutomationJESchedulesView/saveNewScheduleSuccess";
40
- } | {
41
- payload: {
42
- status: import("../../../../../zeniAPIStatus").ZeniAPIStatus;
43
- };
44
- type: "expenseAutomationJESchedulesView/saveNewScheduleFailure";
45
- }>;
@@ -1,114 +0,0 @@
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 jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
7
- const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedulesTypes");
8
- const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
9
- const transactionSelector_1 = require("../../../../../entity/transaction/transactionSelector");
10
- const responsePayload_1 = require("../../../../../responsePayload");
11
- const newScheduleLocalDataHelper_1 = require("../../../helpers/newScheduleLocalDataHelper");
12
- const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
13
- const FAILURE_REASON_MESSAGES = {
14
- missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
15
- missing_vendor: 'Select a vendor before saving this schedule.',
16
- };
17
- const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.saveNewSchedule.match), (0, operators_1.mergeMap)((action) => {
18
- const { scheduleType } = action.payload;
19
- const state = state$.value;
20
- const localData = state.expenseAutomationJESchedulesViewState.newSchedule
21
- .newScheduleState[scheduleType];
22
- const { selectedBaseTransactionId } = localData;
23
- const transaction = selectedBaseTransactionId != null
24
- ? (0, transactionSelector_1.getScheduleTransactionById)(state.transactionState, (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)(selectedBaseTransactionId))
25
- : undefined;
26
- if (transaction == null) {
27
- return (0, rxjs_1.from)([
28
- (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
29
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No base transaction selected for this schedule.'),
30
- }),
31
- (0, snackbarReducer_1.openSnackbar)({
32
- messageSection: 'create_schedule',
33
- messageText: 'failed',
34
- type: 'error',
35
- variables: [
36
- {
37
- variableName: '_api-error_',
38
- variableValue: 'No base transaction selected.',
39
- },
40
- ],
41
- }),
42
- ]);
43
- }
44
- const result = (0, newScheduleLocalDataHelper_1.prepareNewSchedulePayload)(transaction, localData, scheduleType);
45
- if (!result.ok) {
46
- const message = FAILURE_REASON_MESSAGES[result.reason];
47
- return (0, rxjs_1.from)([
48
- (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
49
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', message),
50
- }),
51
- (0, snackbarReducer_1.openSnackbar)({
52
- messageSection: 'create_schedule',
53
- messageText: 'failed',
54
- type: 'error',
55
- variables: [{ variableName: '_api-error_', variableValue: message }],
56
- }),
57
- ]);
58
- }
59
- const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
60
- const queryParam = {
61
- je_schedule_type: scheduleType,
62
- };
63
- const payload = { ...result.payload };
64
- return zeniAPI
65
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
66
- .pipe((0, operators_1.mergeMap)((response) => {
67
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
68
- return (0, rxjs_1.from)([
69
- (0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules),
70
- (0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries),
71
- (0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType }),
72
- (0, jeSchedulesViewReducer_1.saveNewScheduleSuccess)(),
73
- (0, snackbarReducer_1.openSnackbar)({
74
- messageSection: 'create_schedule',
75
- messageText: 'success',
76
- type: 'success',
77
- variables: [
78
- { variableName: '_vendor_name_', variableValue: vendorName },
79
- ],
80
- }),
81
- ]);
82
- }
83
- return (0, rxjs_1.from)([
84
- (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({ status: response.status }),
85
- (0, snackbarReducer_1.openSnackbar)({
86
- messageSection: 'create_schedule',
87
- messageText: 'failed',
88
- type: 'error',
89
- variables: [
90
- {
91
- variableName: '_api-error_',
92
- variableValue: response.status.message,
93
- },
94
- ],
95
- }),
96
- ]);
97
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
98
- (0, snackbarReducer_1.openSnackbar)({
99
- messageSection: 'create_schedule',
100
- messageText: 'failed',
101
- type: 'error',
102
- variables: [
103
- {
104
- variableName: '_api-error_',
105
- variableValue: JSON.stringify(error),
106
- },
107
- ],
108
- }),
109
- (0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
110
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
111
- }),
112
- ])));
113
- }));
114
- exports.saveNewScheduleEpic = saveNewScheduleEpic;
@@ -1,8 +0,0 @@
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>;
@@ -1,83 +0,0 @@
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;
@@ -1,12 +0,0 @@
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 { ZeniAPI } from '../../../../zeniAPI';
7
- import { fetchJeSchedules, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertOneTimeAccrual } from '../../reducers/jeSchedulesViewReducer';
8
- export type ActionType = ReturnType<typeof promoteOneTimeAccrual> | ReturnType<typeof revertOneTimeAccrual> | ReturnType<typeof ignoreOneTimeAccrual> | ReturnType<typeof oneTimeAccrualActionSuccess> | ReturnType<typeof oneTimeAccrualActionFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
9
- export declare const promoteOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
10
- export declare const ignoreOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
11
- export declare const revertOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
12
- export declare const oneTimeAccrualActionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,146 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.oneTimeAccrualActionsEpic = exports.revertOneTimeAccrualEpic = exports.ignoreOneTimeAccrualEpic = exports.promoteOneTimeAccrualEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
- const jeScheduleHelper_1 = require("../../../../entity/jeSchedules/jeScheduleHelper");
8
- const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
9
- const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
10
- const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
11
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
12
- const responsePayload_1 = require("../../../../responsePayload");
13
- const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
14
- /**
15
- * The page the accrual came from, so a promoted or ignored row lands in the right bucket. Guarded
16
- * because convertToPeriod destructures: an unset period would throw and take the epic subscription
17
- * down for the session, and a missed refresh is the cheaper failure.
18
- */
19
- function refreshCurrentPage(state) {
20
- const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
21
- if (selectedMonthYear == null) {
22
- return [];
23
- }
24
- const period = (0, timePeriod_1.convertToPeriod)(selectedMonthYear);
25
- const start = (0, timePeriod_1.toAbsoluteDay)(period.start);
26
- const end = (0, timePeriod_1.toAbsoluteDay)(period.end);
27
- if (start == null || end == null) {
28
- return [];
29
- }
30
- return [(0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start, end }, true)];
31
- }
32
- function failureActions(accrualId, message, status) {
33
- return [
34
- (0, jeSchedulesViewReducer_1.oneTimeAccrualActionFailure)({
35
- accrualId,
36
- status: status ?? (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', message),
37
- }),
38
- (0, snackbarReducer_1.openSnackbar)({
39
- messageSection: 'save_schedule',
40
- messageText: 'failed',
41
- type: 'error',
42
- variables: [{ variableName: '_api-error_', variableValue: message }],
43
- }),
44
- ];
45
- }
46
- const promoteOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.promoteOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
47
- const state = state$.value;
48
- const { accrualId, amount } = action.payload;
49
- const accrual = (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)((0, jeScheduleHelper_1.generateJEOneTimeAccrualKey)(accrualId), state.jeSchedulesState);
50
- if (accrual?.jeDebitAccountId == null ||
51
- accrual.jeCreditAccountId == null) {
52
- // Promote posts a journal entry, so it cannot proceed without both sides of it.
53
- return (0, rxjs_1.from)(failureActions(accrualId, 'This accrual is missing an expense or liability account.'));
54
- }
55
- // vendor_id, vendor_name and service_month are deliberately absent: promote takes them from
56
- // the stored draft and ignores them in the body, so sending them would imply a reassignment
57
- // that never happens.
58
- const payload = {
59
- amount,
60
- memo: accrual.memo,
61
- je_debit_account_id: accrual.jeDebitAccountId,
62
- je_credit_account_id: accrual.jeCreditAccountId,
63
- };
64
- return zeniAPI
65
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`, { ...payload })
66
- .pipe((0, operators_1.mergeMap)((response) => {
67
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
68
- return (0, rxjs_1.from)([
69
- (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
70
- (0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
71
- (0, snackbarReducer_1.openSnackbar)({
72
- messageSection: 'save_schedule',
73
- messageText: 'success',
74
- type: 'success',
75
- variables: [
76
- {
77
- variableName: '_vendor_name_',
78
- variableValue: accrual.vendorName,
79
- },
80
- ],
81
- }),
82
- ...refreshCurrentPage(state),
83
- ]);
84
- }
85
- return (0, rxjs_1.from)(failureActions(accrualId, response.status.message, response.status));
86
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions(accrualId, `Promote accrual REST API call errored out ${JSON.stringify(error)}`))));
87
- }));
88
- exports.promoteOneTimeAccrualEpic = promoteOneTimeAccrualEpic;
89
- const ignoreOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.ignoreOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
90
- const state = state$.value;
91
- const { accrualId, reason, note } = action.payload;
92
- // `scope` is deliberately never sent: the API returns 400 on it, which is why the design's
93
- // "Apply to" selector cannot be built yet.
94
- const payload = {
95
- reason,
96
- ...(note != null && note !== '' ? { note } : {}),
97
- };
98
- return zeniAPI
99
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/ignore`, { ...payload })
100
- .pipe((0, operators_1.mergeMap)((response) => {
101
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
102
- return (0, rxjs_1.from)([
103
- (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
104
- (0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
105
- (0, snackbarReducer_1.openSnackbar)({
106
- messageSection: 'ignore_accrual',
107
- messageText: 'success',
108
- type: 'success',
109
- }),
110
- ...refreshCurrentPage(state),
111
- ]);
112
- }
113
- return (0, rxjs_1.from)(failureActions(accrualId, response.status.message, response.status));
114
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions(accrualId, `Ignore accrual REST API call errored out ${JSON.stringify(error)}`))));
115
- }));
116
- exports.ignoreOneTimeAccrualEpic = ignoreOneTimeAccrualEpic;
117
- const revertOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.revertOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
118
- const state = state$.value;
119
- const { accrualId, reason, note } = action.payload;
120
- // Deletes the accrual's journal entry in QBO and soft-deletes the row. `scope` is never sent:
121
- // the endpoint 400s on it, exactly as ignore does.
122
- const payload = {
123
- reason,
124
- ...(note != null && note !== '' ? { note } : {}),
125
- };
126
- return zeniAPI
127
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/revert`, { ...payload })
128
- .pipe((0, operators_1.mergeMap)((response) => {
129
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
130
- return (0, rxjs_1.from)([
131
- (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
132
- (0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
133
- (0, snackbarReducer_1.openSnackbar)({
134
- messageSection: 'revert_accrual',
135
- messageText: 'success',
136
- type: 'success',
137
- }),
138
- ...refreshCurrentPage(state),
139
- ]);
140
- }
141
- return (0, rxjs_1.from)(failureActions(accrualId, response.status.message, response.status));
142
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions(accrualId, `Revert accrual REST API call errored out ${JSON.stringify(error)}`))));
143
- }));
144
- exports.revertOneTimeAccrualEpic = revertOneTimeAccrualEpic;
145
- const oneTimeAccrualActionsEpic = (actions$, state$, zeniAPI) => (0, rxjs_1.merge)((0, exports.promoteOneTimeAccrualEpic)(actions$, state$, zeniAPI), (0, exports.ignoreOneTimeAccrualEpic)(actions$, state$, zeniAPI), (0, exports.revertOneTimeAccrualEpic)(actions$, state$, zeniAPI));
146
- exports.oneTimeAccrualActionsEpic = oneTimeAccrualActionsEpic;