@zeniai/client-epic-state 5.0.90-betaAR5 → 5.0.90-betaAS10

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.
Files changed (100) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +25 -4
  2. package/lib/entity/approvalRule/approvalRulePayload.d.ts +5 -34
  3. package/lib/entity/approvalRule/approvalRulePayload.js +10 -145
  4. package/lib/entity/approvalRule/approvalRuleSelector.d.ts +1 -25
  5. package/lib/entity/approvalRule/approvalRuleSelector.js +0 -40
  6. package/lib/entity/approvalRule/approvalRuleState.d.ts +7 -59
  7. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  8. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  9. package/lib/epic.d.ts +1 -3
  10. package/lib/epic.js +1 -3
  11. package/lib/esm/entity/approvalRule/approvalRulePayload.js +10 -145
  12. package/lib/esm/entity/approvalRule/approvalRuleSelector.js +0 -35
  13. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
  14. package/lib/esm/epic.js +1 -3
  15. package/lib/esm/index.js +12 -9
  16. package/lib/esm/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
  17. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +12 -109
  18. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  19. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  20. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +7 -11
  21. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +4 -13
  22. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -140
  23. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
  24. package/lib/esm/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +2 -8
  25. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +7 -3
  26. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -34
  27. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
  28. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +146 -0
  29. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +40 -0
  30. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +86 -0
  31. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +55 -8
  32. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -6
  33. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
  34. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +154 -0
  35. package/lib/esm/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.js +1 -5
  36. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  37. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  38. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -11
  39. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +4 -13
  40. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -80
  41. package/lib/index.d.ts +15 -11
  42. package/lib/index.js +38 -30
  43. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  44. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  45. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  46. package/lib/view/people/peopleTypes.d.ts +1 -1
  47. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.d.ts +0 -7
  48. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
  49. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +3 -14
  50. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +13 -110
  51. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +0 -16
  52. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  53. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  54. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -10
  55. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -12
  56. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -59
  57. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +17 -142
  58. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +5 -31
  59. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -8
  60. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
  61. package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +2 -8
  62. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  63. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +6 -2
  64. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +2 -1
  65. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +32 -33
  66. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +2 -7
  67. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +4 -0
  68. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +150 -0
  69. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +38 -0
  70. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +43 -0
  71. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +27 -0
  72. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +96 -0
  73. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +24 -1
  74. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +59 -9
  75. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +4 -5
  76. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +39 -15
  77. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +20 -1
  78. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +32 -0
  79. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +159 -0
  80. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  81. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.js +1 -5
  82. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  83. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  84. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -10
  85. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +3 -12
  86. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +3 -14
  87. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +12 -81
  88. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +0 -12
  89. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  90. package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
  91. package/package.json +1 -1
  92. package/lib/entity/approvalRule/approvalRuleConflict.d.ts +0 -56
  93. package/lib/entity/approvalRule/approvalRuleConflict.js +0 -77
  94. package/lib/esm/entity/approvalRule/approvalRuleConflict.js +0 -74
  95. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -54
  96. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -61
  97. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.d.ts +0 -23
  98. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -58
  99. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.d.ts +0 -14
  100. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -65
@@ -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
- export const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe(filter(initializeIntlVerificationForm.match), mergeMap((action) => {
5
- const { companyId, internationalWireFormPayload } = action.payload;
6
- const actions = [];
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 onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId].companyBillPayInfo
9
- .internationalWireOnboardingDetails;
10
- const localData = {};
11
- Object.keys(internationalWireFormPayload).forEach((formFieldKey) => {
12
- const values = onboardingDataFromCompanyInfo != null
13
- ? onboardingDataFromCompanyInfo[formFieldKey]?.values
14
- : undefined;
15
- if (values != null) {
16
- localData[formFieldKey] =
17
- internationalWireFormPayload[formFieldKey].type === 'enum'
18
- ? internationalWireFormPayload[formFieldKey]
19
- .is_multiple_values_allowed === false
20
- ? typeof values[0] === 'object' && 'code' in values[0]
21
- ? values[0].code
22
- : ''
23
- : values.map((value) => typeof value === 'object' && 'code' in value
24
- ? value.code
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
- else {
29
- localData[formFieldKey] =
30
- internationalWireFormPayload[formFieldKey].type === 'enum' &&
31
- internationalWireFormPayload[formFieldKey]
32
- .is_multiple_values_allowed === true
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`, toIntlWireVerificationPayload(localData))
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 != null && payload.field_values.length > 0
8
- ? payload.field_values.map((fieldValue) => {
9
- return {
10
- code: fieldValue.code,
11
- description: fieldValue.description,
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 { toDynamicFormField, } from './internationalWireVerificationPayload';
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
- const verificationFormFields = [];
35
- Object.keys(internationalWireFormPayload).forEach((key) => {
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
  },
@@ -1,26 +1,50 @@
1
+ import { getCompanyByCompanyId } from '../../../../entity/company/companySelector';
1
2
  import { getFilesByFileIds } from '../../../../entity/file/fileSelector';
3
+ import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
2
4
  import { getFileDeleteStatusById, getFileUpdateNameStatusById, } from '../../../fileView/fileViewSelector';
5
+ import { filterVerificationFormFieldsForReadonlyView } from './internationalWireVerificationPayload';
6
+ const collectFileIdsFromLocalData = (localData) => {
7
+ const fileIds = new Set();
8
+ Object.values(localData).forEach((value) => {
9
+ if (typeof value === 'string' && value.startsWith('file_')) {
10
+ fileIds.add(value);
11
+ return;
12
+ }
13
+ if (Array.isArray(value)) {
14
+ value.forEach((item) => {
15
+ if (typeof item === 'string' && item.startsWith('file_')) {
16
+ fileIds.add(item);
17
+ }
18
+ });
19
+ }
20
+ });
21
+ return Array.from(fileIds);
22
+ };
3
23
  export const getIntlWireVerificationView = (state) => {
4
24
  const deleteFileStatusById = {};
5
25
  const updateFileStatusById = {};
6
- // field with type = file
7
- const fileField = state.internationalWireVerificationState.verificationFormFields.find((field) => field.type === 'file');
8
- let fileId;
9
- if (fileField != null) {
10
- fileId = state.internationalWireVerificationState.verificationFormLocalData[fileField.name];
11
- }
12
- if (fileId != null) {
26
+ const { verificationFormFetchState, verificationFormFields, verificationFormLocalData, verificationFormSubmitState, } = state.internationalWireVerificationState;
27
+ const fileIds = collectFileIdsFromLocalData(verificationFormLocalData);
28
+ fileIds.forEach((fileId) => {
13
29
  deleteFileStatusById[fileId] = getFileDeleteStatusById(state, fileId);
14
30
  updateFileStatusById[fileId] = getFileUpdateNameStatusById(state, fileId);
15
- }
16
- let userFiles = [];
17
- if (fileId != null) {
18
- userFiles = getFilesByFileIds(state.fileState, [fileId]);
19
- }
20
- const fetchState = state.internationalWireVerificationState.verificationFormFetchState
21
- .fetchState;
31
+ });
32
+ const userFiles = fileIds.length > 0 ? getFilesByFileIds(state.fileState, fileIds) : [];
33
+ const fetchState = verificationFormFetchState.fetchState;
34
+ const currentTenant = getCurrentTenant(state);
35
+ const company = currentTenant?.companyId != null
36
+ ? getCompanyByCompanyId(state.companyState, currentTenant.companyId)
37
+ ?.company
38
+ : undefined;
39
+ const onboardingStatusCode = company?.companyBillPayInfo?.internationalWireOnboardingStatus?.code;
40
+ const isReadonly = onboardingStatusCode != null &&
41
+ onboardingStatusCode !== 'onboarding_status_not_started';
42
+ const visibleVerificationFormFields = filterVerificationFormFieldsForReadonlyView(verificationFormFields, verificationFormLocalData, isReadonly);
22
43
  return {
23
- ...state.internationalWireVerificationState,
44
+ verificationFormFetchState,
45
+ verificationFormFields: visibleVerificationFormFields,
46
+ verificationFormLocalData,
47
+ verificationFormSubmitState,
24
48
  deleteFileStatusById,
25
49
  updateFileStatusById,
26
50
  userFiles,