@zeniai/client-epic-state 5.0.90-beta0ND → 5.0.90-betaAR2
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/commonStateTypes/animations.d.ts +1 -1
- package/lib/commonStateTypes/animations.js +0 -1
- package/lib/entity/approvalRule/approvalRuleConflict.d.ts +56 -0
- package/lib/entity/approvalRule/approvalRuleConflict.js +77 -0
- package/lib/entity/approvalRule/approvalRulePayload.d.ts +34 -5
- package/lib/entity/approvalRule/approvalRulePayload.js +145 -10
- package/lib/entity/approvalRule/approvalRuleSelector.d.ts +25 -1
- package/lib/entity/approvalRule/approvalRuleSelector.js +40 -0
- package/lib/entity/approvalRule/approvalRuleState.d.ts +59 -7
- package/lib/entity/company/companyPayload.d.ts +0 -4
- package/lib/entity/company/companyPayload.js +0 -4
- package/lib/entity/company/companyStateTypes.d.ts +0 -4
- package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +0 -1
- package/lib/entity/paymentAccount/paymentAccountSelector.js +0 -4
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/tenantPayload.d.ts +0 -1
- package/lib/entity/tenant/tenantReducer.d.ts +25 -38
- package/lib/entity/tenant/tenantReducer.js +5 -65
- package/lib/entity/tenant/tenantState.d.ts +0 -1
- package/lib/epic.d.ts +5 -8
- package/lib/epic.js +5 -9
- package/lib/esm/commonStateTypes/animations.js +0 -1
- package/lib/esm/entity/approvalRule/approvalRuleConflict.js +74 -0
- package/lib/esm/entity/approvalRule/approvalRulePayload.js +145 -10
- package/lib/esm/entity/approvalRule/approvalRuleSelector.js +35 -0
- package/lib/esm/entity/company/companyPayload.js +0 -4
- package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +0 -3
- package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/esm/entity/tenant/tenantReducer.js +3 -63
- package/lib/esm/epic.js +5 -9
- package/lib/esm/index.js +13 -14
- package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
- package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
- package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +50 -217
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +1 -7
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +0 -12
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +92 -12
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +10 -2
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +8 -4
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +11 -7
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +54 -0
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +13 -4
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +122 -16
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
- package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +52 -105
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +1 -6
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +10 -2
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +8 -2
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +11 -7
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +49 -0
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +13 -4
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +71 -11
- package/lib/index.d.ts +15 -17
- package/lib/index.js +42 -51
- package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
- package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
- package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +0 -3
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +4 -41
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +51 -219
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +1 -5
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +2 -11
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +0 -40
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +1 -13
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +14 -3
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +93 -13
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +16 -0
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +10 -2
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +8 -4
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +10 -6
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.d.ts +23 -0
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +58 -0
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +12 -3
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +50 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +124 -17
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +31 -5
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +2 -28
- package/lib/view/spendManagement/commonSetup/setupViewReducer.js +53 -106
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +2 -7
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +1 -6
- package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +0 -19
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +10 -2
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +8 -2
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +10 -6
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.d.ts +14 -0
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +53 -0
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +12 -3
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +14 -3
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +72 -12
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +12 -0
- package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
- package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
- package/package.json +1 -1
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +0 -21
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -54
- package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +0 -50
- package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -42
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +0 -29
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -40
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -52
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -59
- package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -14
- package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -205
- package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -28
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +0 -7
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +0 -46
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +0 -8
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +0 -33
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +0 -9
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +0 -44
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +0 -28
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +0 -56
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +0 -30
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +0 -63
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +0 -33
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +0 -17
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +0 -24
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +0 -213
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +0 -125
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +0 -32
|
@@ -5,15 +5,24 @@ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
|
5
5
|
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { saveBillPaySetupApproverViewUpdates, saveBillPaySetupApproverViewUpdatesFailure, saveBillPaySetupApproverViewUpdatesSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
|
-
import { toApprovalChangableInfoPayload } from '../types/commonPayload';
|
|
9
|
-
export const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveBillPaySetupApproverViewUpdates.match), switchMap(() => {
|
|
8
|
+
import { toApprovalChangableInfoPayload, toApprovalChangableInfoPayloadV1, } from '../types/commonPayload';
|
|
9
|
+
export const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveBillPaySetupApproverViewUpdates.match), switchMap((action) => {
|
|
10
10
|
const { billPaySetupApproverViewState } = state$.value;
|
|
11
11
|
const billPaySetupApproverViewUpdateData = billPaySetupApproverViewState.billPaySetupApproverViewUpdateData;
|
|
12
12
|
if (billPaySetupApproverViewUpdateData != null &&
|
|
13
13
|
billPaySetupApproverViewUpdateData.data != null) {
|
|
14
|
-
|
|
14
|
+
// Approval Rules 3.0 — gate URL + write-side payload mapper on
|
|
15
|
+
// the `approval_rule_v3_config` dynamic config. `useV3` arrives
|
|
16
|
+
// on the action payload from the screen connector.
|
|
17
|
+
const { useV3 } = action.payload;
|
|
18
|
+
const payload = useV3
|
|
19
|
+
? toApprovalChangableInfoPayload(billPaySetupApproverViewUpdateData.data)
|
|
20
|
+
: toApprovalChangableInfoPayloadV1(billPaySetupApproverViewUpdateData.data);
|
|
21
|
+
const endpoint = useV3
|
|
22
|
+
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
23
|
+
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
15
24
|
return zeniAPI
|
|
16
|
-
.postAndGetJSON(
|
|
25
|
+
.postAndGetJSON(endpoint, payload)
|
|
17
26
|
.pipe(mergeMap((response) => {
|
|
18
27
|
if (isSuccessResponse(response) && response.data != null) {
|
|
19
28
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
export const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
|
|
2
|
-
|
|
2
|
+
// Form-side criteria is a structured object with optional slots for
|
|
3
|
+
// amount / vendor / department; flatten it into the wire format's
|
|
4
|
+
// `conditions[]` array.
|
|
5
|
+
let criteriaPayload;
|
|
3
6
|
if (approverViewUpdateData.criteria != null) {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const { amount, vendor, department } = approverViewUpdateData.criteria;
|
|
8
|
+
const conditions = [];
|
|
9
|
+
if (amount?.min != null) {
|
|
10
|
+
conditions.push({
|
|
11
|
+
field: 'amount',
|
|
12
|
+
type: 'gte',
|
|
13
|
+
value: amount.min.amount,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (amount?.max != null) {
|
|
17
|
+
conditions.push({
|
|
18
|
+
field: 'amount',
|
|
19
|
+
type: 'lte',
|
|
20
|
+
value: amount.max.amount,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (vendor != null && vendor.vendorIds.length > 0) {
|
|
24
|
+
conditions.push({
|
|
25
|
+
field: 'vendor_id',
|
|
26
|
+
type: vendor.operator === 'is_not' ? 'not_in' : 'in',
|
|
27
|
+
value: vendor.vendorIds,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (department != null && department.departmentIds.length > 0) {
|
|
31
|
+
conditions.push({
|
|
32
|
+
field: 'department_id',
|
|
33
|
+
type: department.operator === 'is_not' ? 'not_in' : 'in',
|
|
34
|
+
value: department.departmentIds,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (conditions.length > 0) {
|
|
38
|
+
const currency = amount?.min ?? amount?.max ?? null;
|
|
39
|
+
criteriaPayload = {
|
|
40
|
+
conditions,
|
|
41
|
+
criteria_operator: 'and',
|
|
42
|
+
currency_code: currency?.currencyCode ?? 'USD',
|
|
43
|
+
currency_symbol: currency?.currencySymbol ?? '$',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
18
46
|
}
|
|
19
47
|
const steps = approverViewUpdateData.steps.map((step) => {
|
|
20
48
|
return {
|
|
@@ -35,10 +63,88 @@ export const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
|
|
|
35
63
|
});
|
|
36
64
|
const isUpdate = approverViewUpdateData.approvalRuleId != null;
|
|
37
65
|
const payload = {
|
|
38
|
-
criteria: criteriaPayload,
|
|
39
66
|
steps,
|
|
40
67
|
is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
|
|
41
68
|
};
|
|
69
|
+
if (criteriaPayload != null) {
|
|
70
|
+
payload.criteria = criteriaPayload;
|
|
71
|
+
}
|
|
72
|
+
// Approval Rules 3.0 — surface rule-level fields when the form set them.
|
|
73
|
+
// Send only what the user actually entered: an undefined value means
|
|
74
|
+
// "no opinion" and stays off the wire.
|
|
75
|
+
if (approverViewUpdateData.name != null) {
|
|
76
|
+
payload.name = approverViewUpdateData.name;
|
|
77
|
+
}
|
|
78
|
+
if (approverViewUpdateData.description != null) {
|
|
79
|
+
payload.description = approverViewUpdateData.description;
|
|
80
|
+
}
|
|
81
|
+
if (approverViewUpdateData.separationOfDuties != null) {
|
|
82
|
+
payload.is_separation_of_duty_enabled =
|
|
83
|
+
approverViewUpdateData.separationOfDuties;
|
|
84
|
+
}
|
|
85
|
+
if (approverViewUpdateData.isFallback != null) {
|
|
86
|
+
payload.is_fallback = approverViewUpdateData.isFallback;
|
|
87
|
+
}
|
|
88
|
+
if (isUpdate) {
|
|
89
|
+
payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
|
|
90
|
+
}
|
|
91
|
+
return payload;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
|
|
95
|
+
* for the current tenant. Translates the form-side amount criteria into
|
|
96
|
+
* the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
|
|
97
|
+
* V1 backend does not understand vendor / department criteria or the
|
|
98
|
+
* rule-level 3.0 fields, so those are dropped on the wire.
|
|
99
|
+
*
|
|
100
|
+
* The form-side amount slot is always read as a `range`-style criteria
|
|
101
|
+
* here: V1 schemas only supported ranges, so an absent `min` or `max`
|
|
102
|
+
* falls back to `0` / `Number.MAX_SAFE_INTEGER`.
|
|
103
|
+
*/
|
|
104
|
+
export const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
|
|
105
|
+
const amount = approverViewUpdateData.criteria?.amount;
|
|
106
|
+
const minAmount = amount?.min;
|
|
107
|
+
const maxAmount = amount?.max;
|
|
108
|
+
const currencyCode = minAmount?.currencyCode ?? maxAmount?.currencyCode ?? 'USD';
|
|
109
|
+
const currencySymbol = minAmount?.currencySymbol ?? maxAmount?.currencySymbol ?? '$';
|
|
110
|
+
const steps = approverViewUpdateData.steps.map((step) => {
|
|
111
|
+
return {
|
|
112
|
+
action: step.action,
|
|
113
|
+
operator: step.operator,
|
|
114
|
+
actors: step.actors
|
|
115
|
+
.filter((actor) => actor.subType !== 'admin')
|
|
116
|
+
.map((actor) => {
|
|
117
|
+
return {
|
|
118
|
+
type: actor.type,
|
|
119
|
+
id: actor.userId ?? null,
|
|
120
|
+
sub_type: actor.subType ?? null,
|
|
121
|
+
id_type: actor.idType ?? null,
|
|
122
|
+
is_implicit_actor: actor.isImplicitActor ?? false,
|
|
123
|
+
};
|
|
124
|
+
}),
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
const isUpdate = approverViewUpdateData.approvalRuleId != null;
|
|
128
|
+
const payload = {
|
|
129
|
+
steps,
|
|
130
|
+
is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
|
|
131
|
+
criteria: {
|
|
132
|
+
rangeType: 'range',
|
|
133
|
+
rangeEntity: 'currency',
|
|
134
|
+
range: {
|
|
135
|
+
min: {
|
|
136
|
+
amount: minAmount?.amount ?? 0,
|
|
137
|
+
currencyCode,
|
|
138
|
+
currencySymbol,
|
|
139
|
+
},
|
|
140
|
+
max: {
|
|
141
|
+
amount: maxAmount?.amount ?? Number.MAX_SAFE_INTEGER,
|
|
142
|
+
currencyCode,
|
|
143
|
+
currencySymbol,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
42
148
|
if (isUpdate) {
|
|
43
149
|
payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
|
|
44
150
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import recordGet from 'lodash/get';
|
|
2
2
|
import has from 'lodash/has';
|
|
3
|
+
import { getAmountCriteria } from '../../../../entity/approvalRule/approvalRuleSelector';
|
|
3
4
|
import { reduceFetchState } from '../../../../commonStateTypes/reduceFetchState';
|
|
4
5
|
import { getBankAccountByBankAccountId, getBankAccountsByBankAccountIds, } from '../../../../entity/bankAccount/bankAccountSelector';
|
|
5
6
|
import { getContactById, getContactsByIds, } from '../../../../entity/billPay/contact/contactSelector';
|
|
@@ -681,9 +682,13 @@ export const getDefaultWithdrawFromAccount = (state, depositAccounts, companyId,
|
|
|
681
682
|
export const checkIfCreatorIsApprover = (billAmount, approvalRules, signedInUser) => {
|
|
682
683
|
let isCreatorAlsoApprover = false;
|
|
683
684
|
const approvalRule = approvalRules.find((rule) => {
|
|
684
|
-
const
|
|
685
|
+
const amountCriteria = getAmountCriteria(rule.criteria);
|
|
686
|
+
if (amountCriteria?.min == null) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
const { min, max } = amountCriteria;
|
|
685
690
|
return (billAmount > min.amount &&
|
|
686
|
-
(max?.amount != null ? billAmount <= max
|
|
691
|
+
(max?.amount != null ? billAmount <= max.amount : true));
|
|
687
692
|
});
|
|
688
693
|
if (approvalRule != null) {
|
|
689
694
|
const requireApprovalSteps = approvalRule.steps.filter((step) => step.action === 'require_approval');
|
|
@@ -1,30 +1,62 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from './kycKybAutofillActions';
|
|
3
2
|
const initialFetchStatus = {
|
|
4
3
|
fetchState: 'Not-Started',
|
|
5
4
|
error: undefined,
|
|
6
5
|
};
|
|
7
|
-
const emptyOfficerSlot = {
|
|
8
|
-
autoFilledFields: [],
|
|
9
|
-
localData: undefined,
|
|
10
|
-
sendOtpStatus: initialFetchStatus,
|
|
11
|
-
otpverificationStatus: initialFetchStatus,
|
|
12
|
-
};
|
|
13
6
|
export const initialState = {
|
|
14
7
|
updateStatus: { fetchState: 'Not-Started', error: undefined },
|
|
15
|
-
|
|
16
|
-
companyDetails: { autoFilledFields: [] },
|
|
8
|
+
companyDetails: {},
|
|
17
9
|
companyOfficerUpdateStatus: {
|
|
18
|
-
Officer_1: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
Officer_1: {
|
|
11
|
+
localData: undefined,
|
|
12
|
+
sendOtpStatus: initialFetchStatus,
|
|
13
|
+
otpverificationStatus: initialFetchStatus,
|
|
14
|
+
},
|
|
15
|
+
Officer_2: {
|
|
16
|
+
localData: undefined,
|
|
17
|
+
sendOtpStatus: initialFetchStatus,
|
|
18
|
+
otpverificationStatus: initialFetchStatus,
|
|
19
|
+
},
|
|
20
|
+
Officer_3: {
|
|
21
|
+
localData: undefined,
|
|
22
|
+
sendOtpStatus: initialFetchStatus,
|
|
23
|
+
otpverificationStatus: initialFetchStatus,
|
|
24
|
+
},
|
|
25
|
+
Officer_4: {
|
|
26
|
+
localData: undefined,
|
|
27
|
+
sendOtpStatus: initialFetchStatus,
|
|
28
|
+
otpverificationStatus: initialFetchStatus,
|
|
29
|
+
},
|
|
30
|
+
Officer_5: {
|
|
31
|
+
localData: undefined,
|
|
32
|
+
sendOtpStatus: initialFetchStatus,
|
|
33
|
+
otpverificationStatus: initialFetchStatus,
|
|
34
|
+
},
|
|
35
|
+
Officer_6: {
|
|
36
|
+
localData: undefined,
|
|
37
|
+
sendOtpStatus: initialFetchStatus,
|
|
38
|
+
otpverificationStatus: initialFetchStatus,
|
|
39
|
+
},
|
|
40
|
+
Officer_7: {
|
|
41
|
+
localData: undefined,
|
|
42
|
+
sendOtpStatus: initialFetchStatus,
|
|
43
|
+
otpverificationStatus: initialFetchStatus,
|
|
44
|
+
},
|
|
45
|
+
Officer_8: {
|
|
46
|
+
localData: undefined,
|
|
47
|
+
sendOtpStatus: initialFetchStatus,
|
|
48
|
+
otpverificationStatus: initialFetchStatus,
|
|
49
|
+
},
|
|
50
|
+
Officer_9: {
|
|
51
|
+
localData: undefined,
|
|
52
|
+
sendOtpStatus: initialFetchStatus,
|
|
53
|
+
otpverificationStatus: initialFetchStatus,
|
|
54
|
+
},
|
|
55
|
+
Officer_10: {
|
|
56
|
+
localData: undefined,
|
|
57
|
+
sendOtpStatus: initialFetchStatus,
|
|
58
|
+
otpverificationStatus: initialFetchStatus,
|
|
59
|
+
},
|
|
28
60
|
},
|
|
29
61
|
primaryContactDetails: {},
|
|
30
62
|
};
|
|
@@ -265,92 +297,7 @@ const setupView = createSlice({
|
|
|
265
297
|
clearSetupView(draft) {
|
|
266
298
|
Object.assign(draft, initialState);
|
|
267
299
|
},
|
|
268
|
-
/**
|
|
269
|
-
* Merge AI-parsed officer fields into the selected officer's localData and
|
|
270
|
-
* track which field names were autofilled so the form can show the ✦ badge.
|
|
271
|
-
*/
|
|
272
|
-
applyKycDocumentAutofillForSetup: {
|
|
273
|
-
reducer(draft, action) {
|
|
274
|
-
const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
|
|
275
|
-
const slot = draft.companyOfficerUpdateStatus[officerType];
|
|
276
|
-
slot.localData = Object.assign({}, slot.localData, values);
|
|
277
|
-
slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
|
|
278
|
-
draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
|
|
279
|
-
},
|
|
280
|
-
prepare(payload) {
|
|
281
|
-
return { payload };
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
/**
|
|
285
|
-
* Merge AI-parsed company fields into companyDetails.localData and track
|
|
286
|
-
* which field names were autofilled.
|
|
287
|
-
*/
|
|
288
|
-
applyKybDocumentAutofillForSetup: {
|
|
289
|
-
reducer(draft, action) {
|
|
290
|
-
const { values, autoFilledFieldNames, fileId } = action.payload;
|
|
291
|
-
draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
|
|
292
|
-
draft.companyDetails.autoFilledFields = Array.from(new Set([
|
|
293
|
-
...draft.companyDetails.autoFilledFields,
|
|
294
|
-
...autoFilledFieldNames,
|
|
295
|
-
]));
|
|
296
|
-
draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
|
|
297
|
-
},
|
|
298
|
-
prepare(payload) {
|
|
299
|
-
return { payload };
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
/**
|
|
303
|
-
* Wipe AI-autofill badges. If `officerType` is provided, clears only that
|
|
304
|
-
* officer; otherwise clears company details too.
|
|
305
|
-
*/
|
|
306
|
-
clearKycKybAutofillForSetup: {
|
|
307
|
-
reducer(draft, action) {
|
|
308
|
-
const { officerType } = action.payload;
|
|
309
|
-
if (officerType != null) {
|
|
310
|
-
draft.companyOfficerUpdateStatus[officerType].autoFilledFields = [];
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
draft.companyDetails.autoFilledFields = [];
|
|
314
|
-
Object.keys(draft.companyOfficerUpdateStatus).forEach((key) => {
|
|
315
|
-
draft.companyOfficerUpdateStatus[key].autoFilledFields = [];
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
prepare(payload = {}) {
|
|
320
|
-
return { payload };
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
extraReducers: (builder) => {
|
|
325
|
-
const addParsingFileId = (draft, fileId) => {
|
|
326
|
-
if (!draft.parsingDocumentFileIds.includes(fileId)) {
|
|
327
|
-
draft.parsingDocumentFileIds.push(fileId);
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const removeParsingFileId = (draft, fileId) => {
|
|
331
|
-
draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
|
|
332
|
-
};
|
|
333
|
-
builder.addCase(parseUploadedKycDocument, (draft, action) => {
|
|
334
|
-
if (action.payload.target === 'setup') {
|
|
335
|
-
addParsingFileId(draft, action.payload.fileId);
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
builder.addCase(parseUploadedKybDocument, (draft, action) => {
|
|
339
|
-
if (action.payload.target === 'setup') {
|
|
340
|
-
addParsingFileId(draft, action.payload.fileId);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
builder.addCase(parseUploadedKycDocumentFailure, (draft, action) => {
|
|
344
|
-
if (action.payload.target === 'setup') {
|
|
345
|
-
removeParsingFileId(draft, action.payload.fileId);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
builder.addCase(parseUploadedKybDocumentFailure, (draft, action) => {
|
|
349
|
-
if (action.payload.target === 'setup') {
|
|
350
|
-
removeParsingFileId(draft, action.payload.fileId);
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
300
|
},
|
|
354
301
|
});
|
|
355
|
-
export const { enableSetup, enableSetupSuccess, enableSetupFailure, updateBusinessVerificationDetails, updateBusinessVerificationDetailsSuccess, updateBusinessVerificationDetailsFailure, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveTreasuryAdditionalDocumentsInLocalStore, sendOtp: sendOtpSpendManagementSetUp, resendOtp: resendOtpSpendManagementSetUp, sendOtpSuccess: sendOtpSuccessSpendManagementSetUp, sendOtpFailure: sendOtpFailureSpendManagementSetUp, verifyOtp: verifyOtpSpendManagementSetUp, verifyOtpSuccess: verifyOtpSuccessSpendManagementSetUp, verifyOtpFailure: verifyOtpFailureSpendManagementSetUp, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, clearSetupView,
|
|
302
|
+
export const { enableSetup, enableSetupSuccess, enableSetupFailure, updateBusinessVerificationDetails, updateBusinessVerificationDetailsSuccess, updateBusinessVerificationDetailsFailure, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveTreasuryAdditionalDocumentsInLocalStore, sendOtp: sendOtpSpendManagementSetUp, resendOtp: resendOtpSpendManagementSetUp, sendOtpSuccess: sendOtpSuccessSpendManagementSetUp, sendOtpFailure: sendOtpFailureSpendManagementSetUp, verifyOtp: verifyOtpSpendManagementSetUp, verifyOtpSuccess: verifyOtpSuccessSpendManagementSetUp, verifyOtpFailure: verifyOtpFailureSpendManagementSetUp, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, clearSetupView, } = setupView.actions;
|
|
356
303
|
export default setupView.reducer;
|
|
@@ -87,17 +87,15 @@ export function getBusinessVerificationDetails(state, companyId) {
|
|
|
87
87
|
const { setupViewState, countryListState } = state;
|
|
88
88
|
const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, updateStatus, } = setupViewState;
|
|
89
89
|
const companyView = getCompanyView(state, companyId, []);
|
|
90
|
-
const { companyDetailsLocalData, companyOfficerLocalData
|
|
90
|
+
const { companyDetailsLocalData, companyOfficerLocalData } = getCompanyAndIdentityDetails(state, companyId, {
|
|
91
91
|
companyDetails,
|
|
92
92
|
companyOfficerUpdateStatus,
|
|
93
93
|
primaryContactDetails,
|
|
94
|
-
parsingDocumentFileIds: setupViewState.parsingDocumentFileIds,
|
|
95
94
|
});
|
|
96
95
|
const allNationalityCountries = countryListState.byCountryListCode.nationalityCountryList.countries;
|
|
97
96
|
return {
|
|
98
97
|
companyDetailsLocalData,
|
|
99
98
|
companyOfficerLocalData,
|
|
100
|
-
parsingDocumentFileIds,
|
|
101
99
|
companyView,
|
|
102
100
|
updateStatus,
|
|
103
101
|
allNationalityCountries,
|
|
@@ -121,7 +119,6 @@ export const getCompanyAndIdentityDetails = (state, companyId, companyAndIdentit
|
|
|
121
119
|
const companyAddress = addressViewState.newAddressState?.company_address;
|
|
122
120
|
const registeredCompanyAddress = addressViewState.newAddressState?.company_registered_address;
|
|
123
121
|
companyDetailsLocalData = {
|
|
124
|
-
autoFilledFields: companyDetails.autoFilledFields,
|
|
125
122
|
companyId,
|
|
126
123
|
companyDescription,
|
|
127
124
|
companyLegalName,
|
|
@@ -194,7 +191,6 @@ export const getCompanyAndIdentityDetails = (state, companyId, companyAndIdentit
|
|
|
194
191
|
const companyOfficerAddress = addressViewState.newAddressState?.[addressType];
|
|
195
192
|
companyOfficerLocalData[officerType] = {
|
|
196
193
|
...companyOfficer.localData,
|
|
197
|
-
autoFilledFields: companyOfficer.autoFilledFields,
|
|
198
194
|
userFiles: getFilesByFileIds(fileState, fileIds),
|
|
199
195
|
additionalFiles: getFilesByFileIds(fileState, additionalSubmittedDocumentsForVerificationFileIds),
|
|
200
196
|
deleteFileStatusById,
|
|
@@ -208,7 +204,6 @@ export const getCompanyAndIdentityDetails = (state, companyId, companyAndIdentit
|
|
|
208
204
|
return {
|
|
209
205
|
companyDetailsLocalData,
|
|
210
206
|
companyOfficerLocalData,
|
|
211
|
-
parsingDocumentFileIds: companyAndIdentityDetails.parsingDocumentFileIds,
|
|
212
207
|
};
|
|
213
208
|
};
|
|
214
209
|
/* This helper function takes deposit accounts and payment accounts
|
|
@@ -6,9 +6,17 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { deleteRemiApprovalRule, deleteRemiApprovalRuleFailure, deleteRemiApprovalRuleSuccess, } from '../remiSetupApproverViewReducer';
|
|
8
8
|
export const deleteRemiApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteRemiApprovalRule.match), switchMap((action) => {
|
|
9
|
-
const { approvalRuleId } = action.payload;
|
|
9
|
+
const { approvalRuleId, useV3 } = action.payload;
|
|
10
|
+
// Approval Rules 3.0 — flag-gated endpoint selection.
|
|
11
|
+
// Explicit `=== true` keeps `strict-boolean-expressions` happy
|
|
12
|
+
// when RTK's payload type widens to `any` in some configs.
|
|
13
|
+
const endpoint = useV3 === true
|
|
14
|
+
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
|
|
15
|
+
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
|
|
10
16
|
return zeniAPI
|
|
11
|
-
.deleteAndGetJSON(
|
|
17
|
+
.deleteAndGetJSON(endpoint, {
|
|
18
|
+
approval_rule_id: approvalRuleId,
|
|
19
|
+
})
|
|
12
20
|
.pipe(mergeMap((response) => {
|
|
13
21
|
if (isSuccessResponse(response) && response.data != null) {
|
|
14
22
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -6,7 +6,7 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { fetchRemiSetupApproverView, fetchRemiSetupApproverViewFailure, fetchRemiSetupApproverViewSuccess, } from '../remiSetupApproverViewReducer';
|
|
8
8
|
export const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchRemiSetupApproverView.match), switchMap((action) => {
|
|
9
|
-
const { cacheOverride, resolveAttributeToUser, includeImplicitActors } = action.payload;
|
|
9
|
+
const { cacheOverride, resolveAttributeToUser, includeImplicitActors, useV3, } = action.payload;
|
|
10
10
|
const { remiSetupApproverViewState, approvalRuleState } = state$.value;
|
|
11
11
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, remiSetupApproverViewState.approvalRuleIds);
|
|
12
12
|
if (cacheOverride === true ||
|
|
@@ -14,8 +14,14 @@ export const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => act
|
|
|
14
14
|
remiSetupApproverViewState.approvalRuleIds.length ||
|
|
15
15
|
(remiSetupApproverViewState.hasValidState() === false &&
|
|
16
16
|
remiSetupApproverViewState.fetchState !== 'In-Progress')) {
|
|
17
|
+
// Approval Rules 3.0 — flag-gated endpoint selection.
|
|
18
|
+
// Explicit `=== true` keeps `strict-boolean-expressions` happy
|
|
19
|
+
// when RTK's payload type widens to `any` in some configs.
|
|
20
|
+
const basePath = useV3 === true
|
|
21
|
+
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
|
|
22
|
+
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
|
|
17
23
|
return zeniAPI
|
|
18
|
-
.getJSON(`${
|
|
24
|
+
.getJSON(`${basePath}?query={"is_include_implicit_actors": ${includeImplicitActors}, "is_resolve_attribute_to_user":${resolveAttributeToUser}}`)
|
|
19
25
|
.pipe(mergeMap((response) => {
|
|
20
26
|
if (isSuccessResponse(response) && response.data != null) {
|
|
21
27
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { getApprovalRuleById } from '../../../../../entity/approvalRule/approvalRuleSelector';
|
|
3
|
+
import { getAmountCriteria, getApprovalRuleById, getDepartmentCriteria, getVendorCriteria, } from '../../../../../entity/approvalRule/approvalRuleSelector';
|
|
4
4
|
import { clearRemiSetupApproverViewUpdateData, initializeRemiSetupApproverViewUpdateData, saveRemiSetupApproverViewUpdateData, } from '../remiSetupApproverViewReducer';
|
|
5
5
|
export const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$) => actions$.pipe(filter(initializeRemiSetupApproverViewUpdateData.match), mergeMap((action) => {
|
|
6
6
|
const { approvalRuleId } = action.payload;
|
|
@@ -8,16 +8,20 @@ export const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$)
|
|
|
8
8
|
if (approvalRuleId != null) {
|
|
9
9
|
const approvalRule = getApprovalRuleById(state$.value.approvalRuleState, approvalRuleId);
|
|
10
10
|
if (approvalRule != null) {
|
|
11
|
-
const criteria = approvalRule.criteria[0];
|
|
12
|
-
const range = criteria?.range;
|
|
13
11
|
const remiSetupApproverViewUpdateData = {
|
|
14
12
|
approvalRuleId,
|
|
15
13
|
steps: approvalRule.steps,
|
|
16
14
|
criteria: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
amount: getAmountCriteria(approvalRule.criteria),
|
|
16
|
+
vendor: getVendorCriteria(approvalRule.criteria),
|
|
17
|
+
department: getDepartmentCriteria(approvalRule.criteria),
|
|
20
18
|
},
|
|
19
|
+
// Approval Rules 3.0 — seed rule-level fields so the form can
|
|
20
|
+
// round-trip them on edit. Each may be undefined on legacy rules.
|
|
21
|
+
name: approvalRule.name,
|
|
22
|
+
description: approvalRule.description,
|
|
23
|
+
separationOfDuties: approvalRule.separationOfDuties,
|
|
24
|
+
isFallback: approvalRule.isFallback,
|
|
21
25
|
};
|
|
22
26
|
fetchActions.push(clearRemiSetupApproverViewUpdateData(), saveRemiSetupApproverViewUpdateData(remiSetupApproverViewUpdateData));
|
|
23
27
|
}
|
|
@@ -25,7 +29,7 @@ export const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$)
|
|
|
25
29
|
else {
|
|
26
30
|
const remiSetupApproverViewCreateData = {
|
|
27
31
|
steps: [],
|
|
28
|
-
criteria:
|
|
32
|
+
criteria: {},
|
|
29
33
|
};
|
|
30
34
|
fetchActions.push(clearRemiSetupApproverViewUpdateData(), saveRemiSetupApproverViewUpdateData(remiSetupApproverViewCreateData));
|
|
31
35
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { updateApprovalRules } from '../../../../../entity/approvalRule/approvalRuleReducer';
|
|
4
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
6
|
+
import { fetchRemiSetupApproverView, reorderRemiApprovalRules, reorderRemiApprovalRulesFailure, reorderRemiApprovalRulesSuccess, } from '../remiSetupApproverViewReducer';
|
|
7
|
+
export const reorderRemiApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(reorderRemiApprovalRules.match), switchMap((action) => {
|
|
8
|
+
const { approvalRuleIds, useV3 } = action.payload;
|
|
9
|
+
const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2/reorder`;
|
|
10
|
+
return zeniAPI
|
|
11
|
+
.putAndGetJSON(endpoint, {
|
|
12
|
+
rule_ids: approvalRuleIds,
|
|
13
|
+
})
|
|
14
|
+
.pipe(mergeMap((response) => {
|
|
15
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
16
|
+
const serverOrderedIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
17
|
+
const actions = [
|
|
18
|
+
updateApprovalRules(response.data.approval_rules),
|
|
19
|
+
reorderRemiApprovalRulesSuccess(serverOrderedIds),
|
|
20
|
+
openSnackbar({
|
|
21
|
+
messageSection: `reimbursement_approval_reorder`,
|
|
22
|
+
messageText: 'success',
|
|
23
|
+
type: 'success',
|
|
24
|
+
}),
|
|
25
|
+
];
|
|
26
|
+
return from(actions);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return from([
|
|
30
|
+
reorderRemiApprovalRulesFailure(response.status),
|
|
31
|
+
openSnackbar({
|
|
32
|
+
messageSection: `reimbursement_approval_reorder`,
|
|
33
|
+
messageText: 'failed',
|
|
34
|
+
type: 'error',
|
|
35
|
+
}),
|
|
36
|
+
fetchRemiSetupApproverView(true, true, useV3),
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
}), catchError((error) => from([
|
|
40
|
+
reorderRemiApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Reorder Reimbursement Approval Rules errored out' +
|
|
41
|
+
JSON.stringify(error))),
|
|
42
|
+
openSnackbar({
|
|
43
|
+
messageSection: `reimbursement_approval_reorder`,
|
|
44
|
+
messageText: 'failed',
|
|
45
|
+
type: 'error',
|
|
46
|
+
}),
|
|
47
|
+
fetchRemiSetupApproverView(true, true, useV3),
|
|
48
|
+
])));
|
|
49
|
+
}));
|
|
@@ -4,16 +4,25 @@ import { updateApprovalRules } from '../../../../../entity/approvalRule/approval
|
|
|
4
4
|
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
|
-
import { toApprovalChangableInfoPayload } from '../../../billPay/billPaySetupApproverView/types/commonPayload';
|
|
7
|
+
import { toApprovalChangableInfoPayload, toApprovalChangableInfoPayloadV1, } from '../../../billPay/billPaySetupApproverView/types/commonPayload';
|
|
8
8
|
import { saveRemiSetupApproverViewUpdates, saveRemiSetupApproverViewUpdatesFailure, saveRemiSetupApproverViewUpdatesSuccess, } from '../remiSetupApproverViewReducer';
|
|
9
|
-
export const saveRemiSetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveRemiSetupApproverViewUpdates.match), switchMap(() => {
|
|
9
|
+
export const saveRemiSetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveRemiSetupApproverViewUpdates.match), switchMap((action) => {
|
|
10
10
|
const { remiSetupApproverViewState } = state$.value;
|
|
11
11
|
const remiSetupApproverViewUpdateData = remiSetupApproverViewState.remiSetupApproverViewUpdateData;
|
|
12
12
|
if (remiSetupApproverViewUpdateData != null &&
|
|
13
13
|
remiSetupApproverViewUpdateData.data != null) {
|
|
14
|
-
|
|
14
|
+
// Approval Rules 3.0 — gate URL + write-side payload mapper on
|
|
15
|
+
// the `approval_rule_v3_config` dynamic config. `useV3` arrives
|
|
16
|
+
// on the action payload from the screen connector.
|
|
17
|
+
const { useV3 } = action.payload;
|
|
18
|
+
const payload = useV3
|
|
19
|
+
? toApprovalChangableInfoPayload(remiSetupApproverViewUpdateData.data)
|
|
20
|
+
: toApprovalChangableInfoPayloadV1(remiSetupApproverViewUpdateData.data);
|
|
21
|
+
const endpoint = useV3
|
|
22
|
+
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
|
|
23
|
+
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
|
|
15
24
|
return zeniAPI
|
|
16
|
-
.postAndGetJSON(
|
|
25
|
+
.postAndGetJSON(endpoint, payload)
|
|
17
26
|
.pipe(mergeMap((response) => {
|
|
18
27
|
if (isSuccessResponse(response) && response.data != null) {
|
|
19
28
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|