@zeniai/client-epic-state 5.2.14-betaRD0 → 5.2.14
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 +0 -1
- package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -78
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +4 -183
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -30
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -11
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -38
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -123
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -24
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -96
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
- package/lib/epic.d.ts +1 -9
- package/lib/epic.js +0 -16
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +5 -183
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -30
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -36
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -86
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/esm/epic.js +0 -16
- package/lib/esm/index.js +8 -14
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +5 -41
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +0 -55
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -319
- package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +0 -1
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -327
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
- package/lib/index.d.ts +12 -17
- package/lib/index.js +47 -91
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -39
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +3 -86
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -58
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +12 -93
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -321
- 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/jeAccountSettingsViewSelectorTypes.d.ts +0 -1
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +7 -41
- package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +0 -1
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +0 -34
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -335
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -83
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +2 -4
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -45
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -104
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -138
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -79
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -180
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -111
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -28
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -106
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +0 -21
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -49
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +0 -9
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -108
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -29
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -9
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -142
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -83
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +0 -13
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -187
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +0 -65
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -115
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -32
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -42
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -21
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -112
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { updateJEOneTimeAccruals } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
3
|
-
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { RootState } from '../../../../../reducer';
|
|
5
|
-
import { clearAll } from '../../../../../rootActions';
|
|
6
|
-
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
7
|
-
import { createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedules } from '../../../reducers/jeSchedulesViewReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof createOneTimeAccrual> | ReturnType<typeof createOneTimeAccrualSuccess> | ReturnType<typeof createOneTimeAccrualFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
|
|
9
|
-
export declare const createOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createOneTimeAccrualEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const timePeriod_1 = require("../../../../../commonStateTypes/timePeriod");
|
|
7
|
-
const jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
8
|
-
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
9
|
-
const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
|
|
10
|
-
const rootActions_1 = require("../../../../../rootActions");
|
|
11
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
12
|
-
const jeSchedulesPayload_1 = require("../../../payload/jeSchedulesPayload");
|
|
13
|
-
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
14
|
-
const createOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.createOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
15
|
-
const state = state$.value;
|
|
16
|
-
const { localData } = action.payload;
|
|
17
|
-
/*
|
|
18
|
-
* Idempotency for the create. agent-je dedupes on this: the same key again returns the
|
|
19
|
-
* existing accrual rather than posting a second JE to QBO.
|
|
20
|
-
*
|
|
21
|
-
* Body `request_id` rather than the `Idempotency-Key` header the API doc prefers, on Mohit's
|
|
22
|
-
* call (2026-08-24). The header cannot reach the service from a browser -- common's
|
|
23
|
-
* Access-Control-Allow-Headers does not list it, so cross-origin preflight rejects the
|
|
24
|
-
* request. Same meaning either way; the header simply wins when both are sent.
|
|
25
|
-
*
|
|
26
|
-
* Minted here, per create action, and deliberately not held in local data or the form: a new
|
|
27
|
-
* Save must produce a new key, and only a retry of *this* request may reuse one. Nothing
|
|
28
|
-
* retries today -- if a retry operator is ever added below, it has to sit inside this
|
|
29
|
-
* mergeMap so the key is not re-minted, or the guarantee is silently lost.
|
|
30
|
-
*/
|
|
31
|
-
const requestId = crypto.randomUUID();
|
|
32
|
-
const payload = {
|
|
33
|
-
...(0, jeSchedulesPayload_1.prepareCreateOneTimeAccrualPayload)(state, localData),
|
|
34
|
-
request_id: requestId,
|
|
35
|
-
};
|
|
36
|
-
// convertToPeriod destructures, so an unset period would throw here and take the epic
|
|
37
|
-
// subscription down for the whole session — a missed refresh is the cheaper failure.
|
|
38
|
-
const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
|
|
39
|
-
const selectedPeriod = selectedMonthYear != null
|
|
40
|
-
? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
|
|
41
|
-
: undefined;
|
|
42
|
-
const periodStart = selectedPeriod != null
|
|
43
|
-
? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
|
|
44
|
-
: undefined;
|
|
45
|
-
const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
|
|
46
|
-
return zeniAPI
|
|
47
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
|
|
48
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
49
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
50
|
-
const successActions = [
|
|
51
|
-
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
52
|
-
(0, jeSchedulesViewReducer_1.createOneTimeAccrualSuccess)(),
|
|
53
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
54
|
-
messageSection: 'create_schedule',
|
|
55
|
-
messageText: 'success',
|
|
56
|
-
type: 'success',
|
|
57
|
-
variables: [
|
|
58
|
-
{
|
|
59
|
-
variableName: '_vendor_name_',
|
|
60
|
-
variableValue: localData.vendorName,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
}),
|
|
64
|
-
];
|
|
65
|
-
// The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
|
|
66
|
-
// per fetch, and the backend decides whether a freshly posted accrual belongs to
|
|
67
|
-
// Review or Existing — so refetch rather than guess which bucket to insert into.
|
|
68
|
-
if (periodStart != null && periodEnd != null) {
|
|
69
|
-
successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
|
|
70
|
-
}
|
|
71
|
-
return (0, rxjs_1.from)(successActions);
|
|
72
|
-
}
|
|
73
|
-
return (0, rxjs_1.from)([
|
|
74
|
-
(0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({ status: response.status }),
|
|
75
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
76
|
-
messageSection: 'create_schedule',
|
|
77
|
-
messageText: 'failed',
|
|
78
|
-
type: 'error',
|
|
79
|
-
variables: [
|
|
80
|
-
{
|
|
81
|
-
variableName: '_api-error_',
|
|
82
|
-
variableValue: response.status.message,
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
}),
|
|
86
|
-
]);
|
|
87
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
88
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
89
|
-
messageSection: 'create_schedule',
|
|
90
|
-
messageText: 'failed',
|
|
91
|
-
type: 'error',
|
|
92
|
-
variables: [
|
|
93
|
-
{
|
|
94
|
-
variableName: '_api-error_',
|
|
95
|
-
variableValue: JSON.stringify(error),
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
}),
|
|
99
|
-
(0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({
|
|
100
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
|
|
101
|
-
}),
|
|
102
|
-
])),
|
|
103
|
-
// A tenant switch clears the store while this request is still in flight.
|
|
104
|
-
// Without this the old tenant's response is written back into the freshly
|
|
105
|
-
// cleared store and stays on screen under the new tenant.
|
|
106
|
-
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
107
|
-
}));
|
|
108
|
-
exports.createOneTimeAccrualEpic = createOneTimeAccrualEpic;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
// The account and class fetches above are idempotent (both guard on 'Not-Started'), so they
|
|
22
|
-
// can run on every open. Clearing what the user entered cannot, so it is opt-in.
|
|
23
|
-
if (action.payload.shouldResetEnteredData) {
|
|
24
|
-
newScheduleActions.push((0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType: action.payload.scheduleType }));
|
|
25
|
-
newScheduleActions.push((0, jeSchedulesViewReducer_1.clearSearchTransactionsForNewSchedule)());
|
|
26
|
-
}
|
|
27
|
-
return (0, rxjs_1.from)(newScheduleActions);
|
|
28
|
-
}));
|
|
29
|
-
exports.initializeNewScheduleEpic = initializeNewScheduleEpic;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { clearAll } from '../../../../../rootActions';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { RootState } from '../../../../../reducer';
|
|
6
|
-
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
7
|
-
import { fetchJeSchedules, resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess } from '../../../reducers/jeSchedulesViewReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof saveNewSchedule> | ReturnType<typeof saveNewScheduleSuccess> | ReturnType<typeof saveNewScheduleFailure> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof resetNewScheduleLocalData> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof clearAll> | ReturnType<typeof openSnackbar>;
|
|
9
|
-
export declare const saveNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
|
@@ -1,142 +0,0 @@
|
|
|
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 timePeriod_1 = require("../../../../../commonStateTypes/timePeriod");
|
|
7
|
-
const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
|
|
8
|
-
const rootActions_1 = require("../../../../../rootActions");
|
|
9
|
-
const jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
10
|
-
const jeSchedulesTypes_1 = require("../../../../../entity/jeSchedules/jeSchedulesTypes");
|
|
11
|
-
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
12
|
-
const transactionSelector_1 = require("../../../../../entity/transaction/transactionSelector");
|
|
13
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
14
|
-
const newScheduleLocalDataHelper_1 = require("../../../helpers/newScheduleLocalDataHelper");
|
|
15
|
-
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
16
|
-
const FAILURE_REASON_MESSAGES = {
|
|
17
|
-
missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
|
|
18
|
-
// The form cannot satisfy this: the vendor field is hard-disabled and inherited from the base
|
|
19
|
-
// transaction, so the fix is on the transaction, not here.
|
|
20
|
-
missing_vendor: 'This transaction has no vendor and cannot be scheduled. Add a vendor to the transaction first.',
|
|
21
|
-
};
|
|
22
|
-
const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.saveNewSchedule.match), (0, operators_1.mergeMap)((action) => {
|
|
23
|
-
const { scheduleType } = action.payload;
|
|
24
|
-
const state = state$.value;
|
|
25
|
-
const localData = state.expenseAutomationJESchedulesViewState.newSchedule
|
|
26
|
-
.newScheduleState[scheduleType];
|
|
27
|
-
const { selectedBaseTransactionId } = localData;
|
|
28
|
-
const transaction = selectedBaseTransactionId != null
|
|
29
|
-
? (0, transactionSelector_1.getScheduleTransactionById)(state.transactionState, (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)(selectedBaseTransactionId))
|
|
30
|
-
: undefined;
|
|
31
|
-
if (transaction == null) {
|
|
32
|
-
return (0, rxjs_1.from)([
|
|
33
|
-
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
|
|
34
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'No base transaction selected for this schedule.'),
|
|
35
|
-
}),
|
|
36
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
37
|
-
messageSection: 'create_schedule',
|
|
38
|
-
messageText: 'failed',
|
|
39
|
-
type: 'error',
|
|
40
|
-
variables: [
|
|
41
|
-
{
|
|
42
|
-
variableName: '_api-error_',
|
|
43
|
-
variableValue: 'No base transaction selected.',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
}),
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
const result = (0, newScheduleLocalDataHelper_1.prepareNewSchedulePayload)(transaction, localData, scheduleType);
|
|
50
|
-
if (!result.ok) {
|
|
51
|
-
const message = FAILURE_REASON_MESSAGES[result.reason];
|
|
52
|
-
return (0, rxjs_1.from)([
|
|
53
|
-
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
|
|
54
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', message),
|
|
55
|
-
}),
|
|
56
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
57
|
-
messageSection: 'create_schedule',
|
|
58
|
-
messageText: 'failed',
|
|
59
|
-
type: 'error',
|
|
60
|
-
variables: [{ variableName: '_api-error_', variableValue: message }],
|
|
61
|
-
}),
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
|
|
65
|
-
const queryParam = {
|
|
66
|
-
je_schedule_type: scheduleType,
|
|
67
|
-
};
|
|
68
|
-
const payload = { ...result.payload };
|
|
69
|
-
// convertToPeriod destructures, so an unset period would throw here and take the epic
|
|
70
|
-
// subscription down for the whole session -- a missed refresh is the cheaper failure.
|
|
71
|
-
const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
|
|
72
|
-
const selectedPeriod = selectedMonthYear != null
|
|
73
|
-
? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
|
|
74
|
-
: undefined;
|
|
75
|
-
const periodStart = selectedPeriod != null
|
|
76
|
-
? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
|
|
77
|
-
: undefined;
|
|
78
|
-
const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
|
|
79
|
-
return zeniAPI
|
|
80
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
|
|
81
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
82
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
83
|
-
const successActions = [
|
|
84
|
-
(0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules),
|
|
85
|
-
(0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries),
|
|
86
|
-
(0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType }),
|
|
87
|
-
(0, jeSchedulesViewReducer_1.saveNewScheduleSuccess)(),
|
|
88
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
89
|
-
messageSection: 'create_schedule',
|
|
90
|
-
messageText: 'success',
|
|
91
|
-
type: 'success',
|
|
92
|
-
variables: [
|
|
93
|
-
{ variableName: '_vendor_name_', variableValue: vendorName },
|
|
94
|
-
],
|
|
95
|
-
}),
|
|
96
|
-
];
|
|
97
|
-
// Writing the entity is not enough: the list reads
|
|
98
|
-
// jeScheduleTransactionKeysByPeriodAndTab, which is rebuilt wholesale per fetch, so
|
|
99
|
-
// without this the new schedule stays invisible until some later fetch. The page
|
|
100
|
-
// only refetches when the save also changes tab, so saving from the tab the row
|
|
101
|
-
// lands on showed nothing. Same reasoning as createOneTimeAccrualEpic.
|
|
102
|
-
if (periodStart != null && periodEnd != null) {
|
|
103
|
-
successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
|
|
104
|
-
}
|
|
105
|
-
return (0, rxjs_1.from)(successActions);
|
|
106
|
-
}
|
|
107
|
-
return (0, rxjs_1.from)([
|
|
108
|
-
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({ status: response.status }),
|
|
109
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
110
|
-
messageSection: 'create_schedule',
|
|
111
|
-
messageText: 'failed',
|
|
112
|
-
type: 'error',
|
|
113
|
-
variables: [
|
|
114
|
-
{
|
|
115
|
-
variableName: '_api-error_',
|
|
116
|
-
variableValue: response.status.message,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
}),
|
|
120
|
-
]);
|
|
121
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
122
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
123
|
-
messageSection: 'create_schedule',
|
|
124
|
-
messageText: 'failed',
|
|
125
|
-
type: 'error',
|
|
126
|
-
variables: [
|
|
127
|
-
{
|
|
128
|
-
variableName: '_api-error_',
|
|
129
|
-
variableValue: JSON.stringify(error),
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
}),
|
|
133
|
-
(0, jeSchedulesViewReducer_1.saveNewScheduleFailure)({
|
|
134
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
|
|
135
|
-
}),
|
|
136
|
-
])),
|
|
137
|
-
// A tenant switch clears the store while this request is still in flight.
|
|
138
|
-
// Without this the old tenant's response is written back into the freshly
|
|
139
|
-
// cleared store and stays on screen under the new tenant.
|
|
140
|
-
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
141
|
-
}));
|
|
142
|
-
exports.saveNewScheduleEpic = saveNewScheduleEpic;
|
|
@@ -1,8 +0,0 @@
|
|
|
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>;
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
/**
|
|
13
|
-
* Dropdown-sized result set. The endpoint is paginated — it takes a `page_token` $skip offset and
|
|
14
|
-
* returns `next_page_token` — but nothing here reads or sends those, so this is the whole result
|
|
15
|
-
* set the form ever sees. 20 rather than the backend's default of 10 because a text search for one
|
|
16
|
-
* known transaction was running out of room; the cap server-side is 100 if this needs raising again
|
|
17
|
-
* before infinite scroll is wired up.
|
|
18
|
-
*/
|
|
19
|
-
const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 20;
|
|
20
|
-
/** Fallback when the backend sends a null currency for a search result. */
|
|
21
|
-
const DEFAULT_CURRENCY_CODE = 'USD';
|
|
22
|
-
const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
23
|
-
const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
|
|
24
|
-
const searchActions$ = actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.searchTransactionsForNewSchedule.match));
|
|
25
|
-
/** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
|
|
26
|
-
const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((action) => action.payload.query.trim().length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH));
|
|
27
|
-
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));
|
|
28
|
-
return (0, rxjs_1.merge)(newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
|
|
29
|
-
const query = action.payload.query.trim();
|
|
30
|
-
if (query.length < jeSchedulesViewState_1.MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
31
|
-
return rxjs_1.EMPTY;
|
|
32
|
-
}
|
|
33
|
-
const queryParam = {
|
|
34
|
-
page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
|
|
35
|
-
search_text: query,
|
|
36
|
-
je_schedule_type: action.payload.scheduleType,
|
|
37
|
-
};
|
|
38
|
-
return zeniAPI
|
|
39
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
40
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
41
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
42
|
-
const { transactions } = response.data;
|
|
43
|
-
const transactionsPerCurrency = {};
|
|
44
|
-
transactions.forEach((transaction) => {
|
|
45
|
-
const { currency_code, currency_symbol } = transaction;
|
|
46
|
-
const currencyCode = currency_code ?? DEFAULT_CURRENCY_CODE;
|
|
47
|
-
const existing = transactionsPerCurrency[currencyCode];
|
|
48
|
-
transactionsPerCurrency[currencyCode] =
|
|
49
|
-
existing != null
|
|
50
|
-
? {
|
|
51
|
-
currencySymbol: existing.currencySymbol,
|
|
52
|
-
transactions: [...existing.transactions, transaction],
|
|
53
|
-
}
|
|
54
|
-
: {
|
|
55
|
-
currencySymbol: currency_code == null
|
|
56
|
-
? DEFAULT_CURRENCY_SYMBOL
|
|
57
|
-
: currency_symbol,
|
|
58
|
-
transactions: [transaction],
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
const actionsOut = Object.keys(transactionsPerCurrency).map((currencyCode) => {
|
|
62
|
-
const perCurrency = transactionsPerCurrency[currencyCode];
|
|
63
|
-
return (0, transactionReducer_1.updateScheduleTransactions)(perCurrency.transactions, currencyCode, perCurrency.currencySymbol, 'merge');
|
|
64
|
-
});
|
|
65
|
-
actionsOut.push((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleSuccess)({
|
|
66
|
-
searchResults: transactions.map((transaction) => (0, jeSchedulesTypes_1.getJEScheduleTransactionKey)({
|
|
67
|
-
id: transaction.transaction_id,
|
|
68
|
-
type: (0, transactionType_1.toTransactionType)(transaction.transaction_type),
|
|
69
|
-
lineId: transaction.line_id,
|
|
70
|
-
})),
|
|
71
|
-
}));
|
|
72
|
-
return (0, rxjs_1.from)(actionsOut);
|
|
73
|
-
}
|
|
74
|
-
return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
|
|
75
|
-
status: response.status,
|
|
76
|
-
}));
|
|
77
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.searchTransactionsForNewScheduleFailure)({
|
|
78
|
-
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Search transactions for new schedule errored: ' +
|
|
79
|
-
JSON.stringify(error)),
|
|
80
|
-
}))));
|
|
81
|
-
}));
|
|
82
|
-
};
|
|
83
|
-
exports.searchTransactionsForNewScheduleEpic = searchTransactionsForNewScheduleEpic;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { RootState } from '../../../../reducer';
|
|
6
|
-
import { clearAll } from '../../../../rootActions';
|
|
7
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
8
|
-
import { fetchJeSchedules, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertOneTimeAccrual } from '../../reducers/jeSchedulesViewReducer';
|
|
9
|
-
export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof promoteOneTimeAccrual> | ReturnType<typeof revertOneTimeAccrual> | ReturnType<typeof ignoreOneTimeAccrual> | ReturnType<typeof oneTimeAccrualActionSuccess> | ReturnType<typeof oneTimeAccrualActionFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
|
|
10
|
-
export declare const promoteOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
11
|
-
export declare const ignoreOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
12
|
-
export declare const revertOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
13
|
-
export declare const oneTimeAccrualActionsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.oneTimeAccrualActionsEpic = exports.revertOneTimeAccrualEpic = exports.ignoreOneTimeAccrualEpic = exports.promoteOneTimeAccrualEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
|
-
const jeScheduleHelper_1 = require("../../../../entity/jeSchedules/jeScheduleHelper");
|
|
8
|
-
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
9
|
-
const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
|
|
10
|
-
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
11
|
-
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
12
|
-
const rootActions_1 = require("../../../../rootActions");
|
|
13
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
14
|
-
const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
|
|
15
|
-
/**
|
|
16
|
-
* The page the accrual came from, so a promoted or ignored row lands in the right bucket. Guarded
|
|
17
|
-
* because convertToPeriod destructures: an unset period would throw and take the epic subscription
|
|
18
|
-
* down for the session, and a missed refresh is the cheaper failure.
|
|
19
|
-
*
|
|
20
|
-
* Read state$.value at response time rather than the snapshot taken when the action was dispatched:
|
|
21
|
-
* if the user changes month while the request is in flight, the snapshot refreshes the month they
|
|
22
|
-
* have left and the month they are now looking at stays stale.
|
|
23
|
-
*/
|
|
24
|
-
function refreshCurrentPage(state) {
|
|
25
|
-
const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
|
|
26
|
-
if (selectedMonthYear == null) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const period = (0, timePeriod_1.convertToPeriod)(selectedMonthYear);
|
|
30
|
-
const start = (0, timePeriod_1.toAbsoluteDay)(period.start);
|
|
31
|
-
const end = (0, timePeriod_1.toAbsoluteDay)(period.end);
|
|
32
|
-
if (start == null || end == null) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
return [(0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start, end }, true)];
|
|
36
|
-
}
|
|
37
|
-
function failureActions(
|
|
38
|
-
// Per action, not fixed: every failure used to read "Save schedule failed", so skipping or
|
|
39
|
-
// reverting an accrual reported an operation the user had not performed.
|
|
40
|
-
messageSection, accrualId, message, status) {
|
|
41
|
-
return [
|
|
42
|
-
(0, jeSchedulesViewReducer_1.oneTimeAccrualActionFailure)({
|
|
43
|
-
accrualId,
|
|
44
|
-
status: status ?? (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', message),
|
|
45
|
-
}),
|
|
46
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
47
|
-
messageSection,
|
|
48
|
-
messageText: 'failed',
|
|
49
|
-
type: 'error',
|
|
50
|
-
variables: [{ variableName: '_api-error_', variableValue: message }],
|
|
51
|
-
}),
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
const promoteOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.promoteOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
55
|
-
const state = state$.value;
|
|
56
|
-
const { accrualId, amount, edits } = action.payload;
|
|
57
|
-
const accrual = (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)((0, jeScheduleHelper_1.generateJEOneTimeAccrualKey)(accrualId), state.jeSchedulesState);
|
|
58
|
-
// An edited value wins; anything untouched falls back to the stored draft, which is what the
|
|
59
|
-
// list's inline Post sends.
|
|
60
|
-
const debitAccountId = edits?.jeDebitAccountId ?? accrual?.jeDebitAccountId;
|
|
61
|
-
const creditAccountId = edits?.jeCreditAccountId ?? accrual?.jeCreditAccountId;
|
|
62
|
-
if (debitAccountId == null || creditAccountId == null) {
|
|
63
|
-
// Promote posts a journal entry, so it cannot proceed without both sides of it.
|
|
64
|
-
return (0, rxjs_1.from)(failureActions('save_schedule', accrualId, 'This accrual is missing an expense or liability account.'));
|
|
65
|
-
}
|
|
66
|
-
// vendor_id, vendor_name and service_month are deliberately absent: promote takes them from
|
|
67
|
-
// the stored draft and ignores them in the body, so sending them would imply a reassignment
|
|
68
|
-
// that never happens.
|
|
69
|
-
// Untouched falls back to the stored policy, so posting without editing cannot silently
|
|
70
|
-
// flip a scheduled reversal to on-bill-match.
|
|
71
|
-
const reverseNextMonth = edits?.reverseNextMonth ??
|
|
72
|
-
accrual?.reversalPolicy === 'scheduled_date';
|
|
73
|
-
const expectedReversalDate = edits?.expectedReversalDate ?? accrual?.expectedReversalDate;
|
|
74
|
-
const debitClassId = edits?.jeDebitAccountingClassId ?? accrual?.jeDebitAccountingClassId;
|
|
75
|
-
const debitClassName = edits?.jeDebitAccountingClassName ??
|
|
76
|
-
accrual?.jeDebitAccountingClassName;
|
|
77
|
-
const payload = {
|
|
78
|
-
amount,
|
|
79
|
-
memo: edits?.memo ?? accrual?.memo ?? '',
|
|
80
|
-
je_debit_account_id: debitAccountId,
|
|
81
|
-
je_credit_account_id: creditAccountId,
|
|
82
|
-
...(debitClassId != null ? { je_debit_accounting_class_id: debitClassId } : {}),
|
|
83
|
-
...(debitClassName != null
|
|
84
|
-
? { je_debit_accounting_class_name: debitClassName }
|
|
85
|
-
: {}),
|
|
86
|
-
// Mirrors the create payload: reverse_next_month alone decides the policy, and the date is
|
|
87
|
-
// only meaningful when it is true -- agent-je derives the reversal from the bill otherwise.
|
|
88
|
-
reverse_next_month: reverseNextMonth,
|
|
89
|
-
...(reverseNextMonth && expectedReversalDate != null
|
|
90
|
-
? {
|
|
91
|
-
expected_reversal_date: expectedReversalDate.format(timePeriod_1.DEFAULT_DATE_FORMAT),
|
|
92
|
-
}
|
|
93
|
-
: {}),
|
|
94
|
-
};
|
|
95
|
-
return zeniAPI
|
|
96
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`, { ...payload })
|
|
97
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
98
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
99
|
-
return (0, rxjs_1.from)([
|
|
100
|
-
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
101
|
-
(0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
|
|
102
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
103
|
-
messageSection: 'save_schedule',
|
|
104
|
-
messageText: 'success',
|
|
105
|
-
type: 'success',
|
|
106
|
-
variables: [
|
|
107
|
-
{
|
|
108
|
-
variableName: '_vendor_name_',
|
|
109
|
-
variableValue: accrual?.vendorName ?? '',
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
}),
|
|
113
|
-
...refreshCurrentPage(state$.value),
|
|
114
|
-
]);
|
|
115
|
-
}
|
|
116
|
-
return (0, rxjs_1.from)(failureActions('save_schedule', accrualId, response.status.message, response.status));
|
|
117
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions('save_schedule', accrualId, `Promote accrual REST API call errored out ${JSON.stringify(error)}`))),
|
|
118
|
-
// A tenant switch clears the store while this request is still in flight.
|
|
119
|
-
// Without this the old tenant's response is written back into the freshly
|
|
120
|
-
// cleared store and stays on screen under the new tenant.
|
|
121
|
-
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
122
|
-
}));
|
|
123
|
-
exports.promoteOneTimeAccrualEpic = promoteOneTimeAccrualEpic;
|
|
124
|
-
const ignoreOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.ignoreOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
125
|
-
const { accrualId, reason, note } = action.payload;
|
|
126
|
-
// `scope` is deliberately never sent: the API returns 400 on it, which is why the design's
|
|
127
|
-
// "Apply to" selector cannot be built yet.
|
|
128
|
-
const payload = {
|
|
129
|
-
reason,
|
|
130
|
-
...(note != null && note !== '' ? { note } : {}),
|
|
131
|
-
};
|
|
132
|
-
return zeniAPI
|
|
133
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/ignore`, { ...payload })
|
|
134
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
135
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
136
|
-
return (0, rxjs_1.from)([
|
|
137
|
-
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
138
|
-
(0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
|
|
139
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
140
|
-
messageSection: 'ignore_accrual',
|
|
141
|
-
messageText: 'success',
|
|
142
|
-
type: 'success',
|
|
143
|
-
}),
|
|
144
|
-
...refreshCurrentPage(state$.value),
|
|
145
|
-
]);
|
|
146
|
-
}
|
|
147
|
-
return (0, rxjs_1.from)(failureActions('ignore_accrual', accrualId, response.status.message, response.status));
|
|
148
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions('ignore_accrual', accrualId, `Ignore accrual REST API call errored out ${JSON.stringify(error)}`))),
|
|
149
|
-
// A tenant switch clears the store while this request is still in flight.
|
|
150
|
-
// Without this the old tenant's response is written back into the freshly
|
|
151
|
-
// cleared store and stays on screen under the new tenant.
|
|
152
|
-
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
153
|
-
}));
|
|
154
|
-
exports.ignoreOneTimeAccrualEpic = ignoreOneTimeAccrualEpic;
|
|
155
|
-
const revertOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.revertOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
156
|
-
const { accrualId, reason, note } = action.payload;
|
|
157
|
-
// Deletes the accrual's journal entry in QBO and soft-deletes the row. `scope` is never sent:
|
|
158
|
-
// the endpoint 400s on it, exactly as ignore does.
|
|
159
|
-
const payload = {
|
|
160
|
-
reason,
|
|
161
|
-
...(note != null && note !== '' ? { note } : {}),
|
|
162
|
-
};
|
|
163
|
-
return zeniAPI
|
|
164
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}/revert`, { ...payload })
|
|
165
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
166
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
167
|
-
return (0, rxjs_1.from)([
|
|
168
|
-
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
169
|
-
(0, jeSchedulesViewReducer_1.oneTimeAccrualActionSuccess)({ accrualId }),
|
|
170
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
171
|
-
messageSection: 'revert_accrual',
|
|
172
|
-
messageText: 'success',
|
|
173
|
-
type: 'success',
|
|
174
|
-
}),
|
|
175
|
-
...refreshCurrentPage(state$.value),
|
|
176
|
-
]);
|
|
177
|
-
}
|
|
178
|
-
return (0, rxjs_1.from)(failureActions('revert_accrual', accrualId, response.status.message, response.status));
|
|
179
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)(failureActions('revert_accrual', accrualId, `Revert accrual REST API call errored out ${JSON.stringify(error)}`))),
|
|
180
|
-
// A tenant switch clears the store while this request is still in flight.
|
|
181
|
-
// Without this the old tenant's response is written back into the freshly
|
|
182
|
-
// cleared store and stays on screen under the new tenant.
|
|
183
|
-
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
184
|
-
}));
|
|
185
|
-
exports.revertOneTimeAccrualEpic = revertOneTimeAccrualEpic;
|
|
186
|
-
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));
|
|
187
|
-
exports.oneTimeAccrualActionsEpic = oneTimeAccrualActionsEpic;
|