@zeniai/client-epic-state 5.1.2 → 5.1.3-betaAS1
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/commonPayloadTypes/commonPayload.d.ts +25 -4
- package/lib/entity/approvalRule/approvalRulePayload.d.ts +1 -1
- package/lib/entity/approvalRule/approvalRulePayload.js +5 -1
- package/lib/esm/entity/approvalRule/approvalRulePayload.js +5 -1
- package/lib/esm/index.js +6 -1
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -1
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +7 -3
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -34
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +146 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +40 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +86 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +55 -8
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -6
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +154 -0
- package/lib/index.d.ts +8 -2
- package/lib/index.js +25 -7
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +5 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +6 -2
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +2 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +32 -33
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +4 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +150 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +38 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +43 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +27 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +96 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +24 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +59 -9
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +4 -5
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +20 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +32 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +159 -0
- package/package.json +1 -1
|
@@ -10,10 +10,31 @@ export interface AllowedValueWithCodeOptionalPayload {
|
|
|
10
10
|
export declare function isAllowedValueWithCodePayload(allowedValueWithCodePayload: any): allowedValueWithCodePayload is AllowedValueWithCodePayload;
|
|
11
11
|
export declare function isAllowedValueWithCodeOptionalPayload(allowedValueWithCodePayload: any): allowedValueWithCodePayload is AllowedValueWithCodeOptionalPayload;
|
|
12
12
|
export declare function toAllowedValueWithCode(allowedValueWithCodePayload: AllowedValueWithCodePayload): AllowedValueWithCode;
|
|
13
|
+
export interface LabelValueCodeDescriptionPayload {
|
|
14
|
+
code: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
export interface LabelValueFileOptionPayload {
|
|
18
|
+
file_id: string;
|
|
19
|
+
option?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LabelValuePersonNamePayload {
|
|
22
|
+
first_name?: string;
|
|
23
|
+
last_name?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface LabelValuePersonPayload {
|
|
26
|
+
company_role?: string;
|
|
27
|
+
date_of_birth?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
name?: LabelValuePersonNamePayload;
|
|
30
|
+
nationality?: string;
|
|
31
|
+
ownership_percentage?: number;
|
|
32
|
+
proof_of_address?: LabelValueFileOptionPayload[];
|
|
33
|
+
proof_of_identity?: LabelValueFileOptionPayload[];
|
|
34
|
+
ssn?: string;
|
|
35
|
+
}
|
|
36
|
+
export type LabelValueCodesValuesPayload = string | string[] | LabelValueCodeDescriptionPayload | LabelValueCodeDescriptionPayload[] | LabelValueFileOptionPayload | LabelValueFileOptionPayload[] | LabelValuePersonPayload | LabelValuePersonPayload[];
|
|
13
37
|
export interface LabelValueCodesPayload {
|
|
14
38
|
label: string;
|
|
15
|
-
values:
|
|
16
|
-
code: string;
|
|
17
|
-
description: string;
|
|
18
|
-
}[] | string[];
|
|
39
|
+
values: LabelValueCodesValuesPayload;
|
|
19
40
|
}
|
|
@@ -2,7 +2,7 @@ import { ApprovalRule } from './approvalRuleState';
|
|
|
2
2
|
/**
|
|
3
3
|
* Condition Payload — one entry inside criteria.conditions[].
|
|
4
4
|
*
|
|
5
|
-
* field examples: 'amount' | 'vendor_id' | '
|
|
5
|
+
* field examples: 'amount' | 'vendor_id' | 'accounting_class_id'
|
|
6
6
|
* type examples: 'gte' | 'lte' | 'eq' | 'in' | 'not_in'
|
|
7
7
|
* value: number for amount comparisons; string[] for in / not_in lookups.
|
|
8
8
|
*/
|
|
@@ -69,7 +69,11 @@ const toApprovalCriteria = (payload) => {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
payload.conditions
|
|
72
|
-
|
|
72
|
+
// Backend wire name is 'accounting_class_id' — kept in sync with
|
|
73
|
+
// the write-side mapper in 'commonPayload.ts'. State-side and
|
|
74
|
+
// form-side keep 'department' / 'departmentIds' to match product
|
|
75
|
+
// copy.
|
|
76
|
+
.filter((condition) => condition.field === 'accounting_class_id')
|
|
73
77
|
.forEach((condition) => {
|
|
74
78
|
const department = toDepartmentCriteria(condition);
|
|
75
79
|
if (department != null) {
|
|
@@ -65,7 +65,11 @@ const toApprovalCriteria = (payload) => {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
payload.conditions
|
|
68
|
-
|
|
68
|
+
// Backend wire name is 'accounting_class_id' — kept in sync with
|
|
69
|
+
// the write-side mapper in 'commonPayload.ts'. State-side and
|
|
70
|
+
// form-side keep 'department' / 'departmentIds' to match product
|
|
71
|
+
// copy.
|
|
72
|
+
.filter((condition) => condition.field === 'accounting_class_id')
|
|
69
73
|
.forEach((condition) => {
|
|
70
74
|
const department = toDepartmentCriteria(condition);
|
|
71
75
|
if (department != null) {
|
package/lib/esm/index.js
CHANGED
|
@@ -290,6 +290,7 @@ import { convertAmountToHomeCurrency, discardBillUpdatesInLocalStore, discardOut
|
|
|
290
290
|
import { checkIfCreatorIsApprover, getEditBillDetail, toPaymentToOption, } from './view/spendManagement/billPay/editBillView/editBillViewSelector';
|
|
291
291
|
import { clearInternationalWire, createPaymentInstrument, createPaymentInstrumentUpdateStatus, deletePaymentInstrument, fetchInternationalWireDynamicForm, initializeDynamicForm, initializeInternationalWireLocalData, updateInternationalWireLocalStoreData, } from './view/spendManagement/billPay/internationalWire/internationalWireReducer';
|
|
292
292
|
import { getInternationalWireView, } from './view/spendManagement/billPay/internationalWire/internationalWireSelector';
|
|
293
|
+
import { InternationalWireVerificationFormOrder, sortVerificationFormFields, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload';
|
|
293
294
|
import { fetchInternationalVerificationForm, submitInternationalVerificationForm, updateVerificationFormLocalData, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer';
|
|
294
295
|
import { getIntlWireVerificationView, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector';
|
|
295
296
|
import { fetchBillAttachment, fetchMagicLinkBankNameByRouting, fetchMagicLinkBankNameBySwift, fetchMagicLinkTenant, saveBankAccount, saveMagicLinkAddressInLocalStore, updateMagicLinkBankAccountLocalStoreData, updateMagicLinkInternationalBankAccountLocalStoreData, } from './view/spendManagement/billPay/magicLinkView/magicLinkViewReducer';
|
|
@@ -641,7 +642,11 @@ export { pushToastNotification, getLastNotificationTime, getNotifications, };
|
|
|
641
642
|
export { getReferralListView, getInviteFormView, toReferralListViewSortKeyType, StatusTypes, AmountStatusTypes, fetchReferrals, sendReferralInvite, clearReferrals, saveReferralFormDataInLocalStore, updateReferralListSortUiState, resendReferralInvite, fetchRewardsPlan, getRewardsPlanCard, updateReferViewed, };
|
|
642
643
|
export { ALL_WEEK_DAYS, SEMI_WEEKLY_REQUIRED_DAYS_COUNT, getMinAllowedEndDate, getRecurringEndDateFromCount, toDayOfWeek, toRecurringFrequency, };
|
|
643
644
|
export { fetchCockpitContext, fetchCompanyTaskManagerView, fetchTaskManagerMetrics, getCompanyTaskManagerView, createTaskFromTaskGroupTemplate, };
|
|
644
|
-
export { fetchInternationalVerificationForm, submitInternationalVerificationForm, updateVerificationFormLocalData, getIntlWireVerificationView, };
|
|
645
|
+
export { InternationalWireVerificationFormOrder, sortVerificationFormFields, fetchInternationalVerificationForm, submitInternationalVerificationForm, updateVerificationFormLocalData, getIntlWireVerificationView, };
|
|
646
|
+
export { InternationalWireVerificationBooleanWithSubfieldsFieldNameList, InternationalWireVerificationBooleanWithSubfieldsFieldNames, InternationalWireVerificationControllingPersonFieldName, InternationalWireVerificationFormFieldNames, InternationalWireVerificationStakeHolderFieldName, InternationalWireVerificationSubfieldNames, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants';
|
|
647
|
+
export { IntlWireVerificationLocalDataSuffix, toIntlWireVerificationFormDetails, toIntlWireVerificationSubmitPayload, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload';
|
|
648
|
+
export { getStakeHolderOwnerIndicesFromLocalData, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers';
|
|
649
|
+
export { toVerificationFormLocalDataFromOnboardingDetails, } from './view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData';
|
|
645
650
|
export { fetchExpressPayInitialDetails, updateExpressPayFormLocalData, submitExpressPay, resetExpressPayLocalData, getExpressPayView, };
|
|
646
651
|
export { acceptTreasuryTerms, fetchTreasurySetupView, clearTreasurySetupView, fetchTreasuryFunds, updatePortfolioAllocation, fetchPortfolioAllocation, updateFundAllocationLocalData, updateTreasuryPromoIntroClosedByOutsideClick, updateTreasuryPromoRemindMeLaterClicked, updateTreasuryVideoViewed, getTreasurySetupViewDetails, getTreasuryFundsMaximumYield, };
|
|
647
652
|
// ── AI Accountant Entity ──
|
package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js
CHANGED
|
@@ -29,7 +29,11 @@ export const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
|
|
|
29
29
|
}
|
|
30
30
|
if (department != null && department.departmentIds.length > 0) {
|
|
31
31
|
conditions.push({
|
|
32
|
-
|
|
32
|
+
// The backend models 'department' as the accounting class
|
|
33
|
+
// entity, so the wire field name is 'accounting_class_id'
|
|
34
|
+
// (not 'department_id'). State-side and form-side keep
|
|
35
|
+
// 'department' / 'departmentIds' to match product copy.
|
|
36
|
+
field: 'accounting_class_id',
|
|
33
37
|
type: department.operator === 'is_not' ? 'not_in' : 'in',
|
|
34
38
|
value: department.departmentIds,
|
|
35
39
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { from, of } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { toVerificationFormLocalDataFromOnboardingDetails } from '../internationalWireOnboardingDetailsToLocalData';
|
|
5
|
+
import { fetchInternationalVerificationForm, updateInternationalVerificationForm, updateVerificationFormFailure, updateVerificationFormLocalData, } from '../internationalWireVerificationReducer';
|
|
6
|
+
export const fetchIntlVerificationFormEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchInternationalVerificationForm.match), switchMap((action) => {
|
|
6
7
|
const query = {
|
|
7
8
|
region: 'US',
|
|
8
9
|
legal_type: 'BUSINESS',
|
|
@@ -11,11 +12,14 @@ export const fetchIntlVerificationFormEpic = (actions$, _state$, zeniAPI) => act
|
|
|
11
12
|
.getJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding-fields?query=${encodeURIComponent(JSON.stringify(query))}`)
|
|
12
13
|
.pipe(mergeMap((response) => {
|
|
13
14
|
if (isSuccessResponse(response) && response.data != null) {
|
|
15
|
+
const onboardingDataFromCompanyInfo = state$.value.companyState.companiesById[action.payload.companyId]
|
|
16
|
+
?.companyBillPayInfo?.internationalWireOnboardingDetails;
|
|
17
|
+
const localData = toVerificationFormLocalDataFromOnboardingDetails(onboardingDataFromCompanyInfo, response.data.labels);
|
|
14
18
|
return from([
|
|
15
19
|
updateInternationalVerificationForm({
|
|
16
20
|
internationalWireFormPayload: response.data.labels,
|
|
17
21
|
}),
|
|
18
|
-
|
|
22
|
+
updateVerificationFormLocalData(localData),
|
|
19
23
|
]);
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
1
|
+
import { empty, from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { getCurrentTenant } from '../../../../../entity/tenant/tenantSelector';
|
|
4
|
+
import { fetchBillPaySetupViewSuccess } from '../../billPaySetupView/billPaySetupViewReducer';
|
|
5
|
+
import { toVerificationFormLocalDataFromOnboardingDetails } from '../internationalWireOnboardingDetailsToLocalData';
|
|
3
6
|
import { initializeIntlVerificationForm, updateVerificationFormLocalData, } from '../internationalWireVerificationReducer';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const hasSavedPersonSubfieldData = (localData) => Object.keys(localData).some((key) => /^stake_holder_\d+_/.test(key) ||
|
|
8
|
+
(key.startsWith('controlling_person_') && key !== 'controlling_person'));
|
|
9
|
+
export const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe(filter((action) => initializeIntlVerificationForm.match(action) ||
|
|
10
|
+
fetchBillPaySetupViewSuccess.match(action)), mergeMap((action) => {
|
|
7
11
|
const state = state$.value;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
: values[0];
|
|
12
|
+
const formFieldLabels = state.internationalWireVerificationState.verificationFormFieldLabels;
|
|
13
|
+
if (Object.keys(formFieldLabels).length === 0) {
|
|
14
|
+
return empty();
|
|
15
|
+
}
|
|
16
|
+
const companyId = initializeIntlVerificationForm.match(action) ?
|
|
17
|
+
action.payload.companyId
|
|
18
|
+
: getCurrentTenant(state)?.companyId;
|
|
19
|
+
if (companyId == null) {
|
|
20
|
+
return empty();
|
|
21
|
+
}
|
|
22
|
+
const onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId]?.companyBillPayInfo
|
|
23
|
+
?.internationalWireOnboardingDetails;
|
|
24
|
+
const localDataFromCompany = toVerificationFormLocalDataFromOnboardingDetails(onboardingDataFromCompanyInfo, formFieldLabels);
|
|
25
|
+
const existingLocalData = state.internationalWireVerificationState.verificationFormLocalData;
|
|
26
|
+
if (fetchBillPaySetupViewSuccess.match(action)) {
|
|
27
|
+
if (!hasSavedPersonSubfieldData(localDataFromCompany) ||
|
|
28
|
+
hasSavedPersonSubfieldData(existingLocalData)) {
|
|
29
|
+
return empty();
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
actions.push(updateVerificationFormLocalData(localData));
|
|
38
|
-
return from(actions);
|
|
31
|
+
}
|
|
32
|
+
return from([
|
|
33
|
+
updateVerificationFormLocalData({
|
|
34
|
+
...existingLocalData,
|
|
35
|
+
...localDataFromCompany,
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
39
38
|
}));
|
|
@@ -3,6 +3,7 @@ import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
|
3
3
|
import { updateInternationalWireOnboardingStatus } from '../../../../../entity/company/companyReducer';
|
|
4
4
|
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
6
|
+
import { toIntlWireVerificationSubmitPayload } from '../internationalWireVerificationSubmitPayload';
|
|
6
7
|
import { submitInternationalVerificationForm, updateVerificationFormSubmissionStatus, } from '../internationalWireVerificationReducer';
|
|
7
8
|
export const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(submitInternationalVerificationForm.match), switchMap((action) => {
|
|
8
9
|
const { internationalWireVerificationState } = state$.value;
|
|
@@ -10,7 +11,7 @@ export const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions
|
|
|
10
11
|
const localData = internationalWireVerificationState.verificationFormLocalData;
|
|
11
12
|
if (localData != null) {
|
|
12
13
|
return zeniAPI
|
|
13
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding`,
|
|
14
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding`, toIntlWireVerificationSubmitPayload(localData))
|
|
14
15
|
.pipe(mergeMap((response) => {
|
|
15
16
|
const actions = [];
|
|
16
17
|
if (isSuccessResponse(response) && response.data != null) {
|
|
@@ -54,9 +55,3 @@ export const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions
|
|
|
54
55
|
return from([]);
|
|
55
56
|
}
|
|
56
57
|
}));
|
|
57
|
-
const toIntlWireVerificationPayload = (localData) => {
|
|
58
|
-
return {
|
|
59
|
-
is_applicant_declaration: true,
|
|
60
|
-
form_details: localData,
|
|
61
|
-
};
|
|
62
|
-
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { InternationalWireVerificationBooleanWithSubfieldsFieldNames, InternationalWireVerificationFormFieldNames, } from './internationalWireVerificationFieldConstants';
|
|
2
|
+
import { appendIntlWireFileOptionsToLocalData, appendIntlWirePersonToLocalData, isIntlWireFileOptionLike, isIntlWirePersonLike, toIntlWireFileOptionArray, } from './internationalWireVerificationLocalDataHelpers';
|
|
3
|
+
const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
|
|
4
|
+
InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
5
|
+
InternationalWireVerificationFormFieldNames.companyProofOfAddress,
|
|
6
|
+
InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
|
|
7
|
+
]);
|
|
8
|
+
const toValuesArray = (values) => {
|
|
9
|
+
if (values == null) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(values)) {
|
|
13
|
+
return values;
|
|
14
|
+
}
|
|
15
|
+
return [values];
|
|
16
|
+
};
|
|
17
|
+
const getCodeFromValue = (value) => {
|
|
18
|
+
if (typeof value === 'string') {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === 'object' &&
|
|
22
|
+
value != null &&
|
|
23
|
+
'code' in value &&
|
|
24
|
+
typeof value.code === 'string') {
|
|
25
|
+
return value.code;
|
|
26
|
+
}
|
|
27
|
+
return '';
|
|
28
|
+
};
|
|
29
|
+
const setEmptyFieldDefault = (localData, fieldKey, fieldPayload) => {
|
|
30
|
+
if (fieldPayload.type === 'enum') {
|
|
31
|
+
localData[fieldKey] =
|
|
32
|
+
fieldPayload.is_multiple_values_allowed === true ? [] : '';
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (fieldPayload.type === 'boolean_with_subfields') {
|
|
36
|
+
if (fieldKey ===
|
|
37
|
+
InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
|
|
38
|
+
localData[fieldKey] = 'false';
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (fieldKey ===
|
|
42
|
+
InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
|
|
43
|
+
localData[fieldKey] = fieldPayload.default === true ? 'true' : 'false';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const parseEnumValues = (localData, fieldKey, fieldPayload, values) => {
|
|
48
|
+
if (fieldPayload.is_multiple_values_allowed === true) {
|
|
49
|
+
localData[fieldKey] = values
|
|
50
|
+
.map(getCodeFromValue)
|
|
51
|
+
.filter((code) => code.length > 0);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
localData[fieldKey] = getCodeFromValue(values[0]);
|
|
55
|
+
};
|
|
56
|
+
const parseFileValues = (localData, fieldKey, fieldPayload, values) => {
|
|
57
|
+
if (values.length > 0 &&
|
|
58
|
+
(isIntlWireFileOptionLike(values[0]) ||
|
|
59
|
+
MULTI_OPTION_FILE_FIELD_NAMES.has(fieldKey))) {
|
|
60
|
+
const fileOptions = toIntlWireFileOptionArray(values);
|
|
61
|
+
if (fileOptions.length > 0) {
|
|
62
|
+
appendIntlWireFileOptionsToLocalData(localData, fieldKey, fileOptions);
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const fileIds = values.filter((value) => typeof value === 'string' && value.length > 0);
|
|
67
|
+
if (fieldPayload.is_multiple_values_allowed === true) {
|
|
68
|
+
localData[fieldKey] = fileIds;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
localData[fieldKey] = fileIds[0] ?? '';
|
|
72
|
+
};
|
|
73
|
+
const parseBooleanWithSubfieldsValues = (localData, fieldKey, fieldPayload, rawValues) => {
|
|
74
|
+
if (fieldKey ===
|
|
75
|
+
InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
|
|
76
|
+
if (isIntlWirePersonLike(rawValues)) {
|
|
77
|
+
localData[fieldKey] = 'false';
|
|
78
|
+
appendIntlWirePersonToLocalData(localData, fieldKey, rawValues);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const values = toValuesArray(rawValues);
|
|
82
|
+
if (values.length > 0 && isIntlWirePersonLike(values[0])) {
|
|
83
|
+
localData[fieldKey] = 'false';
|
|
84
|
+
appendIntlWirePersonToLocalData(localData, fieldKey, values[0]);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const selection = getCodeFromValue(values[0]);
|
|
88
|
+
localData[fieldKey] =
|
|
89
|
+
selection.length > 0
|
|
90
|
+
? selection
|
|
91
|
+
: fieldPayload.default === true
|
|
92
|
+
? 'true'
|
|
93
|
+
: 'false';
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (fieldKey ===
|
|
97
|
+
InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
|
|
98
|
+
const values = toValuesArray(rawValues);
|
|
99
|
+
if (values.length > 0 && isIntlWirePersonLike(values[0])) {
|
|
100
|
+
localData[fieldKey] = 'true';
|
|
101
|
+
values.forEach((person, ownerIndex) => {
|
|
102
|
+
if (isIntlWirePersonLike(person)) {
|
|
103
|
+
appendIntlWirePersonToLocalData(localData, `${fieldKey}_${ownerIndex}`, person);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const selection = getCodeFromValue(values[0]);
|
|
109
|
+
localData[fieldKey] = selection.length > 0 ? selection : 'false';
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
export const toVerificationFormLocalDataFromOnboardingDetails = (onboardingDetails, internationalWireFormPayload) => {
|
|
113
|
+
const localData = {};
|
|
114
|
+
Object.keys(internationalWireFormPayload).forEach((fieldKey) => {
|
|
115
|
+
const fieldPayload = internationalWireFormPayload[fieldKey];
|
|
116
|
+
const rawValues = onboardingDetails?.[fieldKey]?.values;
|
|
117
|
+
if (rawValues == null) {
|
|
118
|
+
setEmptyFieldDefault(localData, fieldKey, fieldPayload);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (fieldPayload.type === 'boolean_with_subfields') {
|
|
122
|
+
parseBooleanWithSubfieldsValues(localData, fieldKey, fieldPayload, rawValues);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const values = toValuesArray(rawValues);
|
|
126
|
+
if (values.length === 0) {
|
|
127
|
+
setEmptyFieldDefault(localData, fieldKey, fieldPayload);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
switch (fieldPayload.type) {
|
|
131
|
+
case 'enum':
|
|
132
|
+
parseEnumValues(localData, fieldKey, fieldPayload, values);
|
|
133
|
+
break;
|
|
134
|
+
case 'file':
|
|
135
|
+
parseFileValues(localData, fieldKey, fieldPayload, values);
|
|
136
|
+
break;
|
|
137
|
+
case 'date':
|
|
138
|
+
localData[fieldKey] = getCodeFromValue(values[0]);
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
localData[fieldKey] = getCodeFromValue(values[0]);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return localData;
|
|
146
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const InternationalWireVerificationFormFieldNames = {
|
|
2
|
+
certificateOfGoodStanding: 'certificate_of_good_standing',
|
|
3
|
+
businessOwnership: 'business_ownership',
|
|
4
|
+
companyProofOfAddress: 'company_proof_of_address',
|
|
5
|
+
companyOfficerProofOfAddress: 'company_officer_proof_of_address',
|
|
6
|
+
companyRegistrationDate: 'company_registration_date',
|
|
7
|
+
annualTurnover: 'annual_turnover',
|
|
8
|
+
expectedTransactionVolume: 'expected_transaction_volume',
|
|
9
|
+
employeeCount: 'employee_count',
|
|
10
|
+
intendedUseOfAccount: 'intended_use_of_account',
|
|
11
|
+
transactionCountries: 'transaction_countries',
|
|
12
|
+
stakeHolder: 'stake_holder',
|
|
13
|
+
controllingPerson: 'controlling_person',
|
|
14
|
+
};
|
|
15
|
+
export const InternationalWireVerificationStakeHolderFieldName = InternationalWireVerificationFormFieldNames.stakeHolder;
|
|
16
|
+
export const InternationalWireVerificationControllingPersonFieldName = InternationalWireVerificationFormFieldNames.controllingPerson;
|
|
17
|
+
export const InternationalWireVerificationBooleanWithSubfieldsFieldNames = {
|
|
18
|
+
stakeHolder: InternationalWireVerificationStakeHolderFieldName,
|
|
19
|
+
controllingPerson: InternationalWireVerificationControllingPersonFieldName,
|
|
20
|
+
};
|
|
21
|
+
export const InternationalWireVerificationBooleanWithSubfieldsFieldNameList = Object.values(InternationalWireVerificationBooleanWithSubfieldsFieldNames);
|
|
22
|
+
export const InternationalWireVerificationSubfieldNames = {
|
|
23
|
+
companyRole: 'company_role',
|
|
24
|
+
dateOfBirth: 'date_of_birth',
|
|
25
|
+
name: 'name',
|
|
26
|
+
email: 'email',
|
|
27
|
+
nationality: 'nationality',
|
|
28
|
+
ownershipPercentage: 'ownership_percentage',
|
|
29
|
+
proofOfIdentity: 'proof_of_identity',
|
|
30
|
+
proofOfAddress: 'proof_of_address',
|
|
31
|
+
ssn: 'ssn',
|
|
32
|
+
};
|
|
33
|
+
export const InternationalWireVerificationReadonlyHideableFieldNames = [
|
|
34
|
+
InternationalWireVerificationFormFieldNames.stakeHolder,
|
|
35
|
+
InternationalWireVerificationFormFieldNames.controllingPerson,
|
|
36
|
+
InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
37
|
+
InternationalWireVerificationFormFieldNames.companyProofOfAddress,
|
|
38
|
+
InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
|
|
39
|
+
];
|
|
40
|
+
export const InternationalWireVerificationReadonlyVisibilityGateFieldName = InternationalWireVerificationFormFieldNames.businessOwnership;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { InternationalWireVerificationFormFieldNames, InternationalWireVerificationSubfieldNames, } from './internationalWireVerificationFieldConstants';
|
|
2
|
+
import { IntlWireVerificationLocalDataSuffix } from './internationalWireVerificationSubmitPayload';
|
|
3
|
+
export const isIntlWireFileOptionLike = (value) => typeof value === 'object' &&
|
|
4
|
+
value != null &&
|
|
5
|
+
'file_id' in value &&
|
|
6
|
+
typeof value.file_id === 'string';
|
|
7
|
+
export const isIntlWirePersonLike = (value) => {
|
|
8
|
+
if (typeof value !== 'object' || value == null || Array.isArray(value)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const person = value;
|
|
12
|
+
return (person.name != null ||
|
|
13
|
+
person.email != null ||
|
|
14
|
+
person.nationality != null ||
|
|
15
|
+
person.company_role != null ||
|
|
16
|
+
person.ssn != null ||
|
|
17
|
+
person.date_of_birth != null ||
|
|
18
|
+
person.ownership_percentage != null ||
|
|
19
|
+
person.proof_of_identity != null ||
|
|
20
|
+
person.proof_of_address != null);
|
|
21
|
+
};
|
|
22
|
+
export const toIntlWireFileOptionArray = (items) => items.filter(isIntlWireFileOptionLike);
|
|
23
|
+
export const appendIntlWireFileOptionsToLocalData = (localData, baseKey, fileOptions) => {
|
|
24
|
+
const [front, back] = fileOptions;
|
|
25
|
+
if (front?.file_id != null && front.file_id !== '') {
|
|
26
|
+
localData[baseKey] = front.file_id;
|
|
27
|
+
if (front.option != null && front.option !== '') {
|
|
28
|
+
localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`] = front.option;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (back?.file_id != null && back.file_id !== '') {
|
|
32
|
+
localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`] =
|
|
33
|
+
back.file_id;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) => {
|
|
37
|
+
const nameBaseKey = `${keyPrefix}_${InternationalWireVerificationSubfieldNames.name}`;
|
|
38
|
+
if (person.name?.first_name != null) {
|
|
39
|
+
localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameFirst}`] = person.name.first_name;
|
|
40
|
+
}
|
|
41
|
+
if (person.name?.last_name != null) {
|
|
42
|
+
localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameLast}`] = person.name.last_name;
|
|
43
|
+
}
|
|
44
|
+
const assignStringField = (subfieldName, fieldValue) => {
|
|
45
|
+
if (fieldValue != null && fieldValue !== '') {
|
|
46
|
+
localData[`${keyPrefix}_${subfieldName}`] = fieldValue;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
assignStringField(InternationalWireVerificationSubfieldNames.nationality, person.nationality);
|
|
50
|
+
assignStringField(InternationalWireVerificationSubfieldNames.email, person.email);
|
|
51
|
+
assignStringField(InternationalWireVerificationSubfieldNames.companyRole, person.company_role);
|
|
52
|
+
assignStringField(InternationalWireVerificationSubfieldNames.ssn, person.ssn);
|
|
53
|
+
assignStringField(InternationalWireVerificationSubfieldNames.dateOfBirth, person.date_of_birth);
|
|
54
|
+
if (person.ownership_percentage != null) {
|
|
55
|
+
localData[`${keyPrefix}_${InternationalWireVerificationSubfieldNames.ownershipPercentage}`] = person.ownership_percentage;
|
|
56
|
+
}
|
|
57
|
+
if (person.proof_of_identity != null) {
|
|
58
|
+
appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfIdentity}`, toIntlWireFileOptionArray(person.proof_of_identity));
|
|
59
|
+
}
|
|
60
|
+
if (person.proof_of_address != null) {
|
|
61
|
+
appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfAddress}`, toIntlWireFileOptionArray(person.proof_of_address));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
|
|
65
|
+
const indices = new Set();
|
|
66
|
+
Object.keys(localData).forEach((key) => {
|
|
67
|
+
const match = key.match(/^stake_holder_(\d+)_/);
|
|
68
|
+
if (match != null) {
|
|
69
|
+
indices.add(Number.parseInt(match[1], 10));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return Array.from(indices).sort((a, b) => a - b);
|
|
73
|
+
};
|
|
74
|
+
export const hasBusinessOwnershipValueInLocalData = (localData) => {
|
|
75
|
+
const baseKey = InternationalWireVerificationFormFieldNames.businessOwnership;
|
|
76
|
+
const frontFileId = localData[baseKey];
|
|
77
|
+
if (typeof frontFileId === 'string' && frontFileId !== '') {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
const backFileId = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`];
|
|
81
|
+
if (typeof backFileId === 'string' && backFileId !== '') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const documentOption = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`];
|
|
85
|
+
return typeof documentOption === 'string' && documentOption !== '';
|
|
86
|
+
};
|
|
@@ -1,15 +1,62 @@
|
|
|
1
|
+
import { InternationalWireVerificationReadonlyHideableFieldNames, InternationalWireVerificationFormFieldNames, } from './internationalWireVerificationFieldConstants';
|
|
2
|
+
import { hasBusinessOwnershipValueInLocalData } from './internationalWireVerificationLocalDataHelpers';
|
|
3
|
+
export const InternationalWireVerificationFormOrder = [
|
|
4
|
+
InternationalWireVerificationFormFieldNames.certificateOfGoodStanding,
|
|
5
|
+
InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
6
|
+
InternationalWireVerificationFormFieldNames.companyProofOfAddress,
|
|
7
|
+
InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
|
|
8
|
+
InternationalWireVerificationFormFieldNames.companyRegistrationDate,
|
|
9
|
+
InternationalWireVerificationFormFieldNames.annualTurnover,
|
|
10
|
+
InternationalWireVerificationFormFieldNames.expectedTransactionVolume,
|
|
11
|
+
InternationalWireVerificationFormFieldNames.employeeCount,
|
|
12
|
+
InternationalWireVerificationFormFieldNames.intendedUseOfAccount,
|
|
13
|
+
InternationalWireVerificationFormFieldNames.transactionCountries,
|
|
14
|
+
InternationalWireVerificationFormFieldNames.stakeHolder,
|
|
15
|
+
InternationalWireVerificationFormFieldNames.controllingPerson,
|
|
16
|
+
];
|
|
17
|
+
const toFieldValues = (fieldValues) => fieldValues?.map(({ code, description }) => ({ code, description })) ?? [];
|
|
18
|
+
const toSubField = (subfield) => ({
|
|
19
|
+
label: subfield.label,
|
|
20
|
+
placeholder: subfield.field_hint_text ?? '',
|
|
21
|
+
type: subfield.type,
|
|
22
|
+
fieldValues: toFieldValues(subfield.field_values),
|
|
23
|
+
isMultipleOptionsSupported: subfield.is_multiple_options_supported,
|
|
24
|
+
options: subfield.options,
|
|
25
|
+
});
|
|
1
26
|
export const toDynamicFormField = (key, payload) => ({
|
|
2
27
|
name: key,
|
|
3
28
|
label: payload.label,
|
|
4
29
|
placeholder: payload.field_hint_text ?? '',
|
|
5
30
|
isMultipleValuesAllowed: payload.is_multiple_values_allowed ?? false,
|
|
6
31
|
type: payload.type,
|
|
7
|
-
fieldValues: payload.field_values
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
32
|
+
fieldValues: toFieldValues(payload.field_values),
|
|
33
|
+
isMultipleOptionsSupported: payload.is_multiple_options_supported,
|
|
34
|
+
options: payload.options,
|
|
35
|
+
requirements: payload.requirements,
|
|
36
|
+
default: payload.default,
|
|
37
|
+
subfields: payload.subfields != null
|
|
38
|
+
? Object.fromEntries(Object.entries(payload.subfields).map(([subfieldKey, subfield]) => [
|
|
39
|
+
subfieldKey,
|
|
40
|
+
toSubField(subfield),
|
|
41
|
+
]))
|
|
42
|
+
: undefined,
|
|
15
43
|
});
|
|
44
|
+
const readonlyHideableVerificationFormFieldNames = new Set(InternationalWireVerificationReadonlyHideableFieldNames);
|
|
45
|
+
export const filterVerificationFormFieldsForReadonlyView = (fields, localData, isReadonly) => {
|
|
46
|
+
if (!isReadonly || hasBusinessOwnershipValueInLocalData(localData)) {
|
|
47
|
+
return fields;
|
|
48
|
+
}
|
|
49
|
+
return fields.filter((field) => !readonlyHideableVerificationFormFieldNames.has(field.name));
|
|
50
|
+
};
|
|
51
|
+
export const sortVerificationFormFields = (fields) => {
|
|
52
|
+
const orderIndex = new Map(InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
|
|
53
|
+
return fields.slice().sort((a, b) => {
|
|
54
|
+
const aIndex = orderIndex.get(a.name) ?? InternationalWireVerificationFormOrder.length;
|
|
55
|
+
const bIndex = orderIndex.get(b.name) ?? InternationalWireVerificationFormOrder.length;
|
|
56
|
+
if (aIndex !== bIndex) {
|
|
57
|
+
return aIndex - bIndex;
|
|
58
|
+
}
|
|
59
|
+
return a.name.localeCompare(b.name);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export const toVerificationFormFields = (internationalWireFormPayload) => sortVerificationFormFields(Object.keys(internationalWireFormPayload).map((key) => toDynamicFormField(key, internationalWireFormPayload[key])));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import {
|
|
2
|
+
import { toVerificationFormFields, } from './internationalWireVerificationPayload';
|
|
3
3
|
export const initialState = {
|
|
4
4
|
verificationFormFetchState: {
|
|
5
5
|
fetchState: 'Not-Started',
|
|
6
6
|
},
|
|
7
|
+
verificationFormFieldLabels: {},
|
|
7
8
|
verificationFormFields: [],
|
|
8
9
|
verificationFormLocalData: {},
|
|
9
10
|
verificationFormSubmitState: {
|
|
@@ -31,11 +32,8 @@ const internationalWireVerification = createSlice({
|
|
|
31
32
|
},
|
|
32
33
|
updateInternationalVerificationForm(draft, action) {
|
|
33
34
|
const { internationalWireFormPayload } = action.payload;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
verificationFormFields.push(toDynamicFormField(key, internationalWireFormPayload[key]));
|
|
37
|
-
});
|
|
38
|
-
draft.verificationFormFields = verificationFormFields;
|
|
35
|
+
draft.verificationFormFieldLabels = internationalWireFormPayload;
|
|
36
|
+
draft.verificationFormFields = toVerificationFormFields(internationalWireFormPayload);
|
|
39
37
|
draft.verificationFormFetchState.fetchState = 'Completed';
|
|
40
38
|
},
|
|
41
39
|
updateVerificationFormFailure(draft, action) {
|
|
@@ -45,6 +43,7 @@ const internationalWireVerification = createSlice({
|
|
|
45
43
|
},
|
|
46
44
|
updateVerificationFormLocalData(draft, action) {
|
|
47
45
|
draft.verificationFormLocalData = {
|
|
46
|
+
...draft.verificationFormLocalData,
|
|
48
47
|
...action.payload,
|
|
49
48
|
};
|
|
50
49
|
},
|