@zeniai/client-epic-state 5.1.91 → 5.1.92-betaRD0

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 (126) hide show
  1. package/lib/entity/aiCfo/aiCfoState.d.ts +2 -2
  2. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +2 -0
  3. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
  5. package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
  6. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  7. package/lib/entity/jeSchedules/jeSchedulesReducer.js +24 -2
  8. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  9. package/lib/entity/jeSchedules/jeSchedulesSelector.js +34 -3
  10. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
  11. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  12. package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
  13. package/lib/entity/snackbar/snackbarApiError.d.ts +8 -0
  14. package/lib/entity/snackbar/snackbarApiError.js +15 -0
  15. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  16. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  17. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  18. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  19. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  20. package/lib/epic.d.ts +8 -1
  21. package/lib/epic.js +8 -1
  22. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  23. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
  24. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +24 -2
  25. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +32 -2
  26. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
  27. package/lib/esm/entity/snackbar/snackbarApiError.js +11 -0
  28. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  29. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  30. package/lib/esm/epic.js +8 -1
  31. package/lib/esm/index.js +13 -7
  32. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  33. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  35. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +81 -0
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +21 -0
  37. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
  38. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +73 -0
  39. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +129 -0
  40. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +92 -0
  41. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
  42. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  43. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  44. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +268 -29
  45. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
  46. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  47. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +286 -22
  48. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
  49. package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +2 -0
  50. package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +2 -0
  51. package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +6 -3
  52. package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +6 -3
  53. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +5 -4
  54. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -0
  55. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -0
  56. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +2 -0
  57. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +2 -0
  58. package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +7 -3
  59. package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +2 -0
  60. package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +2 -0
  61. package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +2 -0
  62. package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +3 -0
  63. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +6 -3
  64. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +52 -0
  65. package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +6 -3
  66. package/lib/esm/view/vendorTabView/vendorTabViewReducer.js +1 -1
  67. package/lib/index.d.ts +18 -14
  68. package/lib/index.js +92 -49
  69. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  71. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +38 -2
  72. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  73. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
  74. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +85 -0
  75. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  76. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  77. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
  78. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +77 -0
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +12 -0
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +136 -0
  83. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
  84. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +96 -0
  85. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
  86. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
  87. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  88. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  89. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  90. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
  91. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  92. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +79 -11
  93. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +270 -29
  94. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  95. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  96. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  97. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
  98. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +34 -8
  99. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  100. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  101. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +31 -1
  102. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -21
  103. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  104. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +81 -8
  105. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  106. package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +2 -0
  107. package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +2 -0
  108. package/lib/view/invoicing/discountAction/discountActionEpic.js +5 -2
  109. package/lib/view/invoicing/dunningAction/dunningActionEpic.js +5 -2
  110. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +5 -4
  111. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -0
  112. package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -0
  113. package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +2 -0
  114. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +2 -0
  115. package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +6 -2
  116. package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +2 -0
  117. package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +2 -0
  118. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
  119. package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +1 -1
  120. package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +2 -0
  121. package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +3 -0
  122. package/lib/view/invoicing/settingsView/settingsViewEpics.js +5 -2
  123. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +41 -1
  124. package/lib/view/invoicing/settingsView/settingsViewSelector.js +55 -1
  125. package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +5 -2
  126. package/package.json +1 -1
@@ -11,6 +11,7 @@ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer"
11
11
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
12
12
  const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
13
13
  const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
14
+ const jeSchedulesViewState_1 = require("../../types/jeSchedulesViewState");
14
15
  const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(expenseAutomationViewReducer_1.fetchAllExpenseAutomationTabs.match), (0, operators_1.switchMap)((action) => {
15
16
  const { cacheOverride, refreshViewInBackground } = action.payload;
16
17
  const state = state$.value;
@@ -62,14 +63,16 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
62
63
  state.expenseAutomationFluxAnalysisViewState.groupsBySelectedPeriod[monthYearPeriodId] == null)) {
63
64
  fetchActions.push((0, fluxAnalysisViewReducer_1.fetchFluxAnalysisView)(selectedPeriod, cacheOverride, refreshViewInBackground, null));
64
65
  }
66
+ // The two JE tabs cache separately, so only the tab actually being shown decides whether a
67
+ // fetch is still needed.
68
+ const jeSchedulesPeriodTabKey = (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab, monthYearPeriodId);
65
69
  if (state.expenseAutomationJESchedulesViewState.fetchState !==
66
70
  'In-Progress' &&
67
71
  (!state.expenseAutomationJESchedulesViewState.hasValidState() ||
68
72
  state.expenseAutomationJESchedulesViewState
69
- .jeScheduleTransactionKeysByPeriod[monthYearPeriodId] == null ||
73
+ .jeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null ||
70
74
  state.expenseAutomationJESchedulesViewState
71
- .failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId] ==
72
- null)) {
75
+ .failedJeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null)) {
73
76
  fetchActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
74
77
  }
75
78
  if (state.expenseAutomationReconciliationViewState.fetchState !==
@@ -1,8 +1,9 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
- import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
3
+ import { updateAccruedJESchedules, updateAccruedJESchedulesDetails, updateJEOneTimeAccruals, updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
4
  import { RootState } from '../../../../reducer';
5
+ import { clearAll } from '../../../../rootActions';
5
6
  import { ZeniAPI } from '../../../../zeniAPI';
6
7
  import { fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesSuccess, initializeJeScheduleLocalData } from '../../reducers/jeSchedulesViewReducer';
7
- export type ActionType = ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesFailure> | ReturnType<typeof fetchJeSchedulesSuccess> | ReturnType<typeof initializeJeScheduleLocalData> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
8
+ export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesFailure> | ReturnType<typeof fetchJeSchedulesSuccess> | ReturnType<typeof initializeJeScheduleLocalData> | ReturnType<typeof updateAccruedJESchedules> | ReturnType<typeof updateAccruedJESchedulesDetails> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
8
9
  export declare const fetchJeSchedulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchJeSchedulesEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
+ const formatZeniDateFY_1 = require("../../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
6
7
  const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
8
  const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
8
9
  const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
9
10
  const responsePayload_1 = require("../../../../responsePayload");
11
+ const rootActions_1 = require("../../../../rootActions");
12
+ const zeniDayJS_1 = require("../../../../zeniDayJS");
10
13
  const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
11
14
  const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.fetchJeSchedules.match), (0, operators_1.mergeMap)((action) => {
12
15
  const state = state$.value;
@@ -14,27 +17,54 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
14
17
  const { period, refreshViewInBackground } = action.payload;
15
18
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
16
19
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
20
+ const { selectedPageTab } = state.expenseAutomationJESchedulesViewState.uiState;
21
+ const isClosePeriodTab = selectedPageTab === 'schedules';
22
+ const existingEndDate = (0, timePeriod_1.toAbsoluteDay)((0, zeniDayJS_1.date)((0, timePeriod_1.toString)(period.start))
23
+ .subtract(1, 'month')
24
+ .endOf('month')
25
+ .format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT));
17
26
  const queryParam = {
18
27
  start_date: (0, timePeriod_1.toString)(period.start),
19
- end_date: (0, timePeriod_1.toString)(period.end),
28
+ end_date: isClosePeriodTab || existingEndDate == null
29
+ ? (0, timePeriod_1.toString)(period.end)
30
+ : (0, timePeriod_1.toString)(existingEndDate),
31
+ include_accrued: true,
32
+ ...(isClosePeriodTab
33
+ ? { close_period_start_date: (0, timePeriod_1.toString)(period.start) }
34
+ : {}),
20
35
  };
21
36
  return zeniAPI
22
37
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/je_schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
23
38
  .pipe((0, operators_1.mergeMap)((response) => {
24
39
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
25
40
  const updateActions = [];
41
+ const accruedJeSchedules = response.data.accrued_je_schedules?.je_schedules ?? [];
42
+ const oneTimeAccruals = response.data.one_time_accruals ?? [];
26
43
  updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)([
27
44
  ...response.data.je_schedules,
28
45
  ...response.data.failed_je_postings.je_schedules,
29
46
  ]), (0, jeSchedulesReducer_1.updateJESchedulesDetails)([...response.data.failed_je_postings.je_schedules], response.data.failed_je_postings.scheduled_journal_entries), (0, jeSchedulesViewReducer_1.initializeJeScheduleLocalData)([
30
47
  ...response.data.failed_je_postings.je_schedules,
31
48
  ]));
49
+ if (accruedJeSchedules.length > 0) {
50
+ updateActions.push((0, jeSchedulesReducer_1.updateAccruedJESchedules)(accruedJeSchedules), (0, jeSchedulesReducer_1.updateAccruedJESchedulesDetails)(accruedJeSchedules, response.data.accrued_je_schedules
51
+ ?.scheduled_journal_entries));
52
+ }
53
+ if (oneTimeAccruals.length > 0) {
54
+ // Single action, unlike the accrued pair above: this one writes the entity
55
+ // directly because an accrual denormalizes its vendor, accounts and classes, so
56
+ // there is no fan-out fetch to trigger.
57
+ updateActions.push((0, jeSchedulesReducer_1.updateJEOneTimeAccruals)(oneTimeAccruals));
58
+ }
32
59
  updateActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesSuccess)({
33
60
  jeSchedules: [...response.data.je_schedules],
34
61
  failedJeSchedules: [
35
62
  ...response.data.failed_je_postings.je_schedules,
36
63
  ],
64
+ accruedJeSchedules: accruedJeSchedules,
65
+ oneTimeAccruals: oneTimeAccruals,
37
66
  selectedPeriod: selectedPeriod,
67
+ selectedPageTab: selectedPageTab,
38
68
  refreshViewInBackground: refreshViewInBackground,
39
69
  }));
40
70
  return (0, rxjs_1.from)(updateActions);
@@ -43,12 +73,18 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
43
73
  return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesFailure)({
44
74
  status: response.status,
45
75
  selectedPeriod,
76
+ selectedPageTab,
46
77
  }));
47
78
  }
48
79
  }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesFailure)({
49
80
  status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch JE schedules REST API call errored out' +
50
81
  JSON.stringify(error)),
51
82
  selectedPeriod,
52
- }))));
83
+ selectedPageTab,
84
+ }))),
85
+ // A tenant switch clears the store while this request is still in flight. Without this
86
+ // the old tenant's rows are written back into the freshly cleared store and stay on
87
+ // screen under the new tenant until a manual refresh.
88
+ (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
53
89
  }));
54
90
  exports.fetchJeSchedulesEpic = fetchJeSchedulesEpic;
@@ -14,13 +14,25 @@ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer"
14
14
  const ignoreRecommendedJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.ignoreRecommendedJeSchedule.match), (0, operators_1.mergeMap)((action) => {
15
15
  const state = state$.value;
16
16
  const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
17
- const { scheduleType, jeScheduleTransactionKey } = action.payload;
17
+ const { scheduleType, jeScheduleTransactionKey, reason, note } = action.payload;
18
18
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
19
19
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
20
20
  const actions = [];
21
21
  const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleTransactionKey, state);
22
+ const ignorePayload = (0, jeSchedulesPayload_1.prepareIgnoreSchedulePayload)(scheduleType, jeScheduleTransactionState, state);
23
+ // The gateway reads reason/note from je_schedules[0].feedback and nowhere else, and rejects
24
+ // anything but those two keys inside it — `action` is stamped server-side.
22
25
  const payload = {
23
- ...(0, jeSchedulesPayload_1.prepareIgnoreSchedulePayload)(scheduleType, jeScheduleTransactionState, state),
26
+ ...ignorePayload,
27
+ je_schedules: ignorePayload.je_schedules.map((schedule, index) => index === 0
28
+ ? {
29
+ ...schedule,
30
+ feedback: {
31
+ reason,
32
+ ...(note != null && note !== '' ? { note } : {}),
33
+ },
34
+ }
35
+ : schedule),
24
36
  };
25
37
  const queryParam = {
26
38
  je_schedule_type: scheduleType,
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,85 @@
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
+ const payload = { ...(0, jeSchedulesPayload_1.prepareCreateOneTimeAccrualPayload)(state, localData) };
17
+ // convertToPeriod destructures, so an unset period would throw here and take the epic
18
+ // subscription down for the whole session — a missed refresh is the cheaper failure.
19
+ const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
20
+ const selectedPeriod = selectedMonthYear != null
21
+ ? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
22
+ : undefined;
23
+ const periodStart = selectedPeriod != null
24
+ ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
25
+ : undefined;
26
+ const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
27
+ return zeniAPI
28
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
29
+ .pipe((0, operators_1.mergeMap)((response) => {
30
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
31
+ const successActions = [
32
+ (0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
33
+ (0, jeSchedulesViewReducer_1.createOneTimeAccrualSuccess)(),
34
+ (0, snackbarReducer_1.openSnackbar)({
35
+ messageSection: 'create_schedule',
36
+ messageText: 'success',
37
+ type: 'success',
38
+ variables: [
39
+ {
40
+ variableName: '_vendor_name_',
41
+ variableValue: localData.vendorName,
42
+ },
43
+ ],
44
+ }),
45
+ ];
46
+ // The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
47
+ // per fetch, and the backend decides whether a freshly posted accrual belongs to
48
+ // Review or Existing — so refetch rather than guess which bucket to insert into.
49
+ if (periodStart != null && periodEnd != null) {
50
+ successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
51
+ }
52
+ return (0, rxjs_1.from)(successActions);
53
+ }
54
+ return (0, rxjs_1.from)([
55
+ (0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({ status: response.status }),
56
+ (0, snackbarReducer_1.openSnackbar)({
57
+ messageSection: 'create_schedule',
58
+ messageText: 'failed',
59
+ type: 'error',
60
+ variables: [
61
+ {
62
+ variableName: '_api-error_',
63
+ variableValue: response.status.message,
64
+ },
65
+ ],
66
+ }),
67
+ ]);
68
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
69
+ (0, snackbarReducer_1.openSnackbar)({
70
+ messageSection: 'create_schedule',
71
+ messageText: 'failed',
72
+ type: 'error',
73
+ variables: [
74
+ {
75
+ variableName: '_api-error_',
76
+ variableValue: JSON.stringify(error),
77
+ },
78
+ ],
79
+ }),
80
+ (0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({
81
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
82
+ }),
83
+ ])));
84
+ }));
85
+ exports.createOneTimeAccrualEpic = createOneTimeAccrualEpic;
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../../reducer';
4
+ import { fetchAccountList } from '../../../../accountList/accountListReducer';
5
+ import { fetchClassList } from '../../../../classList/classListReducer';
6
+ import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData } from '../../../reducers/jeSchedulesViewReducer';
7
+ export type ActionType = ReturnType<typeof clearSearchTransactionsForNewSchedule> | ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchClassList> | ReturnType<typeof initializeNewSchedule> | ReturnType<typeof resetNewScheduleLocalData>;
8
+ export declare const initializeNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -0,0 +1,25 @@
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
+ newScheduleActions.push((0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType: action.payload.scheduleType }));
22
+ newScheduleActions.push((0, jeSchedulesViewReducer_1.clearSearchTransactionsForNewSchedule)());
23
+ return (0, rxjs_1.from)(newScheduleActions);
24
+ }));
25
+ exports.initializeNewScheduleEpic = initializeNewScheduleEpic;
@@ -0,0 +1,45 @@
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("../../../../../responsePayload").ZeniAPIStatus;
43
+ };
44
+ type: "expenseAutomationJESchedulesView/saveNewScheduleFailure";
45
+ }>;
@@ -0,0 +1,114 @@
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;
@@ -0,0 +1,8 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
7
+ export type ActionType = ReturnType<typeof searchTransactionsForNewSchedule> | ReturnType<typeof searchTransactionsForNewScheduleSuccess> | ReturnType<typeof searchTransactionsForNewScheduleFailure> | ReturnType<typeof updateScheduleTransactions>;
8
+ export declare const searchTransactionsForNewScheduleEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,77 @@
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
+ /** Dropdown-sized result set — no pagination for Base Transaction search. */
13
+ const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
14
+ /** Fallback when the backend sends a null currency for a search result. */
15
+ const DEFAULT_CURRENCY_CODE = 'USD';
16
+ const DEFAULT_CURRENCY_SYMBOL = '$';
17
+ const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
18
+ const searchActions$ = actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.searchTransactionsForNewSchedule.match));
19
+ /** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
20
+ const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH));
21
+ 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));
22
+ return (0, rxjs_1.merge)(newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
23
+ const query = action.payload.query.trim();
24
+ if (query.length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
25
+ return rxjs_1.EMPTY;
26
+ }
27
+ const queryParam = {
28
+ page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
29
+ search_text: query,
30
+ je_schedule_type: action.payload.scheduleType,
31
+ };
32
+ return zeniAPI
33
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
34
+ .pipe((0, operators_1.mergeMap)((response) => {
35
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
36
+ const { transactions } = response.data;
37
+ const transactionsPerCurrency = {};
38
+ transactions.forEach((transaction) => {
39
+ const { currency_code, currency_symbol } = transaction;
40
+ const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
41
+ const existing = transactionsPerCurrency[currencyCode];
42
+ transactionsPerCurrency[currencyCode] =
43
+ existing != null
44
+ ? {
45
+ currencySymbol: existing.currencySymbol,
46
+ transactions: [...existing.transactions, transaction],
47
+ }
48
+ : {
49
+ currencySymbol: currency_code == null
50
+ ? DEFAULT_CURRENCY_SYMBOL
51
+ : currency_symbol,
52
+ transactions: [transaction],
53
+ };
54
+ });
55
+ const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
56
+ const perCurrency = transactionsPerCurrency[currencyCode];
57
+ return (0, transactionReducer_1.updateScheduleTransactions)(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
58
+ });
59
+ actionsOut.push((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleSuccess)({
60
+ searchResults: transactions.map((transaction) => (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)({
61
+ id: transaction.transaction_id,
62
+ type: (0, transactionType_1.toTransactionType)(transaction.transaction_type),
63
+ lineId: transaction.line_id,
64
+ })),
65
+ }));
66
+ return (0, rxjs_1.from)(actionsOut);
67
+ }
68
+ return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
69
+ status: response.status,
70
+ }));
71
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
72
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for new schedule errored: ' +
73
+ JSON.stringify(error)),
74
+ }))));
75
+ }));
76
+ };
77
+ exports.searchTransactionsForNewScheduleEpic = searchTransactionsForNewScheduleEpic;
@@ -0,0 +1,12 @@
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>;