@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
@@ -0,0 +1,110 @@
1
+ import { from } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateJESchedules, updateJESchedulesDetails, } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
4
+ import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/jeSchedulesTypes';
5
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
6
+ import { getScheduleTransactionById } from '../../../../../entity/transaction/transactionSelector';
7
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
8
+ import { prepareNewSchedulePayload, } from '../../../helpers/newScheduleLocalDataHelper';
9
+ import { resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
10
+ const FAILURE_REASON_MESSAGES = {
11
+ missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
12
+ missing_vendor: 'Select a vendor before saving this schedule.',
13
+ };
14
+ export const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveNewSchedule.match), mergeMap((action) => {
15
+ const { scheduleType } = action.payload;
16
+ const state = state$.value;
17
+ const localData = state.expenseAutomationJESchedulesViewState.newSchedule
18
+ .newScheduleState[scheduleType];
19
+ const { selectedBaseTransactionId } = localData;
20
+ const transaction = selectedBaseTransactionId != null
21
+ ? getScheduleTransactionById(state.transactionState, getJEScheduleTransactionKey(selectedBaseTransactionId))
22
+ : undefined;
23
+ if (transaction == null) {
24
+ return from([
25
+ saveNewScheduleFailure({
26
+ status: createZeniAPIStatus('Unexpected Error', 'No base transaction selected for this schedule.'),
27
+ }),
28
+ openSnackbar({
29
+ messageSection: 'create_schedule',
30
+ messageText: 'failed',
31
+ type: 'error',
32
+ variables: [
33
+ {
34
+ variableName: '_api-error_',
35
+ variableValue: 'No base transaction selected.',
36
+ },
37
+ ],
38
+ }),
39
+ ]);
40
+ }
41
+ const result = prepareNewSchedulePayload(transaction, localData, scheduleType);
42
+ if (!result.ok) {
43
+ const message = FAILURE_REASON_MESSAGES[result.reason];
44
+ return from([
45
+ saveNewScheduleFailure({
46
+ status: createZeniAPIStatus('Unexpected Error', message),
47
+ }),
48
+ openSnackbar({
49
+ messageSection: 'create_schedule',
50
+ messageText: 'failed',
51
+ type: 'error',
52
+ variables: [{ variableName: '_api-error_', variableValue: message }],
53
+ }),
54
+ ]);
55
+ }
56
+ const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
57
+ const queryParam = {
58
+ je_schedule_type: scheduleType,
59
+ };
60
+ const payload = { ...result.payload };
61
+ return zeniAPI
62
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
63
+ .pipe(mergeMap((response) => {
64
+ if (isSuccessResponse(response) && response.data != null) {
65
+ return from([
66
+ updateJESchedules(response.data.je_schedules),
67
+ updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries),
68
+ resetNewScheduleLocalData({ scheduleType }),
69
+ saveNewScheduleSuccess(),
70
+ openSnackbar({
71
+ messageSection: 'create_schedule',
72
+ messageText: 'success',
73
+ type: 'success',
74
+ variables: [
75
+ { variableName: '_vendor_name_', variableValue: vendorName },
76
+ ],
77
+ }),
78
+ ]);
79
+ }
80
+ return from([
81
+ saveNewScheduleFailure({ status: response.status }),
82
+ openSnackbar({
83
+ messageSection: 'create_schedule',
84
+ messageText: 'failed',
85
+ type: 'error',
86
+ variables: [
87
+ {
88
+ variableName: '_api-error_',
89
+ variableValue: response.status.message,
90
+ },
91
+ ],
92
+ }),
93
+ ]);
94
+ }), catchError((error) => from([
95
+ openSnackbar({
96
+ messageSection: 'create_schedule',
97
+ messageText: 'failed',
98
+ type: 'error',
99
+ variables: [
100
+ {
101
+ variableName: '_api-error_',
102
+ variableValue: JSON.stringify(error),
103
+ },
104
+ ],
105
+ }),
106
+ saveNewScheduleFailure({
107
+ status: createZeniAPIStatus('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
108
+ }),
109
+ ])));
110
+ }));
@@ -0,0 +1,73 @@
1
+ import { EMPTY, from, merge, of } from 'rxjs';
2
+ import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
3
+ import { getJEScheduleTransactionKey } from '../../../../../entity/jeSchedules/jeSchedulesTypes';
4
+ import { toTransactionType } from '../../../../../entity/transaction/stateTypes/transactionType';
5
+ import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
6
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
7
+ import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
8
+ import { MIN_NEW_SCHEDULE_SEARCH_LENGTH } from '../../../types/jeSchedulesViewState';
9
+ /** Dropdown-sized result set — no pagination for Base Transaction search. */
10
+ const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
11
+ /** Fallback when the backend sends a null currency for a search result. */
12
+ const DEFAULT_CURRENCY_CODE = 'USD';
13
+ const DEFAULT_CURRENCY_SYMBOL = '$';
14
+ export const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
15
+ const searchActions$ = actions$.pipe(filter(searchTransactionsForNewSchedule.match));
16
+ /** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
17
+ const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length < MIN_NEW_SCHEDULE_SEARCH_LENGTH));
18
+ const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length >= MIN_NEW_SCHEDULE_SEARCH_LENGTH), debounceTime(300));
19
+ return merge(newSearchTooShortOrClear$, newSearchDebounced$).pipe(switchMap((action) => {
20
+ const query = action.payload.query.trim();
21
+ if (query.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
22
+ return EMPTY;
23
+ }
24
+ const queryParam = {
25
+ page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
26
+ search_text: query,
27
+ je_schedule_type: action.payload.scheduleType,
28
+ };
29
+ return zeniAPI
30
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
31
+ .pipe(mergeMap((response) => {
32
+ if (isSuccessResponse(response) && response.data != null) {
33
+ const { transactions } = response.data;
34
+ const transactionsPerCurrency = {};
35
+ transactions.forEach((transaction) => {
36
+ const { currency_code, currency_symbol } = transaction;
37
+ const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
38
+ const existing = transactionsPerCurrency[currencyCode];
39
+ transactionsPerCurrency[currencyCode] =
40
+ existing != null
41
+ ? {
42
+ currencySymbol: existing.currencySymbol,
43
+ transactions: [...existing.transactions, transaction],
44
+ }
45
+ : {
46
+ currencySymbol: currency_code == null
47
+ ? DEFAULT_CURRENCY_SYMBOL
48
+ : currency_symbol,
49
+ transactions: [transaction],
50
+ };
51
+ });
52
+ const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
53
+ const perCurrency = transactionsPerCurrency[currencyCode];
54
+ return updateScheduleTransactions(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
55
+ });
56
+ actionsOut.push(searchTransactionsForNewScheduleSuccess({
57
+ searchResults: transactions.map((transaction) => getJEScheduleTransactionKey({
58
+ id: transaction.transaction_id,
59
+ type: toTransactionType(transaction.transaction_type),
60
+ lineId: transaction.line_id,
61
+ })),
62
+ }));
63
+ return from(actionsOut);
64
+ }
65
+ return of(searchTransactionsForNewScheduleFailure({
66
+ status: response.status,
67
+ }));
68
+ }), catchError((error) => of(searchTransactionsForNewScheduleFailure({
69
+ status: createZeniAPIStatus('Unexpected Error', 'Search transactions for new schedule errored: ' +
70
+ JSON.stringify(error)),
71
+ }))));
72
+ }));
73
+ };
@@ -0,0 +1,129 @@
1
+ import { from, merge } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
4
+ import { generateJEOneTimeAccrualKey } from '../../../../entity/jeSchedules/jeScheduleHelper';
5
+ import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
6
+ import { getJEOneTimeAccrualByKey } from '../../../../entity/jeSchedules/jeSchedulesSelector';
7
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
8
+ import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
9
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
10
+ import { fetchJeSchedules, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertOneTimeAccrual, } from '../../reducers/jeSchedulesViewReducer';
11
+ /**
12
+ * The page the accrual came from, so a promoted or ignored row lands in the right bucket. Guarded
13
+ * because convertToPeriod destructures: an unset period would throw and take the epic subscription
14
+ * down for the session, and a missed refresh is the cheaper failure.
15
+ */
16
+ function refreshCurrentPage(state) {
17
+ const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[getCurrentTenant(state).tenantId];
18
+ if (selectedMonthYear == null) {
19
+ return [];
20
+ }
21
+ const period = convertToPeriod(selectedMonthYear);
22
+ const start = toAbsoluteDay(period.start);
23
+ const end = toAbsoluteDay(period.end);
24
+ if (start == null || end == null) {
25
+ return [];
26
+ }
27
+ return [fetchJeSchedules({ start, end }, true)];
28
+ }
29
+ function failureActions(accrualId, message, status) {
30
+ return [
31
+ oneTimeAccrualActionFailure({
32
+ accrualId,
33
+ status: status ?? createZeniAPIStatus('Unexpected Error', message),
34
+ }),
35
+ openSnackbar({
36
+ messageSection: 'save_schedule',
37
+ messageText: 'failed',
38
+ type: 'error',
39
+ variables: [{ variableName: '_api-error_', variableValue: message }],
40
+ }),
41
+ ];
42
+ }
43
+ export const promoteOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(promoteOneTimeAccrual.match), mergeMap((action) => {
44
+ const state = state$.value;
45
+ const { accrualId, amount } = action.payload;
46
+ const accrual = getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState);
47
+ if (accrual?.jeDebitAccountId == null ||
48
+ accrual.jeCreditAccountId == null) {
49
+ // Promote posts a journal entry, so it cannot proceed without both sides of it.
50
+ return from(failureActions(accrualId, 'This accrual is missing an expense or liability account.'));
51
+ }
52
+ // vendor_id, vendor_name and service_month are deliberately absent: promote takes them from
53
+ // the stored draft and ignores them in the body, so sending them would imply a reassignment
54
+ // that never happens.
55
+ const payload = {
56
+ amount,
57
+ memo: accrual.memo,
58
+ je_debit_account_id: accrual.jeDebitAccountId,
59
+ je_credit_account_id: accrual.jeCreditAccountId,
60
+ };
61
+ return zeniAPI
62
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`, { ...payload })
63
+ .pipe(mergeMap((response) => {
64
+ if (isSuccessResponse(response) && response.data != null) {
65
+ return from([
66
+ updateJEOneTimeAccruals([response.data.accrual]),
67
+ oneTimeAccrualActionSuccess({ accrualId }),
68
+ openSnackbar({
69
+ messageSection: 'save_schedule',
70
+ messageText: 'success',
71
+ type: 'success',
72
+ variables: [
73
+ {
74
+ variableName: '_vendor_name_',
75
+ variableValue: accrual.vendorName,
76
+ },
77
+ ],
78
+ }),
79
+ ...refreshCurrentPage(state),
80
+ ]);
81
+ }
82
+ return from(failureActions(accrualId, response.status.message, response.status));
83
+ }), catchError((error) => from(failureActions(accrualId, `Promote accrual REST API call errored out ${JSON.stringify(error)}`))));
84
+ }));
85
+ export const ignoreOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(ignoreOneTimeAccrual.match), mergeMap((action) => {
86
+ const state = state$.value;
87
+ const { accrualId, reason, note } = action.payload;
88
+ // `scope` is deliberately never sent: the API returns 400 on it, which is why the design's
89
+ // "Apply to" selector cannot be built yet.
90
+ const payload = {
91
+ reason,
92
+ ...(note != null && note !== '' ? { note } : {}),
93
+ };
94
+ return zeniAPI
95
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/ignore`, { ...payload })
96
+ .pipe(mergeMap((response) => {
97
+ if (isSuccessResponse(response) && response.data != null) {
98
+ return from([
99
+ updateJEOneTimeAccruals([response.data.accrual]),
100
+ oneTimeAccrualActionSuccess({ accrualId }),
101
+ ...refreshCurrentPage(state),
102
+ ]);
103
+ }
104
+ return from(failureActions(accrualId, response.status.message, response.status));
105
+ }), catchError((error) => from(failureActions(accrualId, `Ignore accrual REST API call errored out ${JSON.stringify(error)}`))));
106
+ }));
107
+ export const revertOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(revertOneTimeAccrual.match), mergeMap((action) => {
108
+ const state = state$.value;
109
+ const { accrualId, reason, note } = action.payload;
110
+ // Deletes the accrual's journal entry in QBO and soft-deletes the row. `scope` is never sent:
111
+ // the endpoint 400s on it, exactly as ignore does.
112
+ const payload = {
113
+ reason,
114
+ ...(note != null && note !== '' ? { note } : {}),
115
+ };
116
+ return zeniAPI
117
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/revert`, { ...payload })
118
+ .pipe(mergeMap((response) => {
119
+ if (isSuccessResponse(response) && response.data != null) {
120
+ return from([
121
+ updateJEOneTimeAccruals([response.data.accrual]),
122
+ oneTimeAccrualActionSuccess({ accrualId }),
123
+ ...refreshCurrentPage(state),
124
+ ]);
125
+ }
126
+ return from(failureActions(accrualId, response.status.message, response.status));
127
+ }), catchError((error) => from(failureActions(accrualId, `Revert accrual REST API call errored out ${JSON.stringify(error)}`))));
128
+ }));
129
+ export const oneTimeAccrualActionsEpic = (actions$, state$, zeniAPI) => merge(promoteOneTimeAccrualEpic(actions$, state$, zeniAPI), ignoreOneTimeAccrualEpic(actions$, state$, zeniAPI), revertOneTimeAccrualEpic(actions$, state$, zeniAPI));
@@ -0,0 +1,92 @@
1
+ import { from } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateJESchedules, updateJESchedulesDetails, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
+ import { getJEScheduledTransactionByJEScheduleTransactionKey } from '../../../../entity/jeSchedules/jeSchedulesSelector';
5
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
6
+ import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
7
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
8
+ import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
9
+ import { prepareIgnoreSchedulePayload } from '../../payload/jeSchedulesPayload';
10
+ import { removeJeScheduleTransactionKey, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess, } from '../../reducers/jeSchedulesViewReducer';
11
+ /**
12
+ * Undo a posted prepaid / fixed-asset schedule: deletes its posted QBO journal entry, then
13
+ * soft-deletes the scheduled entries and the schedule itself.
14
+ *
15
+ * Prepaid and fixed assets only — the endpoint rejects `accrued_expenses`, which has no revert
16
+ * path of its own. Two or more posted journal entries answer 409 and leave the schedule intact,
17
+ * so the failure is surfaced rather than swallowed.
18
+ */
19
+ export const revertJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(revertJeSchedule.match), mergeMap((action) => {
20
+ const state = state$.value;
21
+ const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
22
+ const { jeScheduleId, jeScheduleTransactionKey, scheduleType, reason, note, } = action.payload;
23
+ const currentTenant = getCurrentTenant(state);
24
+ const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
25
+ const jeScheduleTransactionState = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleTransactionKey, state);
26
+ // Same fat blob as ignore, with the schedule id echoed back: the endpoint compares it to the
27
+ // URL id and rejects a mismatch. reason/note go under `feedback`, and `action` is stamped
28
+ // server-side, so sending it would be rejected as an unexpected field.
29
+ const schedulePayload = prepareIgnoreSchedulePayload(scheduleType, jeScheduleTransactionState, state);
30
+ const payload = {
31
+ ...schedulePayload,
32
+ je_schedules: schedulePayload.je_schedules.map((schedule, index) => index === 0
33
+ ? {
34
+ ...schedule,
35
+ je_schedule_id: jeScheduleId,
36
+ feedback: {
37
+ reason,
38
+ ...(note != null && note !== '' ? { note } : {}),
39
+ },
40
+ }
41
+ : schedule),
42
+ };
43
+ return zeniAPI
44
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/revert`, payload)
45
+ .pipe(mergeMap((response) => {
46
+ if (isSuccessResponse(response) && response.data != null) {
47
+ return from([
48
+ updateJESchedules(response.data.je_schedules),
49
+ updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries),
50
+ revertJeScheduleSuccess({ jeScheduleTransactionKey }),
51
+ removeJeScheduleTransactionKey(jeScheduleTransactionKey, selectedPeriod),
52
+ fetchMonthEndCloseChecks({
53
+ tenantId: currentTenant.tenantId,
54
+ period: selectedPeriod,
55
+ refreshViewInBackground: true,
56
+ }),
57
+ openSnackbar({
58
+ messageSection: 'revert_schedule',
59
+ messageText: 'success',
60
+ type: 'success',
61
+ }),
62
+ ]);
63
+ }
64
+ return from([
65
+ revertJeScheduleFailure({
66
+ jeScheduleTransactionKey,
67
+ status: response.status,
68
+ }),
69
+ openSnackbar({
70
+ messageSection: 'revert_schedule',
71
+ messageText: 'failed',
72
+ type: 'error',
73
+ variables: [
74
+ {
75
+ variableName: '_api-error_',
76
+ variableValue: response.status.message,
77
+ },
78
+ ],
79
+ }),
80
+ ]);
81
+ }), catchError((error) => from([
82
+ revertJeScheduleFailure({
83
+ jeScheduleTransactionKey,
84
+ status: createZeniAPIStatus('Unexpected Error', `Revert schedule REST API call errored out ${JSON.stringify(error)}`),
85
+ }),
86
+ openSnackbar({
87
+ messageSection: 'revert_schedule',
88
+ messageText: 'failed',
89
+ type: 'error',
90
+ }),
91
+ ])));
92
+ }));
@@ -0,0 +1,22 @@
1
+ import { EMPTY, of } from 'rxjs';
2
+ import { filter, mergeMap } from 'rxjs/operators';
3
+ import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
4
+ import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
5
+ import { fetchJeSchedulesPage, updateJESchedulesUIState, } from '../../reducers/jeSchedulesViewReducer';
6
+ export const switchJESchedulesTabEpic = (actions$, state$) => actions$.pipe(filter(updateJESchedulesUIState.match), filter((action) => action.payload.selectedPageTab != null), mergeMap(() => {
7
+ const state = state$.value;
8
+ const { fetchState, refreshStatus } = state.expenseAutomationJESchedulesViewState;
9
+ if (fetchState === 'In-Progress' ||
10
+ refreshStatus.fetchState === 'In-Progress') {
11
+ return EMPTY;
12
+ }
13
+ const currentTenant = getCurrentTenant(state);
14
+ const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
15
+ const period = convertToPeriod(selectedPeriod);
16
+ const timePeriodStart = toAbsoluteDay(period.start);
17
+ const timePeriodEnd = toAbsoluteDay(period.end);
18
+ if (timePeriodStart == null || timePeriodEnd == null) {
19
+ return EMPTY;
20
+ }
21
+ return of(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, true));
22
+ }));
@@ -0,0 +1,140 @@
1
+ import { toAmount } from '../../../commonStateTypes/amount';
2
+ import { DEFAULT_DATE_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
3
+ import { MONTH_YEAR_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
4
+ import { LAST_SCHEDULE_DAY_OF_MONTH } from '../../../commonStateTypes/timePeriod';
5
+ import { getPostingDateAndStatusForIndex } from '../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper';
6
+ import { mapScheduleTransactionToBaseScheduleTransactionPayload, } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
7
+ const getNewScheduleMemo = (vendorName, schedulePostingDate, currentPeriod, totalPeriod, assetId) => {
8
+ const addAsset = assetId != null && assetId !== '' ? ` - ${assetId}` : '';
9
+ return `${vendorName} - ${schedulePostingDate.format(MONTH_YEAR_FORMAT)} (${currentPeriod} of ${totalPeriod})${addAsset}`;
10
+ };
11
+ /**
12
+ * Computes the month-by-month JE schedule breakdown for a brand-new schedule
13
+ * (no linked transaction yet) — replicates createNewSchedulesHelper's math
14
+ * (scheduleDetailLocalDataHelper.ts) exactly: lump-sum total split evenly
15
+ * across months with the rounding remainder absorbed by the last month, and a
16
+ * running balance that decrements each month and is forced to exactly 0 on
17
+ * the last row.
18
+ */
19
+ export const computeNewScheduleJeDetails = (localData, totalAmount, vendorName) => {
20
+ const period = localData.selectedMonths;
21
+ const startingMonth = localData.selectedDate;
22
+ if (startingMonth == null || period == null) {
23
+ return [];
24
+ }
25
+ const assetId = 'assetId' in localData ? localData.assetId : undefined;
26
+ const averageAmount = Math.abs(Math.round((totalAmount.amount / period) * 100) / 100);
27
+ const lastMonthAmount = Math.abs(Math.round((Math.abs(totalAmount.amount) - averageAmount * (period - 1)) * 100) / 100);
28
+ let runningBalance = Math.abs(totalAmount.amount);
29
+ const negativeNumbers = totalAmount.amount < 0 || runningBalance < 0;
30
+ const newJeDetails = [];
31
+ for (let index = 0; index < period; index++) {
32
+ if (runningBalance > averageAmount) {
33
+ runningBalance = Math.round((runningBalance - averageAmount) * 100) / 100;
34
+ }
35
+ else {
36
+ runningBalance = 0;
37
+ }
38
+ const amount = index === period - 1 ? lastMonthAmount : averageAmount;
39
+ runningBalance = index === period - 1 ? 0 : runningBalance;
40
+ const schedulePostingDate = startingMonth.add(index, 'month');
41
+ const { postingDate, postingStatus } = getPostingDateAndStatusForIndex(schedulePostingDate.month(), schedulePostingDate.year(), localData.lastDayOfMonth === true
42
+ ? undefined
43
+ : localData.selectedDayOfMonth);
44
+ newJeDetails.push({
45
+ postingDate,
46
+ amount: toAmount(negativeNumbers ? -amount : amount, totalAmount.currencyCode, totalAmount.currencySymbol),
47
+ runningBalance: toAmount(negativeNumbers ? -runningBalance : runningBalance, totalAmount.currencyCode, totalAmount.currencySymbol),
48
+ postingStatus,
49
+ memo: getNewScheduleMemo(vendorName, schedulePostingDate, index + 1, period, assetId),
50
+ jeLink: { type: 'unknown' },
51
+ });
52
+ }
53
+ return newJeDetails;
54
+ };
55
+ const mapNewJeDetailsToScheduledJournalEntryPayload = (jeScheduleDetails) => jeScheduleDetails.map((journalEntry) => ({
56
+ status: {
57
+ code: journalEntry.postingStatus,
58
+ label: journalEntry.postingStatus,
59
+ },
60
+ transaction_memo: journalEntry.memo,
61
+ third_party_id: journalEntry.jeLink.thirdPartyTransactionId ?? null,
62
+ expected_post_date: journalEntry.postingDate.format(DEFAULT_DATE_FORMAT),
63
+ amount: journalEntry.amount.amount,
64
+ balance: journalEntry.runningBalance.amount,
65
+ // Brand-new schedule — there is no prior scheduled-journal-entry history
66
+ // to cross-reference (unlike the legacy edit flow's equivalent mapper).
67
+ scheduled_journal_entry_id: null,
68
+ actual_post_date: null,
69
+ is_platform_generated: null,
70
+ je_schedule_id: null,
71
+ update_time: null,
72
+ create_time: null,
73
+ }));
74
+ /**
75
+ * Builds a savable schedule payload directly from a Base Transaction search
76
+ * result and the New Schedule form's local data — bypassing the legacy
77
+ * getJEScheduledTransactionByJEScheduleTransactionKey selector entirely,
78
+ * since that selector throws unless the entity has already round-tripped
79
+ * through a real GET /1.0/schedules/:id. A brand-new schedule has no such
80
+ * history, so this reads only from data already in hand (the selected
81
+ * transaction/line plus what the user filled into the form).
82
+ */
83
+ export const prepareNewSchedulePayload = (transaction, localData, scheduleType) => {
84
+ if (transaction.thirdPartyTransactionId == null ||
85
+ transaction.thirdPartyTransactionId === '') {
86
+ return { ok: false, reason: 'missing_third_party_id' };
87
+ }
88
+ const scheduleTransaction = transaction;
89
+ const vendorId = localData.selectedVendor?.id ?? transaction.vendorId ?? '';
90
+ const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
91
+ if (vendorId === '' || vendorName === '') {
92
+ return { ok: false, reason: 'missing_vendor' };
93
+ }
94
+ const vendor = {
95
+ vendor_id: vendorId,
96
+ vendor_name: vendorName,
97
+ };
98
+ const jeScheduleDetails = computeNewScheduleJeDetails(localData, scheduleTransaction.amount, vendorName);
99
+ const postingDate = localData.selectedDayOfMonth ??
100
+ (localData.lastDayOfMonth === true ? LAST_SCHEDULE_DAY_OF_MONTH : null);
101
+ const firstJEScheduleDate = jeScheduleDetails.length > 0
102
+ ? jeScheduleDetails[0].postingDate.format(DEFAULT_DATE_FORMAT)
103
+ : null;
104
+ const lastJEScheduleDate = jeScheduleDetails.length > 0
105
+ ? jeScheduleDetails[jeScheduleDetails.length - 1].postingDate.format(DEFAULT_DATE_FORMAT)
106
+ : null;
107
+ const isFixedAssets = scheduleType === 'fixed_assets';
108
+ const assetId = 'assetId' in localData ? localData.assetId : undefined;
109
+ const selectedAccumulatedDepreciationCategory = 'selectedAccumulatedDepreciationCategory' in localData
110
+ ? localData.selectedAccumulatedDepreciationCategory
111
+ : undefined;
112
+ const status = { code: 'new', label: 'New' };
113
+ const jeSchedulePayload = {
114
+ status,
115
+ vendor,
116
+ currency_code: scheduleTransaction.currency.currencyCode,
117
+ currency_symbol: scheduleTransaction.currency.currencySymbol,
118
+ period: localData.selectedMonths ?? null,
119
+ je_schedule_type: scheduleType,
120
+ posting_date: postingDate,
121
+ balance: scheduleTransaction.amount.amount,
122
+ start_date: firstJEScheduleDate,
123
+ end_date: lastJEScheduleDate,
124
+ je_credit_accounting_class_id: scheduleTransaction.classBase?.classId ?? null,
125
+ je_credit_account_id: isFixedAssets
126
+ ? (selectedAccumulatedDepreciationCategory ?? null)
127
+ : scheduleTransaction.account.accountId,
128
+ je_debit_account_id: localData.selectedAccount ?? null,
129
+ je_debit_accounting_class_id: localData.selectedClass ?? null,
130
+ other_attributes: assetId != null ? { asset_id: assetId } : {},
131
+ base_transaction: mapScheduleTransactionToBaseScheduleTransactionPayload(scheduleTransaction),
132
+ };
133
+ return {
134
+ ok: true,
135
+ payload: {
136
+ je_schedules: [jeSchedulePayload],
137
+ scheduled_journal_entries: mapNewJeDetailsToScheduledJournalEntryPayload(jeScheduleDetails),
138
+ },
139
+ };
140
+ };
@@ -1,5 +1,60 @@
1
1
  import { DEFAULT_DATE_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
2
+ import { getClassList } from '../../classList/classListSelector';
2
3
  import { mapScheduleTransactionToBaseScheduleTransactionPayload, mapVendorToVendorPayload, } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
4
+ const BALANCE_SHEET_CLASS_LABEL = 'balance_sheet';
5
+ const SERVICE_MONTH_FORMAT = 'YYYY-MM';
6
+ /**
7
+ * The credit line is the accrued liability, which always sits on the balance sheet — the
8
+ * recurring accrued path resolves the same class the same way (see
9
+ * prepareNewScheduleAccruedDetailPayload). Omitted rather than sent empty when the tenant has
10
+ * no balance_sheet class, since the API treats the field as optional.
11
+ */
12
+ export const prepareCreateOneTimeAccrualPayload = (state, localData) => {
13
+ const { classListState, classState } = state;
14
+ const balanceSheetClass = getClassList(classState, classListState).classes.find((accountingClass) => accountingClass.labels?.includes(BALANCE_SHEET_CLASS_LABEL) === true);
15
+ // reverse_next_month alone decides reversal_policy server-side, so reversal_policy is
16
+ // deliberately not sent — the API documents it only as an alternate way to say on_bill_match,
17
+ // and sending both would be two sources of truth for one toggle.
18
+ const reversalFields = localData.reverseNextMonth
19
+ ? {
20
+ reverse_next_month: true,
21
+ expected_reversal_date: getExpectedReversalDate(localData.serviceMonth).format(DEFAULT_DATE_FORMAT),
22
+ }
23
+ : { reverse_next_month: false };
24
+ return {
25
+ vendor_id: localData.vendorId,
26
+ vendor_name: localData.vendorName,
27
+ service_month: localData.serviceMonth.format(SERVICE_MONTH_FORMAT),
28
+ amount: localData.amount,
29
+ memo: localData.memo,
30
+ je_debit_account_id: localData.debitAccountId,
31
+ je_credit_account_id: localData.creditAccountId,
32
+ ...(localData.debitAccountName != null
33
+ ? { je_debit_account_name: localData.debitAccountName }
34
+ : {}),
35
+ ...(localData.creditAccountName != null
36
+ ? { je_credit_account_name: localData.creditAccountName }
37
+ : {}),
38
+ ...(localData.debitClassId != null
39
+ ? { je_debit_accounting_class_id: localData.debitClassId }
40
+ : {}),
41
+ ...(localData.debitClassName != null
42
+ ? { je_debit_accounting_class_name: localData.debitClassName }
43
+ : {}),
44
+ ...(balanceSheetClass != null
45
+ ? {
46
+ je_credit_accounting_class_id: balanceSheetClass.classId,
47
+ je_credit_accounting_class_name: balanceSheetClass.className,
48
+ }
49
+ : {}),
50
+ ...reversalFields,
51
+ };
52
+ };
53
+ /**
54
+ * The API defaults this to the 1st of the month after service_month. We send it explicitly so the
55
+ * date the form promised the user is the date that gets stored.
56
+ */
57
+ export const getExpectedReversalDate = (serviceMonth) => serviceMonth.add(1, 'month').startOf('month');
3
58
  export const prepareIgnoreSchedulePayload = (scheduleType, jeScheduleTransaction, state) => {
4
59
  const { vendorState } = state;
5
60
  const { vendor, currencyCode, currencySymbol, baseTransaction, status, balanceAsOfToday, period, startDate, endDate, jeCredit, jeDebit, } = jeScheduleTransaction;