@zeniai/client-epic-state 5.1.67 → 5.1.68-beta0GS
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/tenant/clearAllEpic.d.ts +2 -1
- package/lib/entity/tenant/clearAllEpic.js +2 -0
- package/lib/epic.d.ts +6 -3
- package/lib/epic.js +6 -3
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
- package/lib/esm/epic.js +6 -3
- package/lib/esm/index.js +7 -4
- package/lib/esm/reducer.js +3 -0
- package/lib/esm/view/invoicing/createInvoice/createInvoiceReducer.js +15 -1
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +5 -1
- package/lib/esm/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.js +50 -0
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +0 -1
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +21 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.js +20 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.js +1 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.js +76 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.js +9 -0
- package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.js +1 -0
- package/lib/esm/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +4 -4
- package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +1 -1
- package/lib/esm/view/spendManagement/helpers.js +1 -1
- package/lib/esm/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +4 -4
- package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListSelector.js +2 -2
- package/lib/index.d.ts +9 -4
- package/lib/index.js +58 -49
- package/lib/reducer.d.ts +3 -0
- package/lib/reducer.js +3 -0
- package/lib/view/invoicing/createInvoice/createInvoiceReducer.d.ts +5 -1
- package/lib/view/invoicing/createInvoice/createInvoiceReducer.js +16 -2
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +1 -0
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +5 -1
- package/lib/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.d.ts +15 -0
- package/lib/view/invoicing/createInvoice/epics/fetchCreateInvoiceFormPageEpic.js +54 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js +0 -1
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.d.ts +7 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +25 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.d.ts +6 -0
- package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.js +24 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.d.ts +29 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.js +2 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.d.ts +16 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.js +80 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.d.ts +12 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.js +12 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.d.ts +8 -0
- package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.js +2 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.d.ts +1 -0
- package/lib/view/spendManagement/billPay/billDetailView/billDetailViewSelector.js +4 -4
- package/lib/view/spendManagement/billPay/billList/billListSelector.js +1 -1
- package/lib/view/spendManagement/helpers.js +1 -1
- package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +4 -4
- package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.js +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,10 @@ import { CreateInvoiceState, InvoicingCreateInvoiceFormLocalData } from './creat
|
|
|
5
5
|
export declare const initialState: CreateInvoiceState;
|
|
6
6
|
export declare const createInvoice: import("@reduxjs/toolkit").ActionCreatorWithPayload<CreateInvoiceRequest, "invoicingCreateInvoice/createInvoice">, createInvoiceSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
7
7
|
invoiceId: ID;
|
|
8
|
-
}, "invoicingCreateInvoice/createInvoiceSuccess">, createInvoiceFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCreateInvoice/createInvoiceFailure">,
|
|
8
|
+
}, "invoicingCreateInvoice/createInvoiceSuccess">, createInvoiceFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingCreateInvoice/createInvoiceFailure">, fetchCreateInvoiceFormPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
|
|
9
|
+
cacheOverride: boolean;
|
|
10
|
+
}], {
|
|
11
|
+
cacheOverride: boolean;
|
|
12
|
+
}, "invoicingCreateInvoice/fetchCreateInvoiceFormPage", never, never>, resetCreateInvoice: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingCreateInvoice/resetCreateInvoice">, updateInvoicingCreateInvoiceFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingCreateInvoiceFormLocalData, "invoicingCreateInvoice/updateInvoicingCreateInvoiceFormDraft">;
|
|
9
13
|
declare const _default: import("redux").Reducer<CreateInvoiceState>;
|
|
10
14
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.updateInvoicingCreateInvoiceFormDraft = exports.resetCreateInvoice = exports.createInvoiceFailure = exports.createInvoiceSuccess = exports.createInvoice = exports.initialState = void 0;
|
|
4
|
+
exports.updateInvoicingCreateInvoiceFormDraft = exports.resetCreateInvoice = exports.fetchCreateInvoiceFormPage = exports.createInvoiceFailure = exports.createInvoiceSuccess = exports.createInvoice = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const createInvoiceFormConfig_1 = require("./createInvoiceFormConfig");
|
|
7
7
|
exports.initialState = {
|
|
@@ -18,6 +18,20 @@ const createInvoiceSlice = (0, toolkit_1.createSlice)({
|
|
|
18
18
|
name: 'invoicingCreateInvoice',
|
|
19
19
|
initialState: exports.initialState,
|
|
20
20
|
reducers: {
|
|
21
|
+
/**
|
|
22
|
+
* Trigger-only action for {@link fetchCreateInvoiceFormPageEpic}: fans out to
|
|
23
|
+
* the customer/plan/product/settings fetches, skipping any already cached
|
|
24
|
+
* unless `cacheOverride` is set. Holds no state of its own.
|
|
25
|
+
*/
|
|
26
|
+
fetchCreateInvoiceFormPage: {
|
|
27
|
+
reducer() {
|
|
28
|
+
// No state mutation; fetchCreateInvoiceFormPageEpic fans out to the
|
|
29
|
+
// customer/plan/product/settings fetches in response to this action.
|
|
30
|
+
},
|
|
31
|
+
prepare(payload) {
|
|
32
|
+
return { payload };
|
|
33
|
+
},
|
|
34
|
+
},
|
|
21
35
|
updateInvoicingCreateInvoiceFormDraft(draft, action) {
|
|
22
36
|
draft.formDraft = action.payload;
|
|
23
37
|
},
|
|
@@ -41,5 +55,5 @@ const createInvoiceSlice = (0, toolkit_1.createSlice)({
|
|
|
41
55
|
},
|
|
42
56
|
},
|
|
43
57
|
});
|
|
44
|
-
_a = createInvoiceSlice.actions, exports.createInvoice = _a.createInvoice, exports.createInvoiceSuccess = _a.createInvoiceSuccess, exports.createInvoiceFailure = _a.createInvoiceFailure, exports.resetCreateInvoice = _a.resetCreateInvoice, exports.updateInvoicingCreateInvoiceFormDraft = _a.updateInvoicingCreateInvoiceFormDraft;
|
|
58
|
+
_a = createInvoiceSlice.actions, exports.createInvoice = _a.createInvoice, exports.createInvoiceSuccess = _a.createInvoiceSuccess, exports.createInvoiceFailure = _a.createInvoiceFailure, exports.fetchCreateInvoiceFormPage = _a.fetchCreateInvoiceFormPage, exports.resetCreateInvoice = _a.resetCreateInvoice, exports.updateInvoicingCreateInvoiceFormDraft = _a.updateInvoicingCreateInvoiceFormDraft;
|
|
45
59
|
exports.default = createInvoiceSlice.reducer;
|
|
@@ -8,6 +8,7 @@ import { InvoicingCreateInvoiceFormLocalData } from './createInvoiceState';
|
|
|
8
8
|
export interface CreateInvoiceFormView extends SelectorView {
|
|
9
9
|
customers: InvoicingCustomer[];
|
|
10
10
|
localData: InvoicingCreateInvoiceFormLocalData;
|
|
11
|
+
planNames: string[];
|
|
11
12
|
plans: InvoicingProduct[];
|
|
12
13
|
products: InvoicingProduct[];
|
|
13
14
|
savedInvoiceId?: ID;
|
|
@@ -15,10 +15,14 @@ const settingsViewSelector_1 = require("../settingsView/settingsViewSelector");
|
|
|
15
15
|
const getCreateInvoiceFormView = (state) => {
|
|
16
16
|
const createInvoiceState = state.invoicingCreateInvoiceState;
|
|
17
17
|
const catalogListView = (0, invoicingCatalogListViewSelector_1.getInvoicingCatalogListView)(state);
|
|
18
|
+
const plans = (0, invoicingCatalogListViewSelector_1.getInvoicingCatalogPrices)(catalogListView.plans);
|
|
18
19
|
return {
|
|
19
20
|
customers: (0, invoicingCustomerListViewSelector_1.getInvoicingCustomerListView)(state).customers,
|
|
20
21
|
localData: createInvoiceState.formDraft,
|
|
21
|
-
|
|
22
|
+
planNames: plans
|
|
23
|
+
.map((plan) => plan.name ?? '')
|
|
24
|
+
.filter((name) => name !== ''),
|
|
25
|
+
plans,
|
|
22
26
|
products: (0, invoicingCatalogListViewSelector_1.getInvoicingCatalogPrices)(catalogListView.products),
|
|
23
27
|
savedInvoiceId: createInvoiceState.createdInvoiceId,
|
|
24
28
|
settings: (0, settingsViewSelector_1.getInvoicingSettings)(state),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { fetchInvoicingCatalogPlanList, fetchInvoicingCatalogProductList } from '../../invoicingCatalogListView/invoicingCatalogListViewReducer';
|
|
5
|
+
import { fetchInvoicingCustomerList } from '../../invoicingCustomerListView/invoicingCustomerListViewReducer';
|
|
6
|
+
import { fetchInvoicingSettings } from '../../settingsView/settingsViewReducer';
|
|
7
|
+
import { fetchCreateInvoiceFormPage } from '../createInvoiceReducer';
|
|
8
|
+
export type ActionType = ReturnType<typeof fetchCreateInvoiceFormPage> | ReturnType<typeof fetchInvoicingCustomerList> | ReturnType<typeof fetchInvoicingCatalogPlanList> | ReturnType<typeof fetchInvoicingCatalogProductList> | ReturnType<typeof fetchInvoicingSettings>;
|
|
9
|
+
/**
|
|
10
|
+
* Orchestrates the create-invoice form's option sources: on
|
|
11
|
+
* `fetchCreateInvoiceFormPage`, fans out to the customer, catalog plan, catalog
|
|
12
|
+
* product and settings fetches, skipping any already cached unless
|
|
13
|
+
* `cacheOverride` is set.
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchCreateInvoiceFormPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchCreateInvoiceFormPageEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const invoicingCatalogListViewReducer_1 = require("../../invoicingCatalogListView/invoicingCatalogListViewReducer");
|
|
7
|
+
const invoicingCustomerListViewReducer_1 = require("../../invoicingCustomerListView/invoicingCustomerListViewReducer");
|
|
8
|
+
const settingsViewReducer_1 = require("../../settingsView/settingsViewReducer");
|
|
9
|
+
const createInvoiceReducer_1 = require("../createInvoiceReducer");
|
|
10
|
+
/**
|
|
11
|
+
* Fetch unless the resource is already loaded or in flight — or always when the
|
|
12
|
+
* caller forces a refresh via `cacheOverride` (false on a plain page open, true
|
|
13
|
+
* to force a reload).
|
|
14
|
+
*/
|
|
15
|
+
const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
|
|
16
|
+
(fetchStateAndError.fetchState !== 'Completed' &&
|
|
17
|
+
fetchStateAndError.fetchState !== 'In-Progress');
|
|
18
|
+
/**
|
|
19
|
+
* Orchestrates the create-invoice form's option sources: on
|
|
20
|
+
* `fetchCreateInvoiceFormPage`, fans out to the customer, catalog plan, catalog
|
|
21
|
+
* product and settings fetches, skipping any already cached unless
|
|
22
|
+
* `cacheOverride` is set.
|
|
23
|
+
*/
|
|
24
|
+
const fetchCreateInvoiceFormPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(createInvoiceReducer_1.fetchCreateInvoiceFormPage.match), (0, operators_1.mergeMap)((action) => {
|
|
25
|
+
const { cacheOverride } = action.payload;
|
|
26
|
+
const state = state$.value;
|
|
27
|
+
const customerState = state.invoicingCustomerListViewState;
|
|
28
|
+
const catalogState = state.invoicingCatalogListViewState;
|
|
29
|
+
const settingsState = state.invoicingSettingsViewState;
|
|
30
|
+
const pageActions = [];
|
|
31
|
+
if (shouldFetch({ fetchState: customerState.fetchState, error: customerState.error }, cacheOverride)) {
|
|
32
|
+
pageActions.push((0, invoicingCustomerListViewReducer_1.fetchInvoicingCustomerList)({
|
|
33
|
+
filters: {},
|
|
34
|
+
keepExistingListItems: false,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
if (shouldFetch({ fetchState: catalogState.fetchState, error: catalogState.error }, cacheOverride)) {
|
|
38
|
+
pageActions.push((0, invoicingCatalogListViewReducer_1.fetchInvoicingCatalogPlanList)({
|
|
39
|
+
filters: { type: 'plan' },
|
|
40
|
+
keepExistingListItems: false,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
if (shouldFetch(catalogState.productFetchState, cacheOverride)) {
|
|
44
|
+
pageActions.push((0, invoicingCatalogListViewReducer_1.fetchInvoicingCatalogProductList)({
|
|
45
|
+
filters: { type: 'addon|charge' },
|
|
46
|
+
keepExistingListItems: false,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
if (shouldFetch({ fetchState: settingsState.fetchState, error: settingsState.error }, cacheOverride)) {
|
|
50
|
+
pageActions.push((0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
51
|
+
}
|
|
52
|
+
return (0, rxjs_1.from)(pageActions);
|
|
53
|
+
}));
|
|
54
|
+
exports.fetchCreateInvoiceFormPageEpic = fetchCreateInvoiceFormPageEpic;
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewPayload.js
CHANGED
|
@@ -12,7 +12,6 @@ const localDataToSaveInvoicingCouponPayload = (localData, isCreate) => {
|
|
|
12
12
|
discount_type: localData.discountType,
|
|
13
13
|
duration_type: localData.durationType,
|
|
14
14
|
name: localData.name.trim(),
|
|
15
|
-
status: 'active',
|
|
16
15
|
};
|
|
17
16
|
if (isCreate) {
|
|
18
17
|
data.id = localData.couponId.trim();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { fetchJEScheduleApprovalRules, fetchJEScheduleApprovalRulesFailure, fetchJEScheduleApprovalRulesSuccess } from '../jeScheduleApprovalRulesReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof fetchJEScheduleApprovalRules> | ReturnType<typeof fetchJEScheduleApprovalRulesSuccess> | ReturnType<typeof fetchJEScheduleApprovalRulesFailure>;
|
|
7
|
+
export declare const fetchJEScheduleApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchJEScheduleApprovalRulesEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const jeScheduleApprovalRulesReducer_1 = require("../jeScheduleApprovalRulesReducer");
|
|
8
|
+
const fetchJEScheduleApprovalRulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRules.match), (0, operators_1.switchMap)((action) => {
|
|
9
|
+
const { cacheOverride } = action.payload;
|
|
10
|
+
const { jeScheduleApprovalRulesState } = state$.value;
|
|
11
|
+
const cachedSettings = jeScheduleApprovalRulesState.settings;
|
|
12
|
+
if (cacheOverride !== true &&
|
|
13
|
+
jeScheduleApprovalRulesState.hasValidState() === true &&
|
|
14
|
+
cachedSettings != null) {
|
|
15
|
+
return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesSuccess)(cachedSettings));
|
|
16
|
+
}
|
|
17
|
+
const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/je-schedules/approval-rules`;
|
|
18
|
+
return zeniAPI.getJSON(endpoint).pipe((0, operators_1.mergeMap)((response) => {
|
|
19
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
20
|
+
return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesSuccess)(response.data.settings));
|
|
21
|
+
}
|
|
22
|
+
return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesFailure)(response.status));
|
|
23
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch JE approval rules errored out' + JSON.stringify(error))))));
|
|
24
|
+
}));
|
|
25
|
+
exports.fetchJEScheduleApprovalRulesEpic = fetchJEScheduleApprovalRulesEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
4
|
+
import { saveJEScheduleApprovalRules, saveJEScheduleApprovalRulesConflict, saveJEScheduleApprovalRulesFailure, saveJEScheduleApprovalRulesSuccess } from '../jeScheduleApprovalRulesReducer';
|
|
5
|
+
export type ActionType = ReturnType<typeof saveJEScheduleApprovalRules> | ReturnType<typeof saveJEScheduleApprovalRulesSuccess> | ReturnType<typeof saveJEScheduleApprovalRulesConflict> | ReturnType<typeof saveJEScheduleApprovalRulesFailure>;
|
|
6
|
+
export declare const saveJEScheduleApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveJEScheduleApprovalRulesEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const jeScheduleApprovalRulesReducer_1 = require("../jeScheduleApprovalRulesReducer");
|
|
8
|
+
const HTTP_CONFLICT = 409;
|
|
9
|
+
const saveJEScheduleApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRules.match), (0, operators_1.mergeMap)((action) => {
|
|
10
|
+
const { body } = action.payload;
|
|
11
|
+
const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/je-schedules/approval-rules`;
|
|
12
|
+
return zeniAPI
|
|
13
|
+
.postAndGetJSON(endpoint, body)
|
|
14
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
15
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
16
|
+
return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesSuccess)(response.data.settings, response.data.reevaluation_triggered));
|
|
17
|
+
}
|
|
18
|
+
if (response.status.code === HTTP_CONFLICT) {
|
|
19
|
+
return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesConflict)(response.status));
|
|
20
|
+
}
|
|
21
|
+
return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesFailure)(response.status));
|
|
22
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save JE approval rules errored out' + JSON.stringify(error))))));
|
|
23
|
+
}));
|
|
24
|
+
exports.saveJEScheduleApprovalRulesEpic = saveJEScheduleApprovalRulesEpic;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
2
|
+
export type JEScheduleType = 'prepaid_expenses' | 'fixed_assets' | 'accrued_expenses';
|
|
3
|
+
export interface JEApprovalThresholdRow {
|
|
4
|
+
account_id: string;
|
|
5
|
+
account_name: string;
|
|
6
|
+
max_auto_post_amount: number | null;
|
|
7
|
+
schedule_type: JEScheduleType;
|
|
8
|
+
}
|
|
9
|
+
export interface JEApprovalSettings {
|
|
10
|
+
approver_roles: string[];
|
|
11
|
+
reevaluate_ongoing_on_threshold_change: boolean;
|
|
12
|
+
thresholds: JEApprovalThresholdRow[];
|
|
13
|
+
version: number;
|
|
14
|
+
}
|
|
15
|
+
export interface JEScheduleApprovalRulesResponseData {
|
|
16
|
+
exists: boolean;
|
|
17
|
+
settings: JEApprovalSettings;
|
|
18
|
+
}
|
|
19
|
+
export type JEScheduleApprovalRulesResponse = ZeniAPIResponse<JEScheduleApprovalRulesResponseData>;
|
|
20
|
+
export interface SaveJEScheduleApprovalRulesResponseData extends JEScheduleApprovalRulesResponseData {
|
|
21
|
+
reevaluation_triggered: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type SaveJEScheduleApprovalRulesResponse = ZeniAPIResponse<SaveJEScheduleApprovalRulesResponseData>;
|
|
24
|
+
export interface SaveJEScheduleApprovalRulesRequestBody extends Record<string, unknown> {
|
|
25
|
+
approver_roles: string[];
|
|
26
|
+
reevaluate_ongoing_on_threshold_change: boolean;
|
|
27
|
+
thresholds: JEApprovalThresholdRow[];
|
|
28
|
+
expected_version?: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
2
|
+
import { JEApprovalSettings, SaveJEScheduleApprovalRulesRequestBody } from './jeScheduleApprovalRulesPayload';
|
|
3
|
+
import { JEScheduleApprovalRulesState } from './jeScheduleApprovalRulesState';
|
|
4
|
+
export declare const initialState: JEScheduleApprovalRulesState;
|
|
5
|
+
export declare const fetchJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
|
|
6
|
+
cacheOverride: any;
|
|
7
|
+
}, "jeScheduleApprovalRules/fetchJEScheduleApprovalRules", never, never>, fetchJEScheduleApprovalRulesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[settings: JEApprovalSettings], {
|
|
8
|
+
settings: JEApprovalSettings;
|
|
9
|
+
}, "jeScheduleApprovalRules/fetchJEScheduleApprovalRulesSuccess", never, never>, fetchJEScheduleApprovalRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "jeScheduleApprovalRules/fetchJEScheduleApprovalRulesFailure">, saveJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[body: SaveJEScheduleApprovalRulesRequestBody], {
|
|
10
|
+
body: SaveJEScheduleApprovalRulesRequestBody;
|
|
11
|
+
}, "jeScheduleApprovalRules/saveJEScheduleApprovalRules", never, never>, saveJEScheduleApprovalRulesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[settings: JEApprovalSettings, reevaluationTriggered: boolean], {
|
|
12
|
+
settings: JEApprovalSettings;
|
|
13
|
+
reevaluationTriggered: boolean;
|
|
14
|
+
}, "jeScheduleApprovalRules/saveJEScheduleApprovalRulesSuccess", never, never>, saveJEScheduleApprovalRulesConflict: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "jeScheduleApprovalRules/saveJEScheduleApprovalRulesConflict">, saveJEScheduleApprovalRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "jeScheduleApprovalRules/saveJEScheduleApprovalRulesFailure">, clearJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"jeScheduleApprovalRules/clearJEScheduleApprovalRules">;
|
|
15
|
+
declare const _default: import("redux").Reducer<JEScheduleApprovalRulesState>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearJEScheduleApprovalRules = exports.saveJEScheduleApprovalRulesFailure = exports.saveJEScheduleApprovalRulesConflict = exports.saveJEScheduleApprovalRulesSuccess = exports.saveJEScheduleApprovalRules = exports.fetchJEScheduleApprovalRulesFailure = exports.fetchJEScheduleApprovalRulesSuccess = exports.fetchJEScheduleApprovalRules = exports.initialState = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
exports.initialState = {
|
|
7
|
+
fetchState: 'Not-Started',
|
|
8
|
+
error: undefined,
|
|
9
|
+
saveStatus: { fetchState: 'Not-Started', error: undefined },
|
|
10
|
+
settings: undefined,
|
|
11
|
+
hadVersionConflict: false,
|
|
12
|
+
reevaluationTriggered: false,
|
|
13
|
+
hasValidState() {
|
|
14
|
+
return this.fetchState === 'Completed';
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const jeScheduleApprovalRules = (0, toolkit_1.createSlice)({
|
|
18
|
+
name: 'jeScheduleApprovalRules',
|
|
19
|
+
initialState: exports.initialState,
|
|
20
|
+
reducers: {
|
|
21
|
+
fetchJEScheduleApprovalRules: {
|
|
22
|
+
reducer(draft) {
|
|
23
|
+
draft.fetchState = 'In-Progress';
|
|
24
|
+
draft.error = undefined;
|
|
25
|
+
},
|
|
26
|
+
prepare(cacheOverride = false) {
|
|
27
|
+
return { payload: { cacheOverride } };
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
fetchJEScheduleApprovalRulesSuccess: {
|
|
31
|
+
reducer(draft, action) {
|
|
32
|
+
draft.fetchState = 'Completed';
|
|
33
|
+
draft.error = undefined;
|
|
34
|
+
draft.settings = action.payload.settings;
|
|
35
|
+
},
|
|
36
|
+
prepare(settings) {
|
|
37
|
+
return { payload: { settings } };
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
fetchJEScheduleApprovalRulesFailure(draft, action) {
|
|
41
|
+
draft.fetchState = 'Error';
|
|
42
|
+
draft.error = action.payload;
|
|
43
|
+
},
|
|
44
|
+
saveJEScheduleApprovalRules: {
|
|
45
|
+
reducer(draft) {
|
|
46
|
+
draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
|
|
47
|
+
draft.hadVersionConflict = false;
|
|
48
|
+
draft.reevaluationTriggered = false;
|
|
49
|
+
},
|
|
50
|
+
prepare(body) {
|
|
51
|
+
return { payload: { body } };
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
saveJEScheduleApprovalRulesSuccess: {
|
|
55
|
+
reducer(draft, action) {
|
|
56
|
+
draft.saveStatus = { fetchState: 'Completed', error: undefined };
|
|
57
|
+
draft.settings = action.payload.settings;
|
|
58
|
+
draft.reevaluationTriggered = action.payload.reevaluationTriggered;
|
|
59
|
+
draft.hadVersionConflict = false;
|
|
60
|
+
},
|
|
61
|
+
prepare(settings, reevaluationTriggered) {
|
|
62
|
+
return { payload: { settings, reevaluationTriggered } };
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
// 409 — the stored version moved under us. The screen should re-fetch and
|
|
66
|
+
// ask the user to re-apply. Kept distinct from a generic save failure.
|
|
67
|
+
saveJEScheduleApprovalRulesConflict(draft, action) {
|
|
68
|
+
draft.saveStatus = { fetchState: 'Error', error: action.payload };
|
|
69
|
+
draft.hadVersionConflict = true;
|
|
70
|
+
},
|
|
71
|
+
saveJEScheduleApprovalRulesFailure(draft, action) {
|
|
72
|
+
draft.saveStatus = { fetchState: 'Error', error: action.payload };
|
|
73
|
+
},
|
|
74
|
+
clearJEScheduleApprovalRules() {
|
|
75
|
+
return exports.initialState;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
_a = jeScheduleApprovalRules.actions, exports.fetchJEScheduleApprovalRules = _a.fetchJEScheduleApprovalRules, exports.fetchJEScheduleApprovalRulesSuccess = _a.fetchJEScheduleApprovalRulesSuccess, exports.fetchJEScheduleApprovalRulesFailure = _a.fetchJEScheduleApprovalRulesFailure, exports.saveJEScheduleApprovalRules = _a.saveJEScheduleApprovalRules, exports.saveJEScheduleApprovalRulesSuccess = _a.saveJEScheduleApprovalRulesSuccess, exports.saveJEScheduleApprovalRulesConflict = _a.saveJEScheduleApprovalRulesConflict, exports.saveJEScheduleApprovalRulesFailure = _a.saveJEScheduleApprovalRulesFailure, exports.clearJEScheduleApprovalRules = _a.clearJEScheduleApprovalRules;
|
|
80
|
+
exports.default = jeScheduleApprovalRules.reducer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
|
+
import { RootState } from '../../../reducer';
|
|
3
|
+
import { JEApprovalSettings } from './jeScheduleApprovalRulesPayload';
|
|
4
|
+
export interface JEScheduleApprovalRulesView {
|
|
5
|
+
error: FetchStateAndError['error'];
|
|
6
|
+
fetchState: FetchState;
|
|
7
|
+
hadVersionConflict: boolean;
|
|
8
|
+
reevaluationTriggered: boolean;
|
|
9
|
+
saveStatus: FetchStateAndError;
|
|
10
|
+
settings?: JEApprovalSettings;
|
|
11
|
+
}
|
|
12
|
+
export declare const getJEScheduleApprovalRulesView: (state: RootState) => JEScheduleApprovalRulesView;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getJEScheduleApprovalRulesView = void 0;
|
|
4
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
exports.getJEScheduleApprovalRulesView = (0, toolkit_1.createSelector)((state) => state.jeScheduleApprovalRulesState, (jeScheduleApprovalRulesState) => ({
|
|
6
|
+
fetchState: jeScheduleApprovalRulesState.fetchState,
|
|
7
|
+
error: jeScheduleApprovalRulesState.error,
|
|
8
|
+
saveStatus: jeScheduleApprovalRulesState.saveStatus,
|
|
9
|
+
settings: jeScheduleApprovalRulesState.settings,
|
|
10
|
+
hadVersionConflict: jeScheduleApprovalRulesState.hadVersionConflict ?? false,
|
|
11
|
+
reevaluationTriggered: jeScheduleApprovalRulesState.reevaluationTriggered ?? false,
|
|
12
|
+
}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FetchStateAndError, FetchedState } from '../../../commonStateTypes/common';
|
|
2
|
+
import { JEApprovalSettings } from './jeScheduleApprovalRulesPayload';
|
|
3
|
+
export interface JEScheduleApprovalRulesState extends FetchedState {
|
|
4
|
+
saveStatus: FetchStateAndError;
|
|
5
|
+
hadVersionConflict?: boolean;
|
|
6
|
+
reevaluationTriggered?: boolean;
|
|
7
|
+
settings?: JEApprovalSettings;
|
|
8
|
+
}
|
|
@@ -316,7 +316,7 @@ const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInUser) =>
|
|
|
316
316
|
(actorActivity.subType === 'manager' ||
|
|
317
317
|
actorActivity.subType === 'vendor_owner') &&
|
|
318
318
|
actorActivity.userId === null &&
|
|
319
|
-
isAdminFallbackApprover &&
|
|
319
|
+
isAdminFallbackApprover === true &&
|
|
320
320
|
isUserAdmin &&
|
|
321
321
|
signedInUser?.userId != null &&
|
|
322
322
|
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
@@ -330,7 +330,7 @@ const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInUser) =>
|
|
|
330
330
|
isUserAdmin &&
|
|
331
331
|
signedInUser?.userId != null &&
|
|
332
332
|
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
333
|
-
pendingStep.displayPendingApproverAsAdmin) {
|
|
333
|
+
pendingStep.displayPendingApproverAsAdmin === true) {
|
|
334
334
|
isApprovalorRejectBtnVisible = true;
|
|
335
335
|
isMarkAsPaidBtnVisible = isLastApprovalStep;
|
|
336
336
|
}
|
|
@@ -365,7 +365,7 @@ const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInUser) =>
|
|
|
365
365
|
(actorActivity.subType === 'manager' ||
|
|
366
366
|
actorActivity.subType === 'vendor_owner') &&
|
|
367
367
|
actorActivity.userId === null &&
|
|
368
|
-
isAdminFallbackApprover &&
|
|
368
|
+
isAdminFallbackApprover === true &&
|
|
369
369
|
isUserAdmin &&
|
|
370
370
|
signedInUser?.userId != null &&
|
|
371
371
|
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
@@ -379,7 +379,7 @@ const checkApproveRejectBtnShow = (billActivities, isUserAdmin, signedInUser) =>
|
|
|
379
379
|
isUserAdmin &&
|
|
380
380
|
signedInUser?.userId != null &&
|
|
381
381
|
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
382
|
-
stepWithStatus.displayPendingApproverAsAdmin) {
|
|
382
|
+
stepWithStatus.displayPendingApproverAsAdmin === true) {
|
|
383
383
|
isApprovalorRejectBtnVisible = true;
|
|
384
384
|
isMarkAsPaidBtnVisible = true;
|
|
385
385
|
}
|
|
@@ -326,7 +326,7 @@ const getApproversOrRejectors = (billTransaction, entityApprovalStatusState, use
|
|
|
326
326
|
requireApprovalInfo = [stepsApprovalStatus[currentPendingStepIndex]];
|
|
327
327
|
}
|
|
328
328
|
requireApprovalInfo.forEach((approvalStep) => {
|
|
329
|
-
if (approvers.displayPendingApproverAsAdmin) {
|
|
329
|
+
if (approvers.displayPendingApproverAsAdmin === true) {
|
|
330
330
|
return;
|
|
331
331
|
}
|
|
332
332
|
const pendingActivities = approvalStep.actorsActivity.filter((activity) => activity.activity === 'pending');
|
|
@@ -25,7 +25,7 @@ const isSodExcludedViewerBlocked = (sodExcludedApproverUserId, signedInUserId, s
|
|
|
25
25
|
(0, exports.isUserActorOnApprovalStep)(sodExcludedApproverUserId, stepActorsActivity);
|
|
26
26
|
exports.isSodExcludedViewerBlocked = isSodExcludedViewerBlocked;
|
|
27
27
|
const isSodAdminFallbackEligibleForStep = (sodExcludedApproverUserId, isAdminFallbackApprover, stepActorsActivity = []) => {
|
|
28
|
-
if (sodExcludedApproverUserId == null ||
|
|
28
|
+
if (sodExcludedApproverUserId == null || isAdminFallbackApprover !== true) {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
const pendingResolvedApprovers = stepActorsActivity.filter((activity) => activity.activity === 'pending' && getUserActorId(activity) != null);
|
|
@@ -247,7 +247,7 @@ const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInUser) =>
|
|
|
247
247
|
actorActivity.subType === 'vendor_owner' ||
|
|
248
248
|
actorActivity.subType === 'manager_of_manager') &&
|
|
249
249
|
actorActivity.userId === null &&
|
|
250
|
-
isAdminFallbackApprover &&
|
|
250
|
+
isAdminFallbackApprover === true &&
|
|
251
251
|
isUserAdmin &&
|
|
252
252
|
signedInUser?.userId != null &&
|
|
253
253
|
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
@@ -258,7 +258,7 @@ const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInUser) =>
|
|
|
258
258
|
isUserAdmin &&
|
|
259
259
|
signedInUser?.userId != null &&
|
|
260
260
|
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
261
|
-
pendingStep.displayPendingApproverAsAdmin) {
|
|
261
|
+
pendingStep.displayPendingApproverAsAdmin === true) {
|
|
262
262
|
isApprovalorRejectBtnVisible = true;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
@@ -293,7 +293,7 @@ const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInUser) =>
|
|
|
293
293
|
actorActivity.subType === 'vendor_owner' ||
|
|
294
294
|
actorActivity.subType === 'manager_of_manager') &&
|
|
295
295
|
actorActivity.userId === null &&
|
|
296
|
-
isAdminFallbackApprover &&
|
|
296
|
+
isAdminFallbackApprover === true &&
|
|
297
297
|
isUserAdmin &&
|
|
298
298
|
signedInUser?.userId != null &&
|
|
299
299
|
signedInUser.userId !== sodExcludedApproverUserId) {
|
|
@@ -304,7 +304,7 @@ const checkApproveRejectBtnShow = (remiActivities, isUserAdmin, signedInUser) =>
|
|
|
304
304
|
isUserAdmin &&
|
|
305
305
|
signedInUser?.userId != null &&
|
|
306
306
|
signedInUser.userId !== sodExcludedApproverUserId &&
|
|
307
|
-
stepWithStatus.displayPendingApproverAsAdmin) {
|
|
307
|
+
stepWithStatus.displayPendingApproverAsAdmin === true) {
|
|
308
308
|
isApprovalorRejectBtnVisible = true;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
@@ -245,7 +245,7 @@ const getApproversOrRejectors = (reimbursement, entityApprovalStatusState, userS
|
|
|
245
245
|
requireApprovalInfo = [stepsApprovalStatus[currentPendingStepIndex]];
|
|
246
246
|
}
|
|
247
247
|
requireApprovalInfo.forEach((approvalStep) => {
|
|
248
|
-
if (approvers.displayPendingApproverAsAdmin) {
|
|
248
|
+
if (approvers.displayPendingApproverAsAdmin === true) {
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
251
|
const pendingActivities = approvalStep.actorsActivity.filter((activity) => activity.activity === 'pending');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.68-beta0GS",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|