@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.
- package/lib/entity/aiCfo/aiCfoState.d.ts +2 -2
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +2 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +24 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +34 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
- package/lib/entity/snackbar/snackbarApiError.d.ts +8 -0
- package/lib/entity/snackbar/snackbarApiError.js +15 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +8 -1
- package/lib/epic.js +8 -1
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +24 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +32 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
- package/lib/esm/entity/snackbar/snackbarApiError.js +11 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +8 -1
- package/lib/esm/index.js +13 -7
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +81 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +21 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +73 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +129 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +92 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +268 -29
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +286 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +2 -0
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +2 -0
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +6 -3
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +6 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +5 -4
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -0
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -0
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +2 -0
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +2 -0
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +7 -3
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +2 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +2 -0
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +2 -0
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +3 -0
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +6 -3
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +52 -0
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +6 -3
- package/lib/esm/view/vendorTabView/vendorTabViewReducer.js +1 -1
- package/lib/index.d.ts +18 -14
- package/lib/index.js +92 -49
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +38 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +85 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +77 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +12 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +136 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +96 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +79 -11
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +270 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +34 -8
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +31 -1
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +81 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +2 -0
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +2 -0
- package/lib/view/invoicing/discountAction/discountActionEpic.js +5 -2
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +5 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +5 -4
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +2 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +2 -0
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +6 -2
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +2 -0
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +2 -0
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingSubscriptionListView/invoicingSubscriptionListViewState.d.ts +1 -1
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +2 -0
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +3 -0
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +5 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +41 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +55 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +5 -2
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
...refreshCurrentPage(state),
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
return (0, rxjs_1.from)(failureActions(accrualId, response.status.message, response.status));
|
|
109
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions(accrualId, `Ignore accrual REST API call errored out ${JSON.stringify(error)}`))));
|
|
110
|
+
}));
|
|
111
|
+
exports.ignoreOneTimeAccrualEpic = ignoreOneTimeAccrualEpic;
|
|
112
|
+
const revertOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.revertOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
113
|
+
const state = state$.value;
|
|
114
|
+
const { accrualId, reason, note } = action.payload;
|
|
115
|
+
// Deletes the accrual's journal entry in QBO and soft-deletes the row. `scope` is never sent:
|
|
116
|
+
// the endpoint 400s on it, exactly as ignore does.
|
|
117
|
+
const payload = {
|
|
118
|
+
reason,
|
|
119
|
+
...(note != null && note !== '' ? { note } : {}),
|
|
120
|
+
};
|
|
121
|
+
return zeniAPI
|
|
122
|
+
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/revert`, { ...payload })
|
|
123
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
124
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
125
|
+
return (0, rxjs_1.from)([
|
|
126
|
+
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
127
|
+
(0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
|
|
128
|
+
...refreshCurrentPage(state),
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
return (0, rxjs_1.from)(failureActions(accrualId, response.status.message, response.status));
|
|
132
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions(accrualId, `Revert accrual REST API call errored out ${JSON.stringify(error)}`))));
|
|
133
|
+
}));
|
|
134
|
+
exports.revertOneTimeAccrualEpic = revertOneTimeAccrualEpic;
|
|
135
|
+
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));
|
|
136
|
+
exports.oneTimeAccrualActionsEpic = oneTimeAccrualActionsEpic;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
3
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { RootState } from '../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
+
import { fetchMonthEndCloseChecks } from '../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer';
|
|
7
|
+
import { removeJeScheduleTransactionKey, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess } from '../../reducers/jeSchedulesViewReducer';
|
|
8
|
+
export type ActionType = ReturnType<typeof fetchMonthEndCloseChecks> | ReturnType<typeof openSnackbar> | ReturnType<typeof removeJeScheduleTransactionKey> | ReturnType<typeof revertJeSchedule> | ReturnType<typeof revertJeScheduleFailure> | ReturnType<typeof revertJeScheduleSuccess> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
|
|
9
|
+
/**
|
|
10
|
+
* Undo a posted prepaid / fixed-asset schedule: deletes its posted QBO journal entry, then
|
|
11
|
+
* soft-deletes the scheduled entries and the schedule itself.
|
|
12
|
+
*
|
|
13
|
+
* Prepaid and fixed assets only — the endpoint rejects `accrued_expenses`, which has no revert
|
|
14
|
+
* path of its own. Two or more posted journal entries answer 409 and leave the schedule intact,
|
|
15
|
+
* so the failure is surfaced rather than swallowed.
|
|
16
|
+
*/
|
|
17
|
+
export declare const revertJeScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
18
|
+
payload: {
|
|
19
|
+
messageSection: import("../../../..").SnackbarMessageSections;
|
|
20
|
+
messageText: import("../../../..").SnackbarMessageSectionTexts;
|
|
21
|
+
type: import("../../../..").SnackbarMessageType;
|
|
22
|
+
showStatusIcon?: boolean;
|
|
23
|
+
variables?: {
|
|
24
|
+
variableName: string;
|
|
25
|
+
variableValue: string;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
type: "snackbar/openSnackbar";
|
|
29
|
+
} | {
|
|
30
|
+
payload: {
|
|
31
|
+
jeSchedulesTransactionsPayload: import("../../../../entity/jeSchedules/jeSchedulesPayload").JEScheduledTransactionPayload[];
|
|
32
|
+
};
|
|
33
|
+
type: "jeSchedules/updateJESchedules";
|
|
34
|
+
} | {
|
|
35
|
+
payload: {
|
|
36
|
+
period: import("../../../..").MonthYearPeriod;
|
|
37
|
+
refreshViewInBackground: boolean;
|
|
38
|
+
tenantId: import("../../../..").ID;
|
|
39
|
+
};
|
|
40
|
+
type: "monthEndCloseChecksView/fetchMonthEndCloseChecks";
|
|
41
|
+
} | {
|
|
42
|
+
payload: {
|
|
43
|
+
jeSchedulesPayload: import("../../../../entity/jeSchedules/jeSchedulesPayload").JEScheduledTransactionPayload[];
|
|
44
|
+
scheduledJEntriesPayload: import("../../../../entity/jeSchedules/jeSchedulesPayload").ScheduledJournalEntryPayload[] | undefined;
|
|
45
|
+
updateType: import("../../../..").UpdateType;
|
|
46
|
+
};
|
|
47
|
+
type: "jeSchedules/updateJESchedulesDetails";
|
|
48
|
+
} | {
|
|
49
|
+
payload: {
|
|
50
|
+
jeScheduleKey: `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${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}`;
|
|
51
|
+
selectedPeriod: import("../../../..").MonthYearPeriod;
|
|
52
|
+
};
|
|
53
|
+
type: "expenseAutomationJESchedulesView/removeJeScheduleTransactionKey";
|
|
54
|
+
} | {
|
|
55
|
+
payload: {
|
|
56
|
+
jeScheduleTransactionKey: import("../../../..").JEScheduleTransactionKey;
|
|
57
|
+
status: import("../../../../responsePayload").ZeniAPIStatus;
|
|
58
|
+
};
|
|
59
|
+
type: "expenseAutomationJESchedulesView/revertJeScheduleFailure";
|
|
60
|
+
} | {
|
|
61
|
+
payload: {
|
|
62
|
+
jeScheduleTransactionKey: import("../../../..").JEScheduleTransactionKey;
|
|
63
|
+
};
|
|
64
|
+
type: "expenseAutomationJESchedulesView/revertJeScheduleSuccess";
|
|
65
|
+
}>;
|
|
@@ -0,0 +1,96 @@
|
|
|
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 jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
7
|
+
const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
|
|
8
|
+
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
9
|
+
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
10
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
11
|
+
const monthEndCloseChecksViewReducer_1 = require("../../../monthEndCloseChecksView/monthEndCloseChecksViewReducer");
|
|
12
|
+
const jeSchedulesPayload_1 = require("../../payload/jeSchedulesPayload");
|
|
13
|
+
const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
|
|
14
|
+
/**
|
|
15
|
+
* Undo a posted prepaid / fixed-asset schedule: deletes its posted QBO journal entry, then
|
|
16
|
+
* soft-deletes the scheduled entries and the schedule itself.
|
|
17
|
+
*
|
|
18
|
+
* Prepaid and fixed assets only — the endpoint rejects `accrued_expenses`, which has no revert
|
|
19
|
+
* path of its own. Two or more posted journal entries answer 409 and leave the schedule intact,
|
|
20
|
+
* so the failure is surfaced rather than swallowed.
|
|
21
|
+
*/
|
|
22
|
+
const revertJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.revertJeSchedule.match), (0, operators_1.mergeMap)((action) => {
|
|
23
|
+
const state = state$.value;
|
|
24
|
+
const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
|
|
25
|
+
const { jeScheduleId, jeScheduleTransactionKey, scheduleType, reason, note, } = action.payload;
|
|
26
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
27
|
+
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
28
|
+
const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleTransactionKey, state);
|
|
29
|
+
// Same fat blob as ignore, with the schedule id echoed back: the endpoint compares it to the
|
|
30
|
+
// URL id and rejects a mismatch. reason/note go under `feedback`, and `action` is stamped
|
|
31
|
+
// server-side, so sending it would be rejected as an unexpected field.
|
|
32
|
+
const schedulePayload = (0, jeSchedulesPayload_1.prepareIgnoreSchedulePayload)(scheduleType, jeScheduleTransactionState, state);
|
|
33
|
+
const payload = {
|
|
34
|
+
...schedulePayload,
|
|
35
|
+
je_schedules: schedulePayload.je_schedules.map((schedule, index) => index === 0
|
|
36
|
+
? {
|
|
37
|
+
...schedule,
|
|
38
|
+
je_schedule_id: jeScheduleId,
|
|
39
|
+
feedback: {
|
|
40
|
+
reason,
|
|
41
|
+
...(note != null && note !== '' ? { note } : {}),
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
: schedule),
|
|
45
|
+
};
|
|
46
|
+
return zeniAPI
|
|
47
|
+
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${jeScheduleId}/revert`, payload)
|
|
48
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
49
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
50
|
+
return (0, rxjs_1.from)([
|
|
51
|
+
(0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules),
|
|
52
|
+
(0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries),
|
|
53
|
+
(0, jeSchedulesViewReducer_1.revertJeScheduleSuccess)({ jeScheduleTransactionKey }),
|
|
54
|
+
(0, jeSchedulesViewReducer_1.removeJeScheduleTransactionKey)(jeScheduleTransactionKey, selectedPeriod),
|
|
55
|
+
(0, monthEndCloseChecksViewReducer_1.fetchMonthEndCloseChecks)({
|
|
56
|
+
tenantId: currentTenant.tenantId,
|
|
57
|
+
period: selectedPeriod,
|
|
58
|
+
refreshViewInBackground: true,
|
|
59
|
+
}),
|
|
60
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
61
|
+
messageSection: 'revert_schedule',
|
|
62
|
+
messageText: 'success',
|
|
63
|
+
type: 'success',
|
|
64
|
+
}),
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
return (0, rxjs_1.from)([
|
|
68
|
+
(0, jeSchedulesViewReducer_1.revertJeScheduleFailure)({
|
|
69
|
+
jeScheduleTransactionKey,
|
|
70
|
+
status: response.status,
|
|
71
|
+
}),
|
|
72
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
73
|
+
messageSection: 'revert_schedule',
|
|
74
|
+
messageText: 'failed',
|
|
75
|
+
type: 'error',
|
|
76
|
+
variables: [
|
|
77
|
+
{
|
|
78
|
+
variableName: '_api-error_',
|
|
79
|
+
variableValue: response.status.message,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
}),
|
|
83
|
+
]);
|
|
84
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
85
|
+
(0, jeSchedulesViewReducer_1.revertJeScheduleFailure)({
|
|
86
|
+
jeScheduleTransactionKey,
|
|
87
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Revert schedule REST API call errored out ${JSON.stringify(error)}`),
|
|
88
|
+
}),
|
|
89
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
90
|
+
messageSection: 'revert_schedule',
|
|
91
|
+
messageText: 'failed',
|
|
92
|
+
type: 'error',
|
|
93
|
+
}),
|
|
94
|
+
])));
|
|
95
|
+
}));
|
|
96
|
+
exports.revertJeScheduleEpic = revertJeScheduleEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
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>;
|
|
@@ -0,0 +1,26 @@
|
|
|
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;
|
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
|
@@ -0,0 +1,145 @@
|
|
|
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 formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
6
|
+
const formatZeniDateFY_2 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
7
|
+
const timePeriod_1 = 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_2.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(formatZeniDateFY_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_1.LAST_SCHEDULE_DAY_OF_MONTH : null);
|
|
105
|
+
const firstJEScheduleDate = jeScheduleDetails.length > 0
|
|
106
|
+
? jeScheduleDetails[0].postingDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)
|
|
107
|
+
: null;
|
|
108
|
+
const lastJEScheduleDate = jeScheduleDetails.length > 0
|
|
109
|
+
? jeScheduleDetails[jeScheduleDetails.length - 1].postingDate.format(formatZeniDateFY_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;
|
package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare const getLineItemsByTransactionsIdsFromResponse: (transactions: S
|
|
|
39
39
|
export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLocalData: TransactionReviewLocalDataSelectorView[], selectedTab: TransactionsTab) => Record<ID, string[]>;
|
|
40
40
|
export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
|
|
41
41
|
export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
|
|
42
|
-
messageSection: "reconcile" | "save_reconcile_for_later" | "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_approval_reorder" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_approval_reorder" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "card_policy_created" | "card_policy_updated" | "card_policy_deleted" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "snooze_task" | "unsnooze_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "create_transfer_entry" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "accounting_projects_enabled_update" | "accounting_projects_qbo_not_enabled" | "capitalization_threshold_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "statement_parsing_in_progress" | "statement_parsing_complete" | "ai_accountant_trigger_job" | "oauth_consent_approve" | "oauth_consent_invalid_request" | "credit_agent_update_profile" | "credit_agent_save_macro" | "credit_agent_schedule_cron" | "create_sub_task" | "qbo_connection_already_linked" | "qbo_connection_failed" | "accounting_projects_qbo_reconnect_failed" | "product_services_update" | "qbo_realm_id_update" | "invoicing_dunning_case_resolved" | "invoicing_dunning_retry" | "invoicing_dunning_cancel" | "invoicing_dunning_settings_save" | "invoicing_qbo_backfill" | "invoicing_qbo_sync_health_retry" | "invoicing_qbo_settings_save" | "invoicing_branding_save" | "invoicing_discount_archive" | "invoicing_discount_unarchive" | "invoicing_discount_delete" | "invoicing_invoice_reminder_sent" | "invoicing_invoice_regenerated" | "invoicing_invoice_voided" | "invoicing_catalog_item_saved" | "invoicing_customer_saved" | "invoicing_subscription_saved" | "invoicing_coupon_saved" | "invoicing_invoice_saved" | "invoicing_credit_note_saved" | "invoicing_payment_recorded" | "invoicing_subscription_activated" | "invoicing_subscription_cancellation_removed" | "invoicing_subscription_cancelled" | "invoicing_subscription_non_renewing" | "invoicing_subscription_paused" | "invoicing_subscription_reactivated" | "invoicing_subscription_resumed" | "invoicing_subscription_term_end_changed";
|
|
42
|
+
messageSection: "reconcile" | "save_reconcile_for_later" | "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_approval_reorder" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_approval_reorder" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "card_policy_created" | "card_policy_updated" | "card_policy_deleted" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "revert_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "snooze_task" | "unsnooze_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "create_transfer_entry" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "accounting_projects_enabled_update" | "accounting_projects_qbo_not_enabled" | "capitalization_threshold_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "statement_parsing_in_progress" | "statement_parsing_complete" | "ai_accountant_trigger_job" | "oauth_consent_approve" | "oauth_consent_invalid_request" | "credit_agent_update_profile" | "credit_agent_save_macro" | "credit_agent_schedule_cron" | "create_sub_task" | "qbo_connection_already_linked" | "qbo_connection_failed" | "accounting_projects_qbo_reconnect_failed" | "product_services_update" | "qbo_realm_id_update" | "invoicing_dunning_case_resolved" | "invoicing_dunning_retry" | "invoicing_dunning_cancel" | "invoicing_dunning_settings_save" | "invoicing_qbo_backfill" | "invoicing_qbo_sync_health_retry" | "invoicing_qbo_settings_save" | "invoicing_branding_save" | "invoicing_discount_archive" | "invoicing_discount_unarchive" | "invoicing_discount_delete" | "invoicing_invoice_reminder_sent" | "invoicing_invoice_regenerated" | "invoicing_invoice_voided" | "invoicing_catalog_item_saved" | "invoicing_customer_saved" | "invoicing_subscription_saved" | "invoicing_coupon_saved" | "invoicing_invoice_saved" | "invoicing_credit_note_saved" | "invoicing_payment_recorded" | "invoicing_subscription_activated" | "invoicing_subscription_cancellation_removed" | "invoicing_subscription_cancelled" | "invoicing_subscription_non_renewing" | "invoicing_subscription_paused" | "invoicing_subscription_reactivated" | "invoicing_subscription_resumed" | "invoicing_subscription_term_end_changed";
|
|
43
43
|
messageText: "notification" | "failed" | "success";
|
|
44
44
|
type: "error" | "success" | "info";
|
|
45
45
|
variables: {
|