@zeniai/client-epic-state 5.2.7-betaRD1 → 5.2.8

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 (151) hide show
  1. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +22 -0
  2. package/lib/entity/invoicing/invoicingCommonPayload.js +51 -10
  3. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +0 -1
  4. package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
  5. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -66
  6. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -135
  7. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
  8. package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  9. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -11
  10. package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -38
  11. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -79
  12. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -24
  13. package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -88
  14. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  15. package/lib/entity/snackbar/snackbarTypes.js +0 -3
  16. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
  17. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  18. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
  19. package/lib/epic.d.ts +1 -9
  20. package/lib/epic.js +0 -16
  21. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +51 -10
  22. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
  23. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -135
  24. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -30
  25. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -36
  26. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -78
  27. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
  28. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
  29. package/lib/esm/epic.js +0 -16
  30. package/lib/esm/index.js +8 -14
  31. package/lib/esm/view/accountList/accountListReducer.js +0 -1
  32. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  33. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +5 -41
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  35. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +0 -55
  36. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -306
  37. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -294
  38. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
  39. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +2 -1
  40. package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +2 -0
  41. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +10 -5
  42. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +27 -3
  43. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +7 -3
  44. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  45. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  46. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  47. package/lib/index.d.ts +12 -17
  48. package/lib/index.js +47 -91
  49. package/lib/view/accountList/accountListReducer.js +0 -1
  50. package/lib/view/accountList/accountListState.d.ts +1 -1
  51. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
  52. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -3
  53. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -39
  54. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
  55. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  56. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +3 -72
  57. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -58
  58. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +12 -91
  59. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -308
  60. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  61. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  62. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +7 -36
  63. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +0 -34
  64. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -302
  65. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  66. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -82
  67. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  68. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  69. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +5 -0
  70. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +1 -0
  71. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +1 -0
  72. package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +2 -0
  73. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +10 -5
  74. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +9 -1
  75. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +30 -4
  76. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +11 -4
  77. package/lib/view/invoicing/settingsView/settingsViewSelector.js +7 -3
  78. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  79. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
  80. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +2 -4
  81. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
  82. package/package.json +1 -1
  83. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
  84. package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  85. package/lib/entity/invoicing/coupon/couponConstants.d.ts +0 -11
  86. package/lib/entity/invoicing/coupon/couponConstants.js +0 -29
  87. package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
  88. package/lib/esm/entity/invoicing/coupon/couponConstants.js +0 -26
  89. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -45
  90. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -81
  91. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
  92. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
  93. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -79
  94. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -139
  95. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -106
  96. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -22
  97. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
  98. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
  99. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -106
  100. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -25
  101. package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -15
  102. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -18
  103. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -18
  104. package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -18
  105. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -16
  106. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -1
  107. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -60
  108. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -12
  109. package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -1
  110. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +0 -20
  111. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -49
  112. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +0 -8
  113. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -85
  114. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
  115. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -29
  116. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -45
  117. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -114
  118. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
  119. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -83
  120. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +0 -12
  121. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -146
  122. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +0 -64
  123. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -110
  124. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
  125. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -26
  126. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
  127. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
  128. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -42
  129. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
  130. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -21
  131. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -112
  132. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +0 -6
  133. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -29
  134. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +0 -6
  135. package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -19
  136. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +0 -8
  137. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -22
  138. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +0 -8
  139. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -22
  140. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +0 -8
  141. package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -22
  142. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +0 -13
  143. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -20
  144. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +0 -11
  145. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -2
  146. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +0 -7
  147. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -64
  148. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +0 -12
  149. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -15
  150. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +0 -9
  151. package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -2
@@ -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;
@@ -1,64 +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 { JEScheduleKey, JEScheduleTransactionKey } from '../../../../entity/jeSchedules/jeSchedulesTypes';
5
- import { RootState } from '../../../../reducer';
6
- import { ZeniAPI } from '../../../../zeniAPI';
7
- import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
8
- import { removeJeAccruedScheduleKey, removeJeScheduleTransactionKey, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess } from '../../reducers/jeSchedulesViewReducer';
9
- export type ActionType = ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof openSnackbar> | ReturnType<typeof removeJeAccruedScheduleKey> | ReturnType<typeof removeJeScheduleTransactionKey> | ReturnType<typeof revertJeSchedule> | ReturnType<typeof revertJeScheduleFailure> | ReturnType<typeof revertJeScheduleSuccess> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
10
- /**
11
- * Undo a posted prepaid / fixed-asset / accrued schedule: deletes its posted QBO journal entry, then
12
- * soft-deletes the scheduled entries and the schedule itself.
13
- *
14
- * Two or more posted journal entries answer 409 and leave the schedule intact, so the failure is
15
- * surfaced rather than swallowed. Accrued has one extra rejection of its own — the endpoint refuses
16
- * once a bill has been linked, because the reversal is already on the books — and that arrives the
17
- * same way, as an error on the row.
18
- *
19
- * A one-time accrual is not this action: it is a Mongo row behind the accruals gateway, and goes
20
- * through revertOneTimeAccrual instead. So `accrued_expenses` here always means an accrued
21
- * *schedule*, which is what makes it a safe discriminator for the removal below.
22
- */
23
- export declare const revertJeScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
24
- payload: {
25
- messageSection: import("../../../..").SnackbarMessageSections;
26
- messageText: import("../../../..").SnackbarMessageSectionTexts;
27
- type: import("../../../..").SnackbarMessageType;
28
- showStatusIcon?: boolean;
29
- variables?: {
30
- variableName: string;
31
- variableValue: string;
32
- }[];
33
- };
34
- type: "snackbar/openSnackbar";
35
- } | {
36
- payload: {
37
- period: import("../../../..").MonthYearPeriod;
38
- refreshViewInBackground: boolean;
39
- tenantId: import("../../../..").ID;
40
- };
41
- type: "monthEndCloseChecksView/fetchMonthEndCloseChecks";
42
- } | {
43
- payload: {
44
- jeScheduleKey: `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_refund_${string}` | `${string}_bill_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`;
45
- selectedPeriod: import("../../../..").MonthYearPeriod;
46
- };
47
- type: "expenseAutomationJESchedulesView/removeJeScheduleTransactionKey";
48
- } | {
49
- payload: {
50
- jeAccruedScheduleKey: `${string}_${string}`;
51
- };
52
- type: "expenseAutomationJESchedulesView/removeJeAccruedScheduleKey";
53
- } | {
54
- payload: {
55
- jeScheduleTransactionKey: JEScheduleKey | JEScheduleTransactionKey;
56
- status: import("../../../../zeniAPIStatus").ZeniAPIStatus;
57
- };
58
- type: "expenseAutomationJESchedulesView/revertJeScheduleFailure";
59
- } | {
60
- payload: {
61
- jeScheduleTransactionKey: JEScheduleKey | JEScheduleTransactionKey;
62
- };
63
- type: "expenseAutomationJESchedulesView/revertJeScheduleSuccess";
64
- }>;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.revertJeScheduleEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
- const responsePayload_1 = require("../../../../responsePayload");
9
- const monthEndCloseChecksViewReducer_1 = require("../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer");
10
- const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
11
- /**
12
- * Undo a posted prepaid / fixed-asset / accrued schedule: deletes its posted QBO journal entry, then
13
- * soft-deletes the scheduled entries and the schedule itself.
14
- *
15
- * Two or more posted journal entries answer 409 and leave the schedule intact, so the failure is
16
- * surfaced rather than swallowed. Accrued has one extra rejection of its own — the endpoint refuses
17
- * once a bill has been linked, because the reversal is already on the books — and that arrives the
18
- * same way, as an error on the row.
19
- *
20
- * A one-time accrual is not this action: it is a Mongo row behind the accruals gateway, and goes
21
- * through revertOneTimeAccrual instead. So `accrued_expenses` here always means an accrued
22
- * *schedule*, which is what makes it a safe discriminator for the removal below.
23
- */
24
- const revertJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.revertJeSchedule.match), (0, operators_1.mergeMap)((action) => {
25
- const state = state$.value;
26
- const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
27
- const { jeScheduleId, jeScheduleTransactionKey, reason, note, scheduleType } = action.payload;
28
- const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
29
- const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
30
- // Feedback nested under je_schedules[0], the same shape ignore takes -- the two endpoints were
31
- // made symmetric server-side. A flat {reason, note} body, which this epic used to send while
32
- // revert validated the whole body as feedback, now answers 400 "Request body must contain at
33
- // least one of je_schedules".
34
- //
35
- // Only the id and the feedback: the rest of the fat blob is read from Datastore, not the
36
- // request. The id is optional server-side but sent anyway, because it is validated against the
37
- // URL and so turns a mismatch into a 400 rather than a revert of the wrong schedule.
38
- // `action` is stamped server-side.
39
- const payload = {
40
- je_schedules: [
41
- {
42
- je_schedule_id: jeScheduleId,
43
- feedback: {
44
- reason,
45
- ...(note != null && note !== '' ? { note } : {}),
46
- },
47
- },
48
- ],
49
- };
50
- return zeniAPI
51
- .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/revert`, payload)
52
- .pipe((0, operators_1.mergeMap)((response) => {
53
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
54
- // Deliberately not written to the entity store. A reverted schedule is soft-deleted,
55
- // so the endpoint returns its flat entity json -- `vendor_id` as a bare field, no
56
- // nested `vendor` or `base_transaction` -- rather than the list DTO those mappers
57
- // expect. Feeding it to updateJESchedules threw inside doUpdateVendors on
58
- // `payload.vendor.vendor_id`, and because that happens mid-dispatch it killed the
59
- // rest of this array: the row kept spinning and no snackbar appeared. The row is
60
- // removed from the list below regardless, so there is nothing worth storing.
61
- return (0, rxjs_1.from)([
62
- (0, jeSchedulesViewReducer_1.revertJeScheduleSuccess)({ jeScheduleTransactionKey }),
63
- // Accrued keys live in their own per-tab map, so the transaction-key removal cannot
64
- // reach them -- a reverted accrued schedule would sit on the list until the next
65
- // fetch. The key carried here is a JEScheduleKey for that type.
66
- scheduleType === 'accrued_expenses'
67
- ? (0, jeSchedulesViewReducer_1.removeJeAccruedScheduleKey)(jeScheduleTransactionKey)
68
- : (0, jeSchedulesViewReducer_1.removeJeScheduleTransactionKey)(jeScheduleTransactionKey, selectedPeriod),
69
- (0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
70
- tenantId: currentTenant.tenantId,
71
- period: selectedPeriod,
72
- refreshViewInBackground: true,
73
- }),
74
- (0, snackbarReducer_1.openSnackbar)({
75
- messageSection: 'revert_schedule',
76
- messageText: 'success',
77
- type: 'success',
78
- }),
79
- ]);
80
- }
81
- return (0, rxjs_1.from)([
82
- (0, jeSchedulesViewReducer_1.revertJeScheduleFailure)({
83
- jeScheduleTransactionKey,
84
- status: response.status,
85
- }),
86
- (0, snackbarReducer_1.openSnackbar)({
87
- messageSection: 'revert_schedule',
88
- messageText: 'failed',
89
- type: 'error',
90
- variables: [
91
- {
92
- variableName: '_api-error_',
93
- variableValue: response.status.message,
94
- },
95
- ],
96
- }),
97
- ]);
98
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
99
- (0, jeSchedulesViewReducer_1.revertJeScheduleFailure)({
100
- jeScheduleTransactionKey,
101
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Revert schedule REST API call errored out ${JSON.stringify(error)}`),
102
- }),
103
- (0, snackbarReducer_1.openSnackbar)({
104
- messageSection: 'revert_schedule',
105
- messageText: 'failed',
106
- type: 'error',
107
- }),
108
- ])));
109
- }));
110
- exports.revertJeScheduleEpic = revertJeScheduleEpic;
@@ -1,6 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../../../reducer';
4
- import { fetchJeSchedulesPage, updateJESchedulesUIState } from '../../reducers/jeSchedulesViewReducer';
5
- export type ActionType = ReturnType<typeof fetchJeSchedulesPage> | ReturnType<typeof updateJESchedulesUIState>;
6
- export declare const switchJESchedulesTabEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.switchJESchedulesTabEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
- const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
9
- const switchJESchedulesTabEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.updateJESchedulesUIState.match), (0, operators_1.filter)((action) => action.payload.selectedPageTab != null), (0, operators_1.mergeMap)(() => {
10
- const state = state$.value;
11
- const { fetchState, refreshStatus } = state.expenseAutomationJESchedulesViewState;
12
- if (fetchState === 'In-Progress' ||
13
- refreshStatus.fetchState === 'In-Progress') {
14
- return rxjs_1.EMPTY;
15
- }
16
- const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
17
- const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
18
- const period = (0, timePeriod_1.convertToPeriod)(selectedPeriod);
19
- const timePeriodStart = (0, timePeriod_1.toAbsoluteDay)(period.start);
20
- const timePeriodEnd = (0, timePeriod_1.toAbsoluteDay)(period.end);
21
- if (timePeriodStart == null || timePeriodEnd == null) {
22
- return rxjs_1.EMPTY;
23
- }
24
- return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, true));
25
- }));
26
- exports.switchJESchedulesTabEpic = switchJESchedulesTabEpic;
@@ -1,36 +0,0 @@
1
- import { Amount } from '../../../commonStateTypes/amount';
2
- import { ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
3
- import { ScheduleTransaction } from '../../../entity/transaction/stateTypes/scheduleTransaction';
4
- import { JESchedulePayload, SaveJESchedulePayload } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
5
- import { NewJeDetailLocalData, NewScheduleLocalData, NewScheduleLocalDataFixedAssets } from '../types/jeSchedulesViewState';
6
- /**
7
- * Computes the month-by-month JE schedule breakdown for a brand-new schedule
8
- * (no linked transaction yet) — replicates createNewSchedulesHelper's math
9
- * (scheduleDetailLocalDataHelper.ts) exactly: lump-sum total split evenly
10
- * across months with the rounding remainder absorbed by the last month, and a
11
- * running balance that decrements each month and is forced to exactly 0 on
12
- * the last row.
13
- */
14
- export declare const computeNewScheduleJeDetails: (localData: NewScheduleLocalData | NewScheduleLocalDataFixedAssets, totalAmount: Amount, vendorName: string) => NewJeDetailLocalData[];
15
- export interface NewSchedulePayload {
16
- je_schedules: JESchedulePayload[];
17
- scheduled_journal_entries: SaveJESchedulePayload[];
18
- }
19
- export type PrepareNewSchedulePayloadFailureReason = 'missing_third_party_id' | 'missing_vendor';
20
- export type PrepareNewSchedulePayloadResult = {
21
- ok: true;
22
- payload: NewSchedulePayload;
23
- } | {
24
- ok: false;
25
- reason: PrepareNewSchedulePayloadFailureReason;
26
- };
27
- /**
28
- * Builds a savable schedule payload directly from a Base Transaction search
29
- * result and the New Schedule form's local data — bypassing the legacy
30
- * getJEScheduledTransactionByJEScheduleTransactionKey selector entirely,
31
- * since that selector throws unless the entity has already round-tripped
32
- * through a real GET /1.0/schedules/:id. A brand-new schedule has no such
33
- * history, so this reads only from data already in hand (the selected
34
- * transaction/line plus what the user filled into the form).
35
- */
36
- export declare const prepareNewSchedulePayload: (transaction: ScheduleTransaction, localData: NewScheduleLocalData | NewScheduleLocalDataFixedAssets, scheduleType: ScheduleTypes) => PrepareNewSchedulePayloadResult;
@@ -1,145 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareNewSchedulePayload = exports.computeNewScheduleJeDetails = void 0;
4
- const amount_1 = require("../../../commonStateTypes/amount");
5
- const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
6
- const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
7
- const timePeriod_2 = require("../../../commonStateTypes/timePeriod");
8
- const scheduleDetailLocalDataHelper_1 = require("../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper");
9
- const scheduleDetailPayload_1 = require("../../scheduleView/scheduleDetailView/scheduleDetailPayload");
10
- const getNewScheduleMemo = (vendorName, schedulePostingDate, currentPeriod, totalPeriod, assetId) => {
11
- const addAsset = assetId != null && assetId !== '' ? ` - ${assetId}` : '';
12
- return `${vendorName} - ${schedulePostingDate.format(formatZeniDateFY_1.MONTH_YEAR_FORMAT)} (${currentPeriod} of ${totalPeriod})${addAsset}`;
13
- };
14
- /**
15
- * Computes the month-by-month JE schedule breakdown for a brand-new schedule
16
- * (no linked transaction yet) — replicates createNewSchedulesHelper's math
17
- * (scheduleDetailLocalDataHelper.ts) exactly: lump-sum total split evenly
18
- * across months with the rounding remainder absorbed by the last month, and a
19
- * running balance that decrements each month and is forced to exactly 0 on
20
- * the last row.
21
- */
22
- const computeNewScheduleJeDetails = (localData, totalAmount, vendorName) => {
23
- const period = localData.selectedMonths;
24
- const startingMonth = localData.selectedDate;
25
- if (startingMonth == null || period == null) {
26
- return [];
27
- }
28
- const assetId = 'assetId' in localData ? localData.assetId : undefined;
29
- const averageAmount = Math.abs(Math.round((totalAmount.amount / period) * 100) / 100);
30
- const lastMonthAmount = Math.abs(Math.round((Math.abs(totalAmount.amount) - averageAmount * (period - 1)) * 100) / 100);
31
- let runningBalance = Math.abs(totalAmount.amount);
32
- const negativeNumbers = totalAmount.amount < 0 || runningBalance < 0;
33
- const newJeDetails = [];
34
- for (let index = 0; index < period; index++) {
35
- if (runningBalance > averageAmount) {
36
- runningBalance = Math.round((runningBalance - averageAmount) * 100) / 100;
37
- }
38
- else {
39
- runningBalance = 0;
40
- }
41
- const amount = index === period - 1 ? lastMonthAmount : averageAmount;
42
- runningBalance = index === period - 1 ? 0 : runningBalance;
43
- const schedulePostingDate = startingMonth.add(index, 'month');
44
- const { postingDate, postingStatus } = (0, scheduleDetailLocalDataHelper_1.getPostingDateAndStatusForIndex)(schedulePostingDate.month(), schedulePostingDate.year(), localData.lastDayOfMonth === true
45
- ? undefined
46
- : localData.selectedDayOfMonth);
47
- newJeDetails.push({
48
- postingDate,
49
- amount: (0, amount_1.toAmount)(negativeNumbers ? -amount : amount, totalAmount.currencyCode, totalAmount.currencySymbol),
50
- runningBalance: (0, amount_1.toAmount)(negativeNumbers ? -runningBalance : runningBalance, totalAmount.currencyCode, totalAmount.currencySymbol),
51
- postingStatus,
52
- memo: getNewScheduleMemo(vendorName, schedulePostingDate, index + 1, period, assetId),
53
- jeLink: { type: 'unknown' },
54
- });
55
- }
56
- return newJeDetails;
57
- };
58
- exports.computeNewScheduleJeDetails = computeNewScheduleJeDetails;
59
- const mapNewJeDetailsToScheduledJournalEntryPayload = (jeScheduleDetails) => jeScheduleDetails.map((journalEntry) => ({
60
- status: {
61
- code: journalEntry.postingStatus,
62
- label: journalEntry.postingStatus,
63
- },
64
- transaction_memo: journalEntry.memo,
65
- third_party_id: journalEntry.jeLink.thirdPartyTransactionId ?? null,
66
- expected_post_date: journalEntry.postingDate.format(timePeriod_1.DEFAULT_DATE_FORMAT),
67
- amount: journalEntry.amount.amount,
68
- balance: journalEntry.runningBalance.amount,
69
- // Brand-new schedule — there is no prior scheduled-journal-entry history
70
- // to cross-reference (unlike the legacy edit flow's equivalent mapper).
71
- scheduled_journal_entry_id: null,
72
- actual_post_date: null,
73
- is_platform_generated: null,
74
- je_schedule_id: null,
75
- update_time: null,
76
- create_time: null,
77
- }));
78
- /**
79
- * Builds a savable schedule payload directly from a Base Transaction search
80
- * result and the New Schedule form's local data — bypassing the legacy
81
- * getJEScheduledTransactionByJEScheduleTransactionKey selector entirely,
82
- * since that selector throws unless the entity has already round-tripped
83
- * through a real GET /1.0/schedules/:id. A brand-new schedule has no such
84
- * history, so this reads only from data already in hand (the selected
85
- * transaction/line plus what the user filled into the form).
86
- */
87
- const prepareNewSchedulePayload = (transaction, localData, scheduleType) => {
88
- if (transaction.thirdPartyTransactionId == null ||
89
- transaction.thirdPartyTransactionId === '') {
90
- return { ok: false, reason: 'missing_third_party_id' };
91
- }
92
- const scheduleTransaction = transaction;
93
- const vendorId = localData.selectedVendor?.id ?? transaction.vendorId ?? '';
94
- const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
95
- if (vendorId === '' || vendorName === '') {
96
- return { ok: false, reason: 'missing_vendor' };
97
- }
98
- const vendor = {
99
- vendor_id: vendorId,
100
- vendor_name: vendorName,
101
- };
102
- const jeScheduleDetails = (0, exports.computeNewScheduleJeDetails)(localData, scheduleTransaction.amount, vendorName);
103
- const postingDate = localData.selectedDayOfMonth ??
104
- (localData.lastDayOfMonth === true ? timePeriod_2.LAST_SCHEDULE_DAY_OF_MONTH : null);
105
- const firstJEScheduleDate = jeScheduleDetails.length > 0
106
- ? jeScheduleDetails[0].postingDate.format(timePeriod_1.DEFAULT_DATE_FORMAT)
107
- : null;
108
- const lastJEScheduleDate = jeScheduleDetails.length > 0
109
- ? jeScheduleDetails[jeScheduleDetails.length - 1].postingDate.format(timePeriod_1.DEFAULT_DATE_FORMAT)
110
- : null;
111
- const isFixedAssets = scheduleType === 'fixed_assets';
112
- const assetId = 'assetId' in localData ? localData.assetId : undefined;
113
- const selectedAccumulatedDepreciationCategory = 'selectedAccumulatedDepreciationCategory' in localData
114
- ? localData.selectedAccumulatedDepreciationCategory
115
- : undefined;
116
- const status = { code: 'new', label: 'New' };
117
- const jeSchedulePayload = {
118
- status,
119
- vendor,
120
- currency_code: scheduleTransaction.currency.currencyCode,
121
- currency_symbol: scheduleTransaction.currency.currencySymbol,
122
- period: localData.selectedMonths ?? null,
123
- je_schedule_type: scheduleType,
124
- posting_date: postingDate,
125
- balance: scheduleTransaction.amount.amount,
126
- start_date: firstJEScheduleDate,
127
- end_date: lastJEScheduleDate,
128
- je_credit_accounting_class_id: scheduleTransaction.classBase?.classId ?? null,
129
- je_credit_account_id: isFixedAssets
130
- ? (selectedAccumulatedDepreciationCategory ?? null)
131
- : scheduleTransaction.account.accountId,
132
- je_debit_account_id: localData.selectedAccount ?? null,
133
- je_debit_accounting_class_id: localData.selectedClass ?? null,
134
- other_attributes: assetId != null ? { asset_id: assetId } : {},
135
- base_transaction: (0, scheduleDetailPayload_1.mapScheduleTransactionToBaseScheduleTransactionPayload)(scheduleTransaction),
136
- };
137
- return {
138
- ok: true,
139
- payload: {
140
- je_schedules: [jeSchedulePayload],
141
- scheduled_journal_entries: mapNewJeDetailsToScheduledJournalEntryPayload(jeScheduleDetails),
142
- },
143
- };
144
- };
145
- exports.prepareNewSchedulePayload = prepareNewSchedulePayload;
@@ -1,42 +0,0 @@
1
- import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
2
- import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
3
- import { FetchStateAndError } from '../../../commonStateTypes/common';
4
- import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
5
- import { AccountBase } from '../../../entity/account/accountState';
6
- import { ClassBase } from '../../../entity/class/classState';
7
- import { ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
8
- import { ScheduleTransaction } from '../../../entity/transaction/stateTypes/scheduleTransaction';
9
- import { NewScheduleLocalData, NewScheduleLocalDataFixedAssets } from '../types/jeSchedulesViewState';
10
- export interface NewScheduleSearchTransactionsView {
11
- searchTransactionsFetchState: FetchStateAndError;
12
- searchTransactionsResults: ScheduleTransaction[];
13
- searchTransactionsString?: string;
14
- }
15
- /**
16
- * Accounts and request status for both accrual creation forms — the one-time accrual and the
17
- * recurring accrued schedule. Deliberately not NewScheduleView: neither has a base transaction to
18
- * search, and both need a second account hierarchy (the accrued liability) that no schedule type
19
- * has. A one-time accrual additionally has no local-data slot in newScheduleState, since it is not
20
- * a schedule type at all.
21
- */
22
- export interface NewAccrualAccountsView {
23
- accountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
24
- accruedAccountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
25
- accruedScheduleSaveStatus: FetchStateAndError;
26
- allAccountList: AccountBase[];
27
- allAccruedExpenseList: AccountBase[];
28
- allClassList: ClassBase[];
29
- classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
30
- createStatus: FetchStateAndError;
31
- }
32
- export interface NewScheduleView extends SelectorView, NewScheduleSearchTransactionsView {
33
- accountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
34
- allAccountList: AccountBase[];
35
- allClassList: ClassBase[];
36
- classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
37
- newScheduleLocalData: NewScheduleLocalData | NewScheduleLocalDataFixedAssets;
38
- saveStatus: FetchStateAndError;
39
- scheduleType: ScheduleTypes;
40
- allDepreciationAccountList?: AccountBase[];
41
- allDepreciationAccountListNestedAccountHierarchy?: NestedAccountHierarchyForReport[];
42
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +0,0 @@
1
- import { RootState } from '../../../reducer';
2
- import { NewAccrualAccountsView, NewScheduleSearchTransactionsView, NewScheduleView } from '../selectorTypes/jeNewScheduleViewSelectorTypes';
3
- /**
4
- * The Base Transaction search is shared across schedule types (one search
5
- * box, not one per prepaid_expenses/fixed_assets) — split out from
6
- * getNewScheduleView so a consumer can read it without supplying an
7
- * otherwise-irrelevant scheduleType.
8
- */
9
- export declare const getNewScheduleSearchTransactionsView: (state: RootState) => NewScheduleSearchTransactionsView;
10
- /**
11
- * Account + class options and request status shared by both accrual creation forms — the one-time
12
- * accrual and the recurring accrued schedule.
13
- *
14
- * getAccountsTypesForScheduleDetails('accrued_expenses') deliberately includes
15
- * other_current_liabilities, because the accrued liability accounts live there —
16
- * so the debit list has to subtract them back out, and the credit list keeps only
17
- * them. Mirrors getScheduleAccruedDetailView, which is the form this one is
18
- * modelled on.
19
- */
20
- export declare const getNewAccrualAccountsView: (state: RootState) => NewAccrualAccountsView;
21
- export declare const getNewScheduleView: (state: RootState, scheduleType: "fixed_assets" | "prepaid_expenses") => NewScheduleView;