@zeniai/client-epic-state 5.1.82 → 5.1.83-betaRD2
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/jeSchedules/jeScheduleHelper.d.ts +2 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +34 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +68 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +26 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +10 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +28 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +41 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +12 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +40 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
- package/lib/entity/tenant/clearAllEpic.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 +5 -1
- package/lib/epic.js +5 -1
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +68 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +26 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +26 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +34 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -1
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +5 -1
- package/lib/esm/index.js +11 -5
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +34 -3
- 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/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +163 -28
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +70 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +260 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +33 -9
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +35 -9
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +32 -5
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +23 -3
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +20 -3
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +60 -17
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +29 -10
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +28 -5
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +22 -14
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +46 -7
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +26 -8
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +41 -9
- package/lib/index.d.ts +18 -13
- package/lib/index.js +72 -50
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +32 -1
- 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/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 +8 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +45 -10
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +164 -28
- 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 +25 -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 +10 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +75 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +10 -1
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +266 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +59 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +2 -1
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +22 -8
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/view/invoicing/discountAction/discountActionEpic.d.ts +2 -1
- package/lib/view/invoicing/discountAction/discountActionEpic.js +32 -8
- package/lib/view/invoicing/dunningAction/dunningActionEpic.d.ts +2 -1
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +34 -8
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +31 -4
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +22 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +19 -2
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.d.ts +2 -1
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +59 -16
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +13 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +11 -31
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +15 -0
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +2 -1
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +28 -9
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +27 -4
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +24 -7
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +23 -16
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.d.ts +2 -1
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +45 -6
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +2 -1
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +25 -7
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +10 -1
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +4 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +2 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +40 -8
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer"
|
|
|
11
11
|
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
12
12
|
const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
|
|
13
13
|
const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
|
|
14
|
+
const jeSchedulesViewState_1 = require("../../types/jeSchedulesViewState");
|
|
14
15
|
const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(expenseAutomationViewReducer_1.fetchAllExpenseAutomationTabs.match), (0, operators_1.switchMap)((action) => {
|
|
15
16
|
const { cacheOverride, refreshViewInBackground } = action.payload;
|
|
16
17
|
const state = state$.value;
|
|
@@ -62,14 +63,16 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
|
|
|
62
63
|
state.expenseAutomationFluxAnalysisViewState.groupsBySelectedPeriod[monthYearPeriodId] == null)) {
|
|
63
64
|
fetchActions.push((0, fluxAnalysisViewReducer_1.fetchFluxAnalysisView)(selectedPeriod, cacheOverride, refreshViewInBackground, null));
|
|
64
65
|
}
|
|
66
|
+
// The two JE tabs cache separately, so only the tab actually being shown decides whether a
|
|
67
|
+
// fetch is still needed.
|
|
68
|
+
const jeSchedulesPeriodTabKey = (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab, monthYearPeriodId);
|
|
65
69
|
if (state.expenseAutomationJESchedulesViewState.fetchState !==
|
|
66
70
|
'In-Progress' &&
|
|
67
71
|
(!state.expenseAutomationJESchedulesViewState.hasValidState() ||
|
|
68
72
|
state.expenseAutomationJESchedulesViewState
|
|
69
|
-
.
|
|
73
|
+
.jeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null ||
|
|
70
74
|
state.expenseAutomationJESchedulesViewState
|
|
71
|
-
.
|
|
72
|
-
null)) {
|
|
75
|
+
.failedJeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null)) {
|
|
73
76
|
fetchActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
|
|
74
77
|
}
|
|
75
78
|
if (state.expenseAutomationReconciliationViewState.fetchState !==
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
3
|
+
import { updateAccruedJESchedules, updateAccruedJESchedulesDetails, updateJEOneTimeAccruals, updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
4
|
import { RootState } from '../../../../reducer';
|
|
5
5
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
6
|
import { fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesSuccess, initializeJeScheduleLocalData } from '../../reducers/jeSchedulesViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesFailure> | ReturnType<typeof fetchJeSchedulesSuccess> | ReturnType<typeof initializeJeScheduleLocalData> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesFailure> | ReturnType<typeof fetchJeSchedulesSuccess> | ReturnType<typeof initializeJeScheduleLocalData> | ReturnType<typeof updateAccruedJESchedules> | ReturnType<typeof updateAccruedJESchedulesDetails> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
|
|
8
8
|
export declare const fetchJeSchedulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchJeSchedulesEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const formatZeniDateFY_1 = require("../../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
|
|
6
7
|
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
8
|
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
8
9
|
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
9
10
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
11
|
+
const zeniDayJS_1 = require("../../../../zeniDayJS");
|
|
10
12
|
const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
|
|
11
13
|
const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.fetchJeSchedules.match), (0, operators_1.mergeMap)((action) => {
|
|
12
14
|
const state = state$.value;
|
|
@@ -14,27 +16,54 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
|
|
|
14
16
|
const { period, refreshViewInBackground } = action.payload;
|
|
15
17
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
16
18
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
19
|
+
const { selectedPageTab } = state.expenseAutomationJESchedulesViewState.uiState;
|
|
20
|
+
const isClosePeriodTab = selectedPageTab === 'schedules';
|
|
21
|
+
const existingEndDate = (0, timePeriod_1.toAbsoluteDay)((0, zeniDayJS_1.date)((0, timePeriod_1.toString)(period.start))
|
|
22
|
+
.subtract(1, 'month')
|
|
23
|
+
.endOf('month')
|
|
24
|
+
.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT));
|
|
17
25
|
const queryParam = {
|
|
18
26
|
start_date: (0, timePeriod_1.toString)(period.start),
|
|
19
|
-
end_date:
|
|
27
|
+
end_date: isClosePeriodTab || existingEndDate == null
|
|
28
|
+
? (0, timePeriod_1.toString)(period.end)
|
|
29
|
+
: (0, timePeriod_1.toString)(existingEndDate),
|
|
30
|
+
include_accrued: true,
|
|
31
|
+
...(isClosePeriodTab
|
|
32
|
+
? { close_period_start_date: (0, timePeriod_1.toString)(period.start) }
|
|
33
|
+
: {}),
|
|
20
34
|
};
|
|
21
35
|
return zeniAPI
|
|
22
36
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/je_schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
23
37
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
24
38
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
25
39
|
const updateActions = [];
|
|
40
|
+
const accruedJeSchedules = response.data.accrued_je_schedules?.je_schedules ?? [];
|
|
41
|
+
const oneTimeAccruals = response.data.one_time_accruals ?? [];
|
|
26
42
|
updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)([
|
|
27
43
|
...response.data.je_schedules,
|
|
28
44
|
...response.data.failed_je_postings.je_schedules,
|
|
29
45
|
]), (0, jeSchedulesReducer_1.updateJESchedulesDetails)([...response.data.failed_je_postings.je_schedules], response.data.failed_je_postings.scheduled_journal_entries), (0, jeSchedulesViewReducer_1.initializeJeScheduleLocalData)([
|
|
30
46
|
...response.data.failed_je_postings.je_schedules,
|
|
31
47
|
]));
|
|
48
|
+
if (accruedJeSchedules.length > 0) {
|
|
49
|
+
updateActions.push((0, jeSchedulesReducer_1.updateAccruedJESchedules)(accruedJeSchedules), (0, jeSchedulesReducer_1.updateAccruedJESchedulesDetails)(accruedJeSchedules, response.data.accrued_je_schedules
|
|
50
|
+
?.scheduled_journal_entries));
|
|
51
|
+
}
|
|
52
|
+
if (oneTimeAccruals.length > 0) {
|
|
53
|
+
// Single action, unlike the accrued pair above: this one writes the entity
|
|
54
|
+
// directly because an accrual denormalizes its vendor, accounts and classes, so
|
|
55
|
+
// there is no fan-out fetch to trigger.
|
|
56
|
+
updateActions.push((0, jeSchedulesReducer_1.updateJEOneTimeAccruals)(oneTimeAccruals));
|
|
57
|
+
}
|
|
32
58
|
updateActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesSuccess)({
|
|
33
59
|
jeSchedules: [...response.data.je_schedules],
|
|
34
60
|
failedJeSchedules: [
|
|
35
61
|
...response.data.failed_je_postings.je_schedules,
|
|
36
62
|
],
|
|
63
|
+
accruedJeSchedules: accruedJeSchedules,
|
|
64
|
+
oneTimeAccruals: oneTimeAccruals,
|
|
37
65
|
selectedPeriod: selectedPeriod,
|
|
66
|
+
selectedPageTab: selectedPageTab,
|
|
38
67
|
refreshViewInBackground: refreshViewInBackground,
|
|
39
68
|
}));
|
|
40
69
|
return (0, rxjs_1.from)(updateActions);
|
|
@@ -43,12 +72,14 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
|
|
|
43
72
|
return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesFailure)({
|
|
44
73
|
status: response.status,
|
|
45
74
|
selectedPeriod,
|
|
75
|
+
selectedPageTab,
|
|
46
76
|
}));
|
|
47
77
|
}
|
|
48
78
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesFailure)({
|
|
49
79
|
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch JE schedules REST API call errored out' +
|
|
50
80
|
JSON.stringify(error)),
|
|
51
81
|
selectedPeriod,
|
|
82
|
+
selectedPageTab,
|
|
52
83
|
}))));
|
|
53
84
|
}));
|
|
54
85
|
exports.fetchJeSchedulesEpic = fetchJeSchedulesEpic;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../../reducer';
|
|
4
|
+
import { fetchAccountList } from '../../../../accountList/accountListReducer';
|
|
5
|
+
import { fetchClassList } from '../../../../classList/classListReducer';
|
|
6
|
+
import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof clearSearchTransactionsForNewSchedule> | ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchClassList> | ReturnType<typeof initializeNewSchedule> | ReturnType<typeof resetNewScheduleLocalData>;
|
|
8
|
+
export declare const initializeNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializeNewScheduleEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const accountListReducer_1 = require("../../../../accountList/accountListReducer");
|
|
7
|
+
const classListReducer_1 = require("../../../../classList/classListReducer");
|
|
8
|
+
const scheduleListHelper_1 = require("../../../../scheduleView/scheduleListView/scheduleListHelper");
|
|
9
|
+
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
10
|
+
const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.initializeNewSchedule.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
+
const newScheduleActions = [];
|
|
12
|
+
const accountType = (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)();
|
|
13
|
+
const { accountListState, classListState } = state$.value;
|
|
14
|
+
if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
|
|
15
|
+
'Not-Started') {
|
|
16
|
+
newScheduleActions.push((0, accountListReducer_1.fetchAccountList)(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
|
|
17
|
+
}
|
|
18
|
+
if (classListState.fetchState === 'Not-Started') {
|
|
19
|
+
newScheduleActions.push((0, classListReducer_1.fetchClassList)());
|
|
20
|
+
}
|
|
21
|
+
newScheduleActions.push((0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType: action.payload.scheduleType }));
|
|
22
|
+
newScheduleActions.push((0, jeSchedulesViewReducer_1.clearSearchTransactionsForNewSchedule)());
|
|
23
|
+
return (0, rxjs_1.from)(newScheduleActions);
|
|
24
|
+
}));
|
|
25
|
+
exports.initializeNewScheduleEpic = initializeNewScheduleEpic;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { updateJESchedules, updateJESchedulesDetails } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
3
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { RootState } from '../../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
+
import { resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof saveNewSchedule> | ReturnType<typeof saveNewScheduleSuccess> | ReturnType<typeof saveNewScheduleFailure> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof resetNewScheduleLocalData> | ReturnType<typeof openSnackbar>;
|
|
8
|
+
export declare const saveNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
9
|
+
payload: {
|
|
10
|
+
messageSection: import("../../../../..").SnackbarMessageSections;
|
|
11
|
+
messageText: import("../../../../..").SnackbarMessageSectionTexts;
|
|
12
|
+
type: import("../../../../..").SnackbarMessageType;
|
|
13
|
+
showStatusIcon?: boolean;
|
|
14
|
+
variables?: {
|
|
15
|
+
variableName: string;
|
|
16
|
+
variableValue: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
type: "snackbar/openSnackbar";
|
|
20
|
+
} | {
|
|
21
|
+
payload: {
|
|
22
|
+
jeSchedulesTransactionsPayload: import("../../../../../entity/jeSchedules/jeSchedulesPayload").JEScheduledTransactionPayload[];
|
|
23
|
+
};
|
|
24
|
+
type: "jeSchedules/updateJESchedules";
|
|
25
|
+
} | {
|
|
26
|
+
payload: {
|
|
27
|
+
jeSchedulesPayload: import("../../../../../entity/jeSchedules/jeSchedulesPayload").JEScheduledTransactionPayload[];
|
|
28
|
+
scheduledJEntriesPayload: import("../../../../../entity/jeSchedules/jeSchedulesPayload").ScheduledJournalEntryPayload[] | undefined;
|
|
29
|
+
updateType: import("../../../../..").UpdateType;
|
|
30
|
+
};
|
|
31
|
+
type: "jeSchedules/updateJESchedulesDetails";
|
|
32
|
+
} | {
|
|
33
|
+
payload: {
|
|
34
|
+
scheduleType: "prepaid_expenses" | "fixed_assets";
|
|
35
|
+
};
|
|
36
|
+
type: "expenseAutomationJESchedulesView/resetNewScheduleLocalData";
|
|
37
|
+
} | {
|
|
38
|
+
payload: undefined;
|
|
39
|
+
type: "expenseAutomationJESchedulesView/saveNewScheduleSuccess";
|
|
40
|
+
} | {
|
|
41
|
+
payload: {
|
|
42
|
+
status: import("../../../../../responsePayload").ZeniAPIStatus;
|
|
43
|
+
};
|
|
44
|
+
type: "expenseAutomationJESchedulesView/saveNewScheduleFailure";
|
|
45
|
+
}>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveNewScheduleEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
7
|
+
const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedulesTypes");
|
|
8
|
+
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
9
|
+
const transactionSelector_1 = require("../../../../../entity/transaction/transactionSelector");
|
|
10
|
+
const responsePayload_1 = require("../../../../../responsePayload");
|
|
11
|
+
const newScheduleLocalDataHelper_1 = require("../../../helpers/newScheduleLocalDataHelper");
|
|
12
|
+
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
13
|
+
const FAILURE_REASON_MESSAGES = {
|
|
14
|
+
missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
|
|
15
|
+
missing_vendor: 'Select a vendor before saving this schedule.',
|
|
16
|
+
};
|
|
17
|
+
const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.saveNewSchedule.match), (0, operators_1.mergeMap)((action) => {
|
|
18
|
+
const { scheduleType } = action.payload;
|
|
19
|
+
const state = state$.value;
|
|
20
|
+
const localData = state.expenseAutomationJESchedulesViewState.newSchedule
|
|
21
|
+
.newScheduleState[scheduleType];
|
|
22
|
+
const { selectedBaseTransactionId } = localData;
|
|
23
|
+
const transaction = selectedBaseTransactionId != null
|
|
24
|
+
? (0, transactionSelector_1.getScheduleTransactionById)(state.transactionState, (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)(selectedBaseTransactionId))
|
|
25
|
+
: undefined;
|
|
26
|
+
if (transaction == null) {
|
|
27
|
+
return (0, rxjs_1.from)([
|
|
28
|
+
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
|
|
29
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No base transaction selected for this schedule.'),
|
|
30
|
+
}),
|
|
31
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
32
|
+
messageSection: 'create_schedule',
|
|
33
|
+
messageText: 'failed',
|
|
34
|
+
type: 'error',
|
|
35
|
+
variables: [
|
|
36
|
+
{
|
|
37
|
+
variableName: '_api-error_',
|
|
38
|
+
variableValue: 'No base transaction selected.',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
const result = (0, newScheduleLocalDataHelper_1.prepareNewSchedulePayload)(transaction, localData, scheduleType);
|
|
45
|
+
if (!result.ok) {
|
|
46
|
+
const message = FAILURE_REASON_MESSAGES[result.reason];
|
|
47
|
+
return (0, rxjs_1.from)([
|
|
48
|
+
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
|
|
49
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', message),
|
|
50
|
+
}),
|
|
51
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
52
|
+
messageSection: 'create_schedule',
|
|
53
|
+
messageText: 'failed',
|
|
54
|
+
type: 'error',
|
|
55
|
+
variables: [{ variableName: '_api-error_', variableValue: message }],
|
|
56
|
+
}),
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
|
|
60
|
+
const queryParam = {
|
|
61
|
+
je_schedule_type: scheduleType,
|
|
62
|
+
};
|
|
63
|
+
const payload = { ...result.payload };
|
|
64
|
+
return zeniAPI
|
|
65
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
|
|
66
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
67
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
68
|
+
return (0, rxjs_1.from)([
|
|
69
|
+
(0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules),
|
|
70
|
+
(0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries),
|
|
71
|
+
(0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType }),
|
|
72
|
+
(0, jeSchedulesViewReducer_1.saveNewScheduleSuccess)(),
|
|
73
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
74
|
+
messageSection: 'create_schedule',
|
|
75
|
+
messageText: 'success',
|
|
76
|
+
type: 'success',
|
|
77
|
+
variables: [
|
|
78
|
+
{ variableName: '_vendor_name_', variableValue: vendorName },
|
|
79
|
+
],
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
return (0, rxjs_1.from)([
|
|
84
|
+
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({ status: response.status }),
|
|
85
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
86
|
+
messageSection: 'create_schedule',
|
|
87
|
+
messageText: 'failed',
|
|
88
|
+
type: 'error',
|
|
89
|
+
variables: [
|
|
90
|
+
{
|
|
91
|
+
variableName: '_api-error_',
|
|
92
|
+
variableValue: response.status.message,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
}),
|
|
96
|
+
]);
|
|
97
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
98
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
99
|
+
messageSection: 'create_schedule',
|
|
100
|
+
messageText: 'failed',
|
|
101
|
+
type: 'error',
|
|
102
|
+
variables: [
|
|
103
|
+
{
|
|
104
|
+
variableName: '_api-error_',
|
|
105
|
+
variableValue: JSON.stringify(error),
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
|
|
110
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
|
|
111
|
+
}),
|
|
112
|
+
])));
|
|
113
|
+
}));
|
|
114
|
+
exports.saveNewScheduleEpic = saveNewScheduleEpic;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { updateScheduleTransactions } from '../../../../../entity/transaction/transactionReducer';
|
|
4
|
+
import { RootState } from '../../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
+
import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof searchTransactionsForNewSchedule> | ReturnType<typeof searchTransactionsForNewScheduleSuccess> | ReturnType<typeof searchTransactionsForNewScheduleFailure> | ReturnType<typeof updateScheduleTransactions>;
|
|
8
|
+
export declare const searchTransactionsForNewScheduleEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchTransactionsForNewScheduleEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedulesTypes");
|
|
7
|
+
const transactionType_1 = require("../../../../../entity/transaction/stateTypes/transactionType");
|
|
8
|
+
const transactionReducer_1 = require("../../../../../entity/transaction/transactionReducer");
|
|
9
|
+
const responsePayload_1 = require("../../../../../responsePayload");
|
|
10
|
+
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
11
|
+
const jeSchedulesViewState_1 = require("../../../types/jeSchedulesViewState");
|
|
12
|
+
/** Dropdown-sized result set — no pagination for Base Transaction search. */
|
|
13
|
+
const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
|
|
14
|
+
/** Fallback when the backend sends a null currency for a search result. */
|
|
15
|
+
const DEFAULT_CURRENCY_CODE = 'USD';
|
|
16
|
+
const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
17
|
+
const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
|
|
18
|
+
const searchActions$ = actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.searchTransactionsForNewSchedule.match));
|
|
19
|
+
/** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
|
|
20
|
+
const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH));
|
|
21
|
+
const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length >= jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH), (0, operators_1.debounceTime)(300));
|
|
22
|
+
return (0, rxjs_1.merge)(newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
|
|
23
|
+
const query = action.payload.query.trim();
|
|
24
|
+
if (query.length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
25
|
+
return rxjs_1.EMPTY;
|
|
26
|
+
}
|
|
27
|
+
const queryParam = {
|
|
28
|
+
page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
|
|
29
|
+
search_text: query,
|
|
30
|
+
je_schedule_type: action.payload.scheduleType,
|
|
31
|
+
};
|
|
32
|
+
return zeniAPI
|
|
33
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
34
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
35
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
36
|
+
const { transactions } = response.data;
|
|
37
|
+
const transactionsPerCurrency = {};
|
|
38
|
+
transactions.forEach((transaction) => {
|
|
39
|
+
const { currency_code, currency_symbol } = transaction;
|
|
40
|
+
const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
|
|
41
|
+
const existing = transactionsPerCurrency[currencyCode];
|
|
42
|
+
transactionsPerCurrency[currencyCode] =
|
|
43
|
+
existing != null
|
|
44
|
+
? {
|
|
45
|
+
currencySymbol: existing.currencySymbol,
|
|
46
|
+
transactions: [...existing.transactions, transaction],
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
currencySymbol: currency_code == null
|
|
50
|
+
? DEFAULT_CURRENCY_SYMBOL
|
|
51
|
+
: currency_symbol,
|
|
52
|
+
transactions: [transaction],
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
|
|
56
|
+
const perCurrency = transactionsPerCurrency[currencyCode];
|
|
57
|
+
return (0, transactionReducer_1.updateScheduleTransactions)(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
|
|
58
|
+
});
|
|
59
|
+
actionsOut.push((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleSuccess)({
|
|
60
|
+
searchResults: transactions.map((transaction) => (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)({
|
|
61
|
+
id: transaction.transaction_id,
|
|
62
|
+
type: (0, transactionType_1.toTransactionType)(transaction.transaction_type),
|
|
63
|
+
lineId: transaction.line_id,
|
|
64
|
+
})),
|
|
65
|
+
}));
|
|
66
|
+
return (0, rxjs_1.from)(actionsOut);
|
|
67
|
+
}
|
|
68
|
+
return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
|
|
69
|
+
status: response.status,
|
|
70
|
+
}));
|
|
71
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
|
|
72
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for new schedule errored: ' +
|
|
73
|
+
JSON.stringify(error)),
|
|
74
|
+
}))));
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
77
|
+
exports.searchTransactionsForNewScheduleEpic = searchTransactionsForNewScheduleEpic;
|
|
@@ -0,0 +1,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;
|