@adyen/kyc-components 3.70.0-beta.0 → 3.70.0
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/dist/{AU-DBnla6IS.js → AU-CaovX9P8.js} +4 -5
- package/dist/{AcceptTermsOfServiceComponent-DGnbaEif.js → AcceptTermsOfServiceComponent-D-HcDOBq.js} +200 -13
- package/dist/{AccountSetupRejected-BUjkuj8y.js → AccountSetupRejected-voqgiesN.js} +3 -3
- package/dist/{BE-By7sRfJq.js → BE-H45zzgu4.js} +3 -2
- package/dist/{BR-CG-ZSQQz.js → BR-Dmkd5VjU.js} +5 -5
- package/dist/BusinessDetailsDropin-CnGwMWvN.js +2406 -0
- package/dist/{BusinessTypeSelection-DqYdtKWT.js → BusinessTypeSelection-DQr-2_Iq.js} +31 -30
- package/dist/{CH-DNjTl_X_.js → CH-DVyjmrDH.js} +4 -2
- package/dist/{CXEL7IU7-D4uuriQj.js → CXEL7IU7-Do0b5BzU.js} +3 -3
- package/dist/{CZ-DDucwl8A.js → CZ-1E7Zx2il.js} +3 -4
- package/dist/CreateIndividualComponent-BuBNDvhx.js +7204 -0
- package/dist/{CustomerSupport-Dt_GbO2W.js → CustomerSupport-BJrkWmYp.js} +4 -4
- package/dist/{DE-LKZHA8bh.js → DE-D7HKgI77.js} +6 -5
- package/dist/{DK-moHaAY_C.js → DK-x6M9-ek-.js} +2 -4
- package/dist/{DebugModal-DqSAxc2y.js → DebugModal-DdFbk-rz.js} +11 -10
- package/dist/{DecisionMakers-DCP-NbPE.js → DecisionMakers-DghodKJR.js} +5 -5
- package/dist/{ES-BOW3pjTD.js → ES-CeohntGo.js} +6 -7
- package/dist/{EmbedShell-D1F1J3bv.js → EmbedShell-BaZnwexg.js} +5 -6
- package/dist/{EventEmitter-B5nDiK-t.js → EventEmitter-Cfyz1mmg.js} +2742 -3396
- package/dist/{FI-gB1Mh_9c.js → FI-BOex4MFx.js} +3 -5
- package/dist/{FR-iSfxCiGj.js → FR-CAxkckai.js} +4 -4
- package/dist/{GB-UYrtNfT0.js → GB-DUnW-a4M.js} +2 -4
- package/dist/{HASRA6WW-yCLwR-7b.js → HASRA6WW-CLlxPThM.js} +2 -2
- package/dist/{HK-BsLgqwJt.js → HK-eKVHN8Vg.js} +4 -4
- package/dist/{HR-BOrmO4s8.js → HR-BHhcnUGU.js} +3 -3
- package/dist/{HU-DSPD5z5O.js → HU-hfSSMbei.js} +1 -4
- package/dist/{I3HPI4QX-DmhzJNXt.js → I3HPI4QX-BW3ApIxs.js} +3 -3
- package/dist/{IE-BNxtcUkX.js → IE-BN3Eiv5M.js} +2 -2
- package/dist/{IT-CjMPVtH8.js → IT-CBt6Os6J.js} +4 -7
- package/dist/{Introduction-Dhm3WEef.js → Introduction-C8dJNT23.js} +5 -3
- package/dist/{LT-CUUN_JaO.js → LT-Dkevn83h.js} +2 -4
- package/dist/{NL-C3ArXgfX.js → NL-zm__7LWV.js} +3 -3
- package/dist/{NO-yBcMewGZ.js → NO-BAcMdKUJ.js} +5 -4
- package/dist/NZ-DDRknBQk.js +20 -0
- package/dist/{PL-DGMOmdSy.js → PL-D6_6gquq.js} +6 -5
- package/dist/{PT-D3NkDIsX.js → PT-C2dln191.js} +3 -3
- package/dist/{RO-Bo0cNUJf.js → RO-C_utD--1.js} +2 -4
- package/dist/{Review-B5Drv-UX.js → Review-DbvMjmRe.js} +3 -3
- package/dist/{SE-W4QBeQtP.js → SE-BqGOP1F1.js} +2 -4
- package/dist/{SI-DoClLcmM.js → SI-DBADzvYO.js} +3 -6
- package/dist/{SK-DmiByqvu.js → SK-DamCBYsZ.js} +2 -4
- package/dist/{SingpassSelection-Djfz5Puu.js → SingpassSelection-CJRAISeY.js} +2 -2
- package/dist/SourceOfFunds.module-BhujhW0d.js +132 -0
- package/dist/SourceOfFundsDropin-NxYXl3NE.js +3041 -0
- package/dist/{listToRecord-BwWy8lby.js → TaskItemStatus-ChW10MdE.js} +3 -11
- package/dist/{TaxReportingDropin-CpStwino.js → TaxReportingDropin-_MxQClQd.js} +27 -45
- package/dist/TrustDropin-BcxdDqKa.js +706 -0
- package/dist/adyen-kyc-components.js +1 -1
- package/dist/adyenConfig.js +3 -3
- package/dist/core-BwyfkHN1.js +8426 -0
- package/dist/{css-CWOdPM3V.js → css-CcrdHRiR.js} +2 -2
- package/dist/en-US-QbdqemZi.js +202 -0
- package/dist/formatCurrency-CMOSdJMB.js +29 -0
- package/dist/individual.js +8 -6
- package/dist/ja-JP-DU7yCJYq.js +202 -0
- package/dist/{json-B7P51psT.js → json-jBhgszKy.js} +2 -2
- package/dist/listToRecord-CO3M1Q74.js +19 -0
- package/dist/{plaintext-C3KsPoAZ.js → plaintext-RpKLxlRt.js} +2 -2
- package/dist/style.css +1019 -945
- package/dist/styles-CLV89_hH.js +1014 -940
- package/dist/terms-of-service.js +8 -6
- package/dist/toCapitalized-Bq7laD0b.js +13 -0
- package/dist/types/api/configurations/useVersionConfiguration.d.ts +0 -5
- package/dist/types/api/legalEntity/useLegalEntity.d.ts +9 -3
- package/dist/types/api/queryKeys.d.ts +3 -1
- package/dist/types/api/uiAnalytics/useAnalyticsSession.d.ts +5 -4
- package/dist/types/components/BankAccount/forms/PayoutAccount/payoutAccountFormat.d.ts +2 -0
- package/dist/types/components/BankAccount/mapping/payoutKeyMappings.d.ts +1 -1
- package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/PayoutDetailsDropin.d.ts +1 -1
- package/dist/types/components/Business/tasks/BusinessDetailsDropin/types.d.ts +2 -0
- package/dist/types/components/EFP/tasks/SourceOfFundsDropin/types.d.ts +2 -0
- package/dist/types/components/EFP/tasks/TaxReportingDropin/types.d.ts +1 -0
- package/dist/types/components/EmbeddedDropins/OnboardingDropinComponent/DropinComposer/types.d.ts +0 -3
- package/dist/types/components/Individual/forms/Individual/IdVerification/idVerificationProviderId.d.ts +1 -0
- package/dist/types/components/Individual/forms/Individual/IndividualOuter.d.ts +26 -0
- package/dist/types/components/Individual/forms/Individual/types.d.ts +3 -2
- package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/IdVerificationMethod.d.ts +1 -1
- package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/IdVerificationMethod.types.d.ts +3 -0
- package/dist/types/components/Individual/forms/IndividualOnfido/IndividualOnfido.types.d.ts +4 -2
- package/dist/types/components/Individual/helpers/isOnfidoAutofillFlowEnabled.d.ts +4 -0
- package/dist/types/components/Individual/helpers/shouldShowMotionCapture.d.ts +2 -3
- package/dist/types/components/Individual/tasks/IndividualDropin/IndividualDropin.d.ts +1 -1
- package/dist/types/components/Individual/tasks/IndividualOnfidoDropin/IndividualOnfidoDropin.d.ts +1 -1
- package/dist/types/components/Shared/AllowedCountryGate/AllowedCountryGate.d.ts +7 -0
- package/dist/types/components/Shared/FormFlow/FormFlow.d.ts +3 -0
- package/dist/types/components/Shared/FormFlow/FormFlow.types.d.ts +23 -0
- package/dist/types/components/Shared/FormNavigation/FormNavigation.d.ts +1 -0
- package/dist/types/components/Shared/FormNavigation/FormNavigationItem.d.ts +1 -0
- package/dist/types/components/Shared/FormWrapper/FormWrapper.d.ts +1 -0
- package/dist/types/components/Shared/fields/IdFieldTypeSelector/countryIdNumberTypes.d.ts +2 -2
- package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
- package/dist/types/components/Trust/forms/Trust/types.d.ts +1 -0
- package/dist/types/components/Trust/forms/TrustRegistrationDetails/types.d.ts +4 -9
- package/dist/types/components/Trust/hooks/useTrustMemberNavigation.hook.d.ts +1 -1
- package/dist/types/components/Trust/utils/trustUtil.d.ts +2 -2
- package/dist/types/components/index.d.ts +1 -2
- package/dist/types/components/ui/atoms/ProgressBar/ProgressBar.d.ts +3 -0
- package/dist/types/components/ui/atoms/ProgressBar/ProgressBar.types.d.ts +5 -0
- package/dist/types/components/ui/atoms/StepProgressIndicator/StepProgressIndicator.d.ts +1 -0
- package/dist/types/core/EmbedShell/EmbedShell.d.ts +2 -3
- package/dist/types/core/UIElement/UIElement.d.ts +1 -2
- package/dist/types/core/analytics.d.ts +1 -1
- package/dist/types/core/models/api/instant-id-verification.d.ts +1 -1
- package/dist/types/core/models/api/trust.d.ts +2 -2
- package/dist/types/core/models/errors/entity-problems.d.ts +5 -3
- package/dist/types/embeds/utils.d.ts +2 -2
- package/dist/types/hooks/useAccountHolder.d.ts +1 -1
- package/dist/types/hooks/useForm/types.d.ts +0 -1
- package/dist/types/hooks/useTrustMembers.d.ts +2 -0
- package/dist/types/hooks/useUnincorporatedPartnershipMembers.d.ts +2 -0
- package/dist/types/stores/globalStore/determineTaskIdentifiers.d.ts +1 -1
- package/dist/types/stores/globalStore/globalStore.d.ts +18 -40
- package/dist/types/utils/api/getProblemsForEntity.d.ts +5 -0
- package/dist/types/utils/api/processValidationErrors.d.ts +2 -5
- package/dist/types/utils/api/useCapabilities.d.ts +2 -0
- package/dist/types/utils/entityAssociationUtil.d.ts +2 -1
- package/dist/types/utils/entityStatusUtil.d.ts +1 -1
- package/dist/types/utils/getLegalEntityCountry.d.ts +2 -2
- package/dist/types/utils/signals/useSignalValue.d.ts +40 -0
- package/dist/utils-BI1ZfPqr.js +228 -0
- package/dist/{utils-Do7EwrWz.js → utils-C6fwKsVX.js} +7 -4
- package/dist/{yaml-Cv3Lis4l.js → yaml-BtUk5udq.js} +2 -2
- package/package.json +2 -4
- package/dist/CreateIndividualComponent-DArsdfFf.js +0 -3697
- package/dist/core-BY7J00UO.js +0 -18119
- package/dist/types/components/Individual/forms/Individual/IndividualExperimentWrapper.d.ts +0 -3
- package/dist/types/components/Individual/tasks/IndividualDropin/mandatoryFields.d.ts +0 -5
- package/dist/types/components/Individual/tasks/IndividualOnfidoDropin/mandatoryFields.d.ts +0 -5
- package/dist/types/context/CoreContext/CoreContext.d.ts +0 -17
- package/dist/types/context/CoreContext/CoreProvider.d.ts +0 -7
- package/dist/types/context/CoreContext/useCoreContext.d.ts +0 -2
- package/dist/types/core/models/api/trust-types-value.d.ts +0 -21
|
@@ -0,0 +1,2406 @@
|
|
|
1
|
+
;
|
|
2
|
+
{
|
|
3
|
+
try {
|
|
4
|
+
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
5
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "1f165b67-5566-4808-937a-e5cdce16972a", e._sentryDebugIdIdentifier = "sentry-dbid-1f165b67-5566-4808-937a-e5cdce16972a");
|
|
6
|
+
} catch (e) {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
;
|
|
10
|
+
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
11
|
+
import { useState, useCallback, useRef, useEffect, useMemo } from "preact/hooks";
|
|
12
|
+
import { u as useApiContext, c as useMutation, h as httpPost, e as useI18nContext, dj as MemoizedDocumentUpload, dt as List, C as CountryCodes, af as CompanyTypesValue, bl as useGlobalData, du as getForms, T as TaskTypes, dv as BasicInformation, br as getFormProps, dw as CompanyStructure, dx as AdditionalInformation, dy as MemoizedConstitutionalDocument, O as LegalEntityType, dz as FinancialInformation, dA as StateCodesUS, b3 as objectsDeepEqual, a3 as createLogger, a2 as entriesOf, bS as businessDetailsComponentsKeyMapping, dB as solePropBusinessDetailsKeyMapping, dC as operationalAddressIsSameIds, dD as COUNTRIES_USING_COMPANY_SEARCH, dE as FIELDS_NEEDED_FOR_COMPANY_SEARCH, q as keysOf, bt as isUndefinedOrNull, r as summaryItem, dF as solePropBusinessDetailsApiKeyMapping, bN as businessDetailsApiKeyMapping, d4 as isEmpty, dG as COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT, G as datasetUtilities, cF as mapAddressLabels, dH as companyTypeMetadata, K as isEmpty$1, cE as filterOutUnwantedAssociationsIfRootLE, dI as documentFormsIds, ay as resolveFieldMetadata, dJ as defaultFieldMetadata, dK as inferCompanyRegistrationNumberType, dL as getCompanyRegistrationNumberOptions, dM as defaultFieldConfig, ck as defaultFieldMetadata$1, dN as countryToTaxInfoTypeMap, cl as defaultFieldConfig$1, dO as getKeyForField, b9 as drop, aR as getOwnEntityAssociations, cK as doArraysMatch, ag as useAccountHolder, t as useToastContext, f as useAnalyticsContext, g as useExperimentsContext, v as useSettingsContext, z as useStateContext, E as SettingNames, dP as setIsBankAccountRequestedForOrganization, bq as getAssociatedLeAnalyticsPayload, A as getCapabilityProblems, dQ as rules, a1 as Confirm, dR as solePropBusinessDetailsDocumentMapping, dS as businessDetailsDocumentMapping } from "./EventEmitter-Cfyz1mmg.js";
|
|
13
|
+
import { B as formatObject, g as getDocument, m as mapExistingFile, a as getPageName, c as createDocumentRequest, s as augmentWithCountryConfigs, E as composePerScenarioFormConfigurations, D as getProp, k as isValidationError, p as processValidationErrors, q as isMaintenanceModeError, v as getFileExtention, d as documentApiUtils, u as useScenarioConfiguration, e as getPropsFromConfigurations, M as getFieldsWithExistingData, h as getRequiredForms, i as addValidityToForms, y as useCreateLegalEntity, z as useUpdateLegalEntity, j as useFormComposer, t as trackNavigation } from "./CreateIndividualComponent-BuBNDvhx.js";
|
|
14
|
+
import { m as mapFinancialReportsToFinancialInformation, d as mapFinancialInformationToFinancialReport, h as hasDataChanged, F as FormWrapper } from "./core-BwyfkHN1.js";
|
|
15
|
+
import { o as organizationTypesToSkipCompanyStructureForm } from "./utils-BI1ZfPqr.js";
|
|
16
|
+
import cx from "classnames";
|
|
17
|
+
import { f as formatCurrency } from "./formatCurrency-CMOSdJMB.js";
|
|
18
|
+
const clearCompanyData = async (legalEntityId, baseUrl) => {
|
|
19
|
+
return httpPost({
|
|
20
|
+
baseUrl,
|
|
21
|
+
path: `legalEntities/${legalEntityId}/companyDataset/clearCompanyData`
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const useClearCompanyData = (options) => {
|
|
25
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
26
|
+
return useMutation({
|
|
27
|
+
mutationFn: () => {
|
|
28
|
+
return clearCompanyData(rootLegalEntityId.value, baseUrl.value);
|
|
29
|
+
},
|
|
30
|
+
retry: 0,
|
|
31
|
+
...options
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const getCompanyDataset = async (rootLegalEntityId, baseUrl, data) => {
|
|
35
|
+
return httpPost(
|
|
36
|
+
{
|
|
37
|
+
baseUrl,
|
|
38
|
+
path: `legalEntities/${rootLegalEntityId}/companyDataset`
|
|
39
|
+
},
|
|
40
|
+
data
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
const useCompanyDataset = (options) => {
|
|
44
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
45
|
+
return useMutation({
|
|
46
|
+
mutationFn: (payload) => {
|
|
47
|
+
return getCompanyDataset(rootLegalEntityId.value, baseUrl.value, payload);
|
|
48
|
+
},
|
|
49
|
+
retry: 0,
|
|
50
|
+
...options
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const refreshCompanyDataset = async (rootLegalEntityId, baseUrl, data) => {
|
|
54
|
+
return httpPost(
|
|
55
|
+
{
|
|
56
|
+
baseUrl,
|
|
57
|
+
path: `legalEntities/${rootLegalEntityId}/companyDataset/refreshed`
|
|
58
|
+
},
|
|
59
|
+
data
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
const useRefreshCompanyDataset = (options) => {
|
|
63
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
64
|
+
return useMutation({
|
|
65
|
+
mutationFn: (payload) => {
|
|
66
|
+
return refreshCompanyDataset(rootLegalEntityId.value, baseUrl.value, payload);
|
|
67
|
+
},
|
|
68
|
+
retry: 0,
|
|
69
|
+
...options
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const companyDeepSearch = async (rootLegalEntityId, baseUrl, data) => {
|
|
73
|
+
return httpPost(
|
|
74
|
+
{
|
|
75
|
+
baseUrl,
|
|
76
|
+
path: `legalEntities/${rootLegalEntityId}/companySearch/deep`
|
|
77
|
+
},
|
|
78
|
+
data
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
const useCompanyDeepSearch = (options) => {
|
|
82
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
83
|
+
return useMutation({
|
|
84
|
+
mutationFn: (payload) => {
|
|
85
|
+
return companyDeepSearch(rootLegalEntityId.value, baseUrl.value, payload);
|
|
86
|
+
},
|
|
87
|
+
retry: 0,
|
|
88
|
+
...options
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const companyIndexSearch = async (rootLegalEntityId, baseUrl, data) => {
|
|
92
|
+
return httpPost(
|
|
93
|
+
{
|
|
94
|
+
baseUrl,
|
|
95
|
+
path: `legalEntities/${rootLegalEntityId}/companySearch`
|
|
96
|
+
},
|
|
97
|
+
data
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
const useCompanyIndexSearch = (options) => {
|
|
101
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
102
|
+
return useMutation({
|
|
103
|
+
mutationFn: (payload) => {
|
|
104
|
+
return companyIndexSearch(rootLegalEntityId.value, baseUrl.value, payload);
|
|
105
|
+
},
|
|
106
|
+
retry: 0,
|
|
107
|
+
...options
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const companyRegistrationNumberDeepSearch = async (rootLegalEntityId, baseUrl, data) => {
|
|
111
|
+
return httpPost(
|
|
112
|
+
{
|
|
113
|
+
baseUrl,
|
|
114
|
+
path: `legalEntities/${rootLegalEntityId}/companySearch/deepSearchByRegistrationNumber`
|
|
115
|
+
},
|
|
116
|
+
data
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
const useCompanyRegistrationNumberDeepSearch = (options) => {
|
|
120
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
121
|
+
return useMutation({
|
|
122
|
+
mutationFn: (payload) => {
|
|
123
|
+
return companyRegistrationNumberDeepSearch(rootLegalEntityId.value, baseUrl.value, payload);
|
|
124
|
+
},
|
|
125
|
+
retry: 0,
|
|
126
|
+
...options
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const companyRegistrationNumberIndexSearch = async (rootLegalEntityId, baseUrl, data) => {
|
|
130
|
+
return httpPost(
|
|
131
|
+
{
|
|
132
|
+
baseUrl,
|
|
133
|
+
path: `legalEntities/${rootLegalEntityId}/companySearch/searchByRegistrationNumber`
|
|
134
|
+
},
|
|
135
|
+
data
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
const useCompanyRegistrationNumberIndexSearch = (options) => {
|
|
139
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
140
|
+
return useMutation({
|
|
141
|
+
mutationFn: (payload) => {
|
|
142
|
+
return companyRegistrationNumberIndexSearch(rootLegalEntityId.value, baseUrl.value, payload);
|
|
143
|
+
},
|
|
144
|
+
retry: 0,
|
|
145
|
+
...options
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const verifyTin = async (legalEntityId, baseUrl, data) => {
|
|
149
|
+
return httpPost(
|
|
150
|
+
{
|
|
151
|
+
baseUrl,
|
|
152
|
+
path: `legalEntities/${legalEntityId}/verifyTin`
|
|
153
|
+
},
|
|
154
|
+
data
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
const useVerifyTin = (options) => {
|
|
158
|
+
const { rootLegalEntityId, baseUrl } = useApiContext();
|
|
159
|
+
return useMutation({
|
|
160
|
+
mutationFn: (data) => verifyTin(rootLegalEntityId.value, baseUrl.value, data),
|
|
161
|
+
...options
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const stripWhitespace = (str) => str.replace(/\s/g, "");
|
|
165
|
+
const toNormalizedString = (s) => stripWhitespace(s.toLowerCase());
|
|
166
|
+
const isNormalizedStringMatch = (s1, s2) => toNormalizedString(s1) === toNormalizedString(s2);
|
|
167
|
+
const documentTypes$1 = [
|
|
168
|
+
{ id: "Internal company document", name: "internalCompanyDocument" },
|
|
169
|
+
{ id: "Business registry statement", name: "businessRegistryStatement" }
|
|
170
|
+
];
|
|
171
|
+
const GuidanceContent$3 = () => {
|
|
172
|
+
const { i18n } = useI18nContext();
|
|
173
|
+
return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-upload-field__guidance", children: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
174
|
+
/* @__PURE__ */ jsx("strong", { children: i18n.get("documentRequirements") }),
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
List,
|
|
177
|
+
{
|
|
178
|
+
className: "adyen-kyc-u-margin-left-8",
|
|
179
|
+
items: [
|
|
180
|
+
i18n.get("includesTheDirectorsFullName"),
|
|
181
|
+
i18n.get("includesEvidenceOfTheIndividualsRole"),
|
|
182
|
+
i18n.get("issuedOrSignedByALegalRepresentative")
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }) });
|
|
187
|
+
};
|
|
188
|
+
function ProofOfDirectorDocument({
|
|
189
|
+
id,
|
|
190
|
+
country,
|
|
191
|
+
heading = "uploadYourOrganizationProofOfDirector",
|
|
192
|
+
description = "weNeedAnOfficialDocument",
|
|
193
|
+
...props
|
|
194
|
+
}) {
|
|
195
|
+
const { i18n } = useI18nContext();
|
|
196
|
+
const [selectedDocumentName, setSelectedDocumentName] = useState(documentTypes$1[0].id);
|
|
197
|
+
return /* @__PURE__ */ jsx(
|
|
198
|
+
MemoizedDocumentUpload,
|
|
199
|
+
{
|
|
200
|
+
...props,
|
|
201
|
+
id,
|
|
202
|
+
heading: i18n.get(heading),
|
|
203
|
+
description: i18n.get(description),
|
|
204
|
+
documentField: "proofOfDirector",
|
|
205
|
+
documentType: "proofOfDirector",
|
|
206
|
+
guidanceContent: /* @__PURE__ */ jsx(GuidanceContent$3, {}),
|
|
207
|
+
country,
|
|
208
|
+
documentTypeSelect: {
|
|
209
|
+
selectedType: selectedDocumentName,
|
|
210
|
+
setSelectedType: setSelectedDocumentName,
|
|
211
|
+
options: documentTypes$1
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
const documentTypes = [
|
|
217
|
+
{ id: "Trade registry document", name: "tradeRegistryDocument" },
|
|
218
|
+
{ id: "Internal company document", name: "internalCompanyDocument" }
|
|
219
|
+
];
|
|
220
|
+
const GuidanceContent$2 = () => {
|
|
221
|
+
const { i18n } = useI18nContext();
|
|
222
|
+
return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-upload-field__guidance", children: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
223
|
+
/* @__PURE__ */ jsx("strong", { children: i18n.get("documentRequirements") }),
|
|
224
|
+
/* @__PURE__ */ jsx(
|
|
225
|
+
List,
|
|
226
|
+
{
|
|
227
|
+
className: "adyen-kyc-u-margin-left-8",
|
|
228
|
+
items: [
|
|
229
|
+
i18n.get("includesTheSignatorysFullName"),
|
|
230
|
+
i18n.get("includesEvidenceOfTheIndividualsRoleSignatory"),
|
|
231
|
+
i18n.get("issuedOrSignedByALegalRepresentative")
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
] }) });
|
|
236
|
+
};
|
|
237
|
+
function ProofOfSignatoryDocument({
|
|
238
|
+
id,
|
|
239
|
+
country,
|
|
240
|
+
heading = "uploadYourOrganizationProofOfSignatory",
|
|
241
|
+
description = "weNeedAnOfficialDocumentSignatory",
|
|
242
|
+
...props
|
|
243
|
+
}) {
|
|
244
|
+
const { i18n } = useI18nContext();
|
|
245
|
+
const [selectedDocumentName, setSelectedDocumentName] = useState(documentTypes[0].id);
|
|
246
|
+
return /* @__PURE__ */ jsx(
|
|
247
|
+
MemoizedDocumentUpload,
|
|
248
|
+
{
|
|
249
|
+
...props,
|
|
250
|
+
id,
|
|
251
|
+
heading: i18n.get(heading),
|
|
252
|
+
description: i18n.get(description),
|
|
253
|
+
documentField: "proofOfSignatory",
|
|
254
|
+
documentType: "proofOfSignatory",
|
|
255
|
+
guidanceContent: /* @__PURE__ */ jsx(GuidanceContent$2, {}),
|
|
256
|
+
country,
|
|
257
|
+
documentTypeSelect: {
|
|
258
|
+
selectedType: selectedDocumentName,
|
|
259
|
+
setSelectedType: setSelectedDocumentName,
|
|
260
|
+
options: documentTypes
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
const ACCEPTED_DOCUMENTS_MAP$1 = {
|
|
266
|
+
[CountryCodes.PuertoRico]: {
|
|
267
|
+
// should exactly match CountryCodes.UnitedStates
|
|
268
|
+
[CompanyTypesValue.PRIVATE_COMPANY]: {
|
|
269
|
+
header: "acceptedDocumentsForPrivateCompanies",
|
|
270
|
+
documents: [
|
|
271
|
+
"certificateOfIncorporation",
|
|
272
|
+
"certificateOfFormation",
|
|
273
|
+
"secretaryOfStateFiling__PR"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
[CompanyTypesValue.PUBLIC_COMPANY]: {
|
|
277
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
278
|
+
documents: ["certificateOfIncorporation", "certificateOfFormation"]
|
|
279
|
+
},
|
|
280
|
+
[CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]: {
|
|
281
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
282
|
+
documents: ["certificateOfIncorporation", "certificateOfFormation"]
|
|
283
|
+
},
|
|
284
|
+
[CompanyTypesValue.GOVERNMENTAL_ORGANIZATION]: {
|
|
285
|
+
header: "acceptedDocumentsForGovernment",
|
|
286
|
+
documents: ["charter"]
|
|
287
|
+
},
|
|
288
|
+
[CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]: {
|
|
289
|
+
header: "acceptedDocumentsForNonProfit",
|
|
290
|
+
documents: [
|
|
291
|
+
"articlesOfIncorporation",
|
|
292
|
+
"meetingRecords",
|
|
293
|
+
"secretaryOfStateRegDoc__PR",
|
|
294
|
+
"certificateOfIncumbency"
|
|
295
|
+
]
|
|
296
|
+
},
|
|
297
|
+
[CompanyTypesValue.INCORPORATED_PARTNERSHIP]: {
|
|
298
|
+
header: "acceptedDocumentsForPartnerships",
|
|
299
|
+
documents: ["partnerShipAgreement", "secretaryOfStateFiling__PR"]
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
[CountryCodes.UnitedStates]: {
|
|
303
|
+
[CompanyTypesValue.PRIVATE_COMPANY]: {
|
|
304
|
+
header: "acceptedDocumentsForPrivateCompanies",
|
|
305
|
+
documents: ["certificateOfIncorporation", "certificateOfFormation", "secretaryOfStateFiling"]
|
|
306
|
+
},
|
|
307
|
+
[CompanyTypesValue.PUBLIC_COMPANY]: {
|
|
308
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
309
|
+
documents: ["certificateOfIncorporation", "certificateOfFormation"]
|
|
310
|
+
},
|
|
311
|
+
[CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]: {
|
|
312
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
313
|
+
documents: ["certificateOfIncorporation", "certificateOfFormation"]
|
|
314
|
+
},
|
|
315
|
+
[CompanyTypesValue.GOVERNMENTAL_ORGANIZATION]: {
|
|
316
|
+
header: "acceptedDocumentsForGovernment",
|
|
317
|
+
documents: ["charter"]
|
|
318
|
+
},
|
|
319
|
+
[CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]: {
|
|
320
|
+
header: "acceptedDocumentsForNonProfit",
|
|
321
|
+
documents: [
|
|
322
|
+
"articlesOfIncorporation",
|
|
323
|
+
"meetingRecords",
|
|
324
|
+
"secretaryOfStateRegDoc",
|
|
325
|
+
"certificateOfIncumbency"
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
[CompanyTypesValue.INCORPORATED_PARTNERSHIP]: {
|
|
329
|
+
header: "acceptedDocumentsForPartnerships",
|
|
330
|
+
documents: ["partnerShipAgreement", "secretaryOfStateFiling"]
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const GuidanceContent$1 = ({
|
|
335
|
+
country,
|
|
336
|
+
companyType
|
|
337
|
+
}) => {
|
|
338
|
+
var _a;
|
|
339
|
+
const { i18n } = useI18nContext();
|
|
340
|
+
const acceptedDocGuidance = (_a = ACCEPTED_DOCUMENTS_MAP$1[country]) == null ? void 0 : _a[companyType];
|
|
341
|
+
return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-upload-field__guidance", children: country === "US" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
342
|
+
acceptedDocGuidance && /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
343
|
+
/* @__PURE__ */ jsx("strong", { children: i18n.get(acceptedDocGuidance.header) }),
|
|
344
|
+
/* @__PURE__ */ jsx(
|
|
345
|
+
List,
|
|
346
|
+
{
|
|
347
|
+
className: "adyen-kyc-u-margin-left-8",
|
|
348
|
+
items: acceptedDocGuidance.documents.map((document) => i18n.get(document))
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
] }),
|
|
352
|
+
/* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
353
|
+
/* @__PURE__ */ jsx("strong", { children: i18n.get("documentRequirements") }),
|
|
354
|
+
/* @__PURE__ */ jsx(
|
|
355
|
+
List,
|
|
356
|
+
{
|
|
357
|
+
className: "adyen-kyc-u-margin-left-8",
|
|
358
|
+
items: [i18n.get("includesLegalCompanyName")]
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
] })
|
|
362
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
363
|
+
/* @__PURE__ */ jsxs("strong", { children: [
|
|
364
|
+
" ",
|
|
365
|
+
i18n.get("documentRequirements")
|
|
366
|
+
] }),
|
|
367
|
+
/* @__PURE__ */ jsx(
|
|
368
|
+
List,
|
|
369
|
+
{
|
|
370
|
+
className: "adyen-kyc-upload-field__requirements",
|
|
371
|
+
items: [i18n.get("documentIssuedByGovernmentAuthority")]
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
] }) });
|
|
375
|
+
};
|
|
376
|
+
function RegistrationDocument({
|
|
377
|
+
id,
|
|
378
|
+
country,
|
|
379
|
+
companyType = CompanyTypesValue.PRIVATE_COMPANY,
|
|
380
|
+
heading = "companyRegistrationDocumentFormHeading",
|
|
381
|
+
description = "companyRegistrationDocumentFormDescription",
|
|
382
|
+
...props
|
|
383
|
+
}) {
|
|
384
|
+
const { i18n } = useI18nContext();
|
|
385
|
+
return /* @__PURE__ */ jsx(
|
|
386
|
+
MemoizedDocumentUpload,
|
|
387
|
+
{
|
|
388
|
+
...props,
|
|
389
|
+
id,
|
|
390
|
+
heading: i18n.get(heading),
|
|
391
|
+
description: i18n.get(description),
|
|
392
|
+
documentField: "registrationDocument",
|
|
393
|
+
documentType: "registrationDocument",
|
|
394
|
+
guidanceContent: /* @__PURE__ */ jsx(GuidanceContent$1, { country, companyType }),
|
|
395
|
+
companyType,
|
|
396
|
+
country
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
const ACCEPTED_DOCUMENTS_MAP = {
|
|
401
|
+
[CountryCodes.PuertoRico]: {
|
|
402
|
+
// should exactly match CountryCodes.UnitedStates
|
|
403
|
+
[CompanyTypesValue.PRIVATE_COMPANY]: {
|
|
404
|
+
header: "acceptedDocumentsForPrivateCompanies",
|
|
405
|
+
documents: ["irsCP575"]
|
|
406
|
+
},
|
|
407
|
+
[CompanyTypesValue.PUBLIC_COMPANY]: {
|
|
408
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
409
|
+
documents: ["annualReport", "secForm10k"]
|
|
410
|
+
},
|
|
411
|
+
[CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]: {
|
|
412
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
413
|
+
documents: ["annualReport", "secForm10k"]
|
|
414
|
+
},
|
|
415
|
+
[CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]: {
|
|
416
|
+
header: "acceptedDocumentsForNonProfit",
|
|
417
|
+
documents: ["annualReport"]
|
|
418
|
+
},
|
|
419
|
+
[CompanyTypesValue.INCORPORATED_PARTNERSHIP]: {
|
|
420
|
+
header: "acceptedDocumentsForPartnerships",
|
|
421
|
+
documents: ["irsScheduleK1"]
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
[CountryCodes.UnitedStates]: {
|
|
425
|
+
[CompanyTypesValue.PRIVATE_COMPANY]: {
|
|
426
|
+
header: "acceptedDocumentsForPrivateCompanies",
|
|
427
|
+
documents: ["irsCP575"]
|
|
428
|
+
},
|
|
429
|
+
[CompanyTypesValue.PUBLIC_COMPANY]: {
|
|
430
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
431
|
+
documents: ["annualReport", "secForm10k"]
|
|
432
|
+
},
|
|
433
|
+
[CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]: {
|
|
434
|
+
header: "acceptedDocumentsForPublicCompanies",
|
|
435
|
+
documents: ["annualReport", "secForm10k"]
|
|
436
|
+
},
|
|
437
|
+
[CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]: {
|
|
438
|
+
header: "acceptedDocumentsForNonProfit",
|
|
439
|
+
documents: ["annualReport"]
|
|
440
|
+
},
|
|
441
|
+
[CompanyTypesValue.INCORPORATED_PARTNERSHIP]: {
|
|
442
|
+
header: "acceptedDocumentsForPartnerships",
|
|
443
|
+
documents: ["irsScheduleK1"]
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const GuidanceContent = ({
|
|
448
|
+
country,
|
|
449
|
+
companyType
|
|
450
|
+
}) => {
|
|
451
|
+
var _a;
|
|
452
|
+
const { i18n } = useI18nContext();
|
|
453
|
+
const acceptedDocGuidance = (_a = ACCEPTED_DOCUMENTS_MAP[country]) == null ? void 0 : _a[companyType];
|
|
454
|
+
return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-upload-field__guidance", children: country === "US" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
455
|
+
acceptedDocGuidance && /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
456
|
+
/* @__PURE__ */ jsx("strong", { children: i18n.get(acceptedDocGuidance.header) }),
|
|
457
|
+
/* @__PURE__ */ jsx(
|
|
458
|
+
List,
|
|
459
|
+
{
|
|
460
|
+
className: "adyen-kyc-u-margin-left-8",
|
|
461
|
+
items: acceptedDocGuidance.documents.map((document) => i18n.get(document))
|
|
462
|
+
}
|
|
463
|
+
)
|
|
464
|
+
] }),
|
|
465
|
+
/* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
466
|
+
/* @__PURE__ */ jsx("strong", { children: i18n.get("documentRequirements") }),
|
|
467
|
+
/* @__PURE__ */ jsx(
|
|
468
|
+
List,
|
|
469
|
+
{
|
|
470
|
+
className: "adyen-kyc-u-margin-left-8",
|
|
471
|
+
items: [i18n.get("includesLegalCompanyName"), i18n.get("includesEIN")]
|
|
472
|
+
}
|
|
473
|
+
)
|
|
474
|
+
] })
|
|
475
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
476
|
+
/* @__PURE__ */ jsx("div", { className: "adyen-kyc-upload-field__subtitle", children: i18n.get("documentRequirements") }),
|
|
477
|
+
/* @__PURE__ */ jsx(
|
|
478
|
+
List,
|
|
479
|
+
{
|
|
480
|
+
className: "adyen-kyc-upload-field__requirements",
|
|
481
|
+
items: [
|
|
482
|
+
i18n.get("containsNameOfCompany"),
|
|
483
|
+
i18n.get("documentShowsTaxIdOfCompany"),
|
|
484
|
+
i18n.get("issuedByTheTaxAuthority")
|
|
485
|
+
]
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
] }) });
|
|
489
|
+
};
|
|
490
|
+
function TaxDocument({
|
|
491
|
+
id,
|
|
492
|
+
country,
|
|
493
|
+
companyType = CompanyTypesValue.PRIVATE_COMPANY,
|
|
494
|
+
heading = "companyTaxDocumentFormHeading",
|
|
495
|
+
description = "companyTaxDocumentFormDescription",
|
|
496
|
+
...props
|
|
497
|
+
}) {
|
|
498
|
+
const { i18n } = useI18nContext();
|
|
499
|
+
return /* @__PURE__ */ jsx(
|
|
500
|
+
MemoizedDocumentUpload,
|
|
501
|
+
{
|
|
502
|
+
...props,
|
|
503
|
+
id,
|
|
504
|
+
heading: i18n.get(heading),
|
|
505
|
+
description: i18n.get(description),
|
|
506
|
+
documentField: "taxDocument",
|
|
507
|
+
documentType: "proofOfOrganizationTaxInfo",
|
|
508
|
+
guidanceContent: /* @__PURE__ */ jsx(GuidanceContent, { country, companyType }),
|
|
509
|
+
companyType,
|
|
510
|
+
country
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
function BusinessDetails(props) {
|
|
515
|
+
const { i18n } = useI18nContext();
|
|
516
|
+
const { companyStructure } = useGlobalData();
|
|
517
|
+
const {
|
|
518
|
+
country,
|
|
519
|
+
isTopLevelEntity,
|
|
520
|
+
activeForm,
|
|
521
|
+
showCompanyStructure,
|
|
522
|
+
showBusinessSelection,
|
|
523
|
+
setShowBusinessSelection,
|
|
524
|
+
setShowCompanyStructure,
|
|
525
|
+
searching,
|
|
526
|
+
fetching,
|
|
527
|
+
verifying,
|
|
528
|
+
resettingTrustedData,
|
|
529
|
+
searchResults,
|
|
530
|
+
invalidTin,
|
|
531
|
+
verifiedBusiness,
|
|
532
|
+
taskType,
|
|
533
|
+
resetTinVerification,
|
|
534
|
+
handleNextClick,
|
|
535
|
+
fetchBusinessData,
|
|
536
|
+
verifyTin: verifyTin2,
|
|
537
|
+
proceedToManualDataEntry
|
|
538
|
+
} = props;
|
|
539
|
+
const forms = getForms(country);
|
|
540
|
+
const formWrapperClasses = (formId) => (activeForm == null ? void 0 : activeForm.formId) !== formId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper";
|
|
541
|
+
const classNames = cx("adyen-kyc-business-details", {
|
|
542
|
+
"adyen-kyc-business-details--hide": (activeForm == null ? void 0 : activeForm.formId) === "summary"
|
|
543
|
+
});
|
|
544
|
+
const companyType = taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY ? CompanyTypesValue.SOLE_PROPRIETORSHIP : companyStructure == null ? void 0 : companyStructure.entityType;
|
|
545
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames, children: [
|
|
546
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.basicInformation.formId), children: /* @__PURE__ */ jsx(
|
|
547
|
+
BasicInformation,
|
|
548
|
+
{
|
|
549
|
+
...getFormProps(props, forms.basicInformation.formId),
|
|
550
|
+
id: forms.basicInformation.formId,
|
|
551
|
+
heading: i18n.get((activeForm == null ? void 0 : activeForm.formHeading) || forms.basicInformation.formHeading),
|
|
552
|
+
description: (activeForm == null ? void 0 : activeForm.formDescription) ? i18n.get(activeForm == null ? void 0 : activeForm.formDescription) : void 0,
|
|
553
|
+
country,
|
|
554
|
+
companyType,
|
|
555
|
+
isTopLevelEntity,
|
|
556
|
+
showBusinessSelection,
|
|
557
|
+
showCompanyStructure,
|
|
558
|
+
isActiveForm: (activeForm == null ? void 0 : activeForm.formId) === forms.basicInformation.formId,
|
|
559
|
+
searching,
|
|
560
|
+
fetching,
|
|
561
|
+
verifying,
|
|
562
|
+
resettingTrustedData,
|
|
563
|
+
fetchBusinessData,
|
|
564
|
+
verifyTin: verifyTin2,
|
|
565
|
+
proceedToManualDataEntry,
|
|
566
|
+
searchResults,
|
|
567
|
+
invalidTin,
|
|
568
|
+
verifiedBusiness,
|
|
569
|
+
setShowBusinessSelection,
|
|
570
|
+
setShowCompanyStructure,
|
|
571
|
+
handleNextClick,
|
|
572
|
+
resetTinVerification,
|
|
573
|
+
disableCountry: taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY
|
|
574
|
+
}
|
|
575
|
+
) }),
|
|
576
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyStructure.formId), children: /* @__PURE__ */ jsx(
|
|
577
|
+
CompanyStructure,
|
|
578
|
+
{
|
|
579
|
+
...getFormProps(props, forms.companyStructure.formId),
|
|
580
|
+
id: forms.companyStructure.formId,
|
|
581
|
+
heading: i18n.get((activeForm == null ? void 0 : activeForm.formHeading) ?? forms.companyStructure.formHeading),
|
|
582
|
+
description: i18n.get(
|
|
583
|
+
(activeForm == null ? void 0 : activeForm.formDescription) ?? forms.companyStructure.formDescription
|
|
584
|
+
),
|
|
585
|
+
country,
|
|
586
|
+
verifiedBusiness,
|
|
587
|
+
showCompanyStructure
|
|
588
|
+
}
|
|
589
|
+
) }),
|
|
590
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.additionalInformation.formId), children: /* @__PURE__ */ jsx(
|
|
591
|
+
AdditionalInformation,
|
|
592
|
+
{
|
|
593
|
+
...getFormProps(props, forms.additionalInformation.formId),
|
|
594
|
+
id: forms.additionalInformation.formId,
|
|
595
|
+
heading: i18n.get((activeForm == null ? void 0 : activeForm.formHeading) ?? forms.additionalInformation.formHeading),
|
|
596
|
+
country,
|
|
597
|
+
companyType,
|
|
598
|
+
verifiedBusiness,
|
|
599
|
+
showCompanyStructure
|
|
600
|
+
}
|
|
601
|
+
) }),
|
|
602
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyRegistrationDocument.formId), children: /* @__PURE__ */ jsx(
|
|
603
|
+
RegistrationDocument,
|
|
604
|
+
{
|
|
605
|
+
...getFormProps(props, forms.companyRegistrationDocument.formId),
|
|
606
|
+
id: forms.companyRegistrationDocument.formId,
|
|
607
|
+
heading: forms.companyRegistrationDocument.formHeading,
|
|
608
|
+
description: forms.companyRegistrationDocument.formDescription,
|
|
609
|
+
country,
|
|
610
|
+
companyType
|
|
611
|
+
}
|
|
612
|
+
) }),
|
|
613
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyTaxDocument.formId), children: country === "US" ? /* @__PURE__ */ jsx(
|
|
614
|
+
TaxDocument,
|
|
615
|
+
{
|
|
616
|
+
...getFormProps(props, forms.companyTaxDocument.formId),
|
|
617
|
+
id: forms.companyTaxDocument.formId,
|
|
618
|
+
heading: forms.companyTaxDocument.formHeading,
|
|
619
|
+
description: forms.companyTaxDocument.formDescription,
|
|
620
|
+
country,
|
|
621
|
+
companyType
|
|
622
|
+
}
|
|
623
|
+
) : /* @__PURE__ */ jsx(
|
|
624
|
+
MemoizedDocumentUpload,
|
|
625
|
+
{
|
|
626
|
+
...getFormProps(props, forms.companyTaxDocument.formId),
|
|
627
|
+
id: forms.companyTaxDocument.formId,
|
|
628
|
+
heading: i18n.get(forms.companyTaxDocument.formHeading),
|
|
629
|
+
description: i18n.get(forms.companyTaxDocument.formDescription),
|
|
630
|
+
documentField: "taxDocument",
|
|
631
|
+
documentType: "vatDocument",
|
|
632
|
+
guidanceContent: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
|
|
633
|
+
/* @__PURE__ */ jsxs("div", { className: "adyen-kyc-upload-field__subtitle", children: [
|
|
634
|
+
" ",
|
|
635
|
+
i18n.get("requirements")
|
|
636
|
+
] }),
|
|
637
|
+
/* @__PURE__ */ jsx(
|
|
638
|
+
List,
|
|
639
|
+
{
|
|
640
|
+
className: "adyen-kyc-upload-field__requirements",
|
|
641
|
+
items: [
|
|
642
|
+
i18n.get("containsNameOfCompany"),
|
|
643
|
+
i18n.get("documentShowsTaxIdOfCompany"),
|
|
644
|
+
i18n.get("issuedByTheTaxAuthority")
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
)
|
|
648
|
+
] })
|
|
649
|
+
}
|
|
650
|
+
) }),
|
|
651
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyProofOfDirectorDocument.formId), children: /* @__PURE__ */ jsx(
|
|
652
|
+
ProofOfDirectorDocument,
|
|
653
|
+
{
|
|
654
|
+
...getFormProps(props, forms.companyProofOfDirectorDocument.formId),
|
|
655
|
+
id: forms.companyProofOfDirectorDocument.formId,
|
|
656
|
+
heading: forms.companyProofOfDirectorDocument.formHeading,
|
|
657
|
+
description: forms.companyProofOfDirectorDocument.formDescription,
|
|
658
|
+
country
|
|
659
|
+
}
|
|
660
|
+
) }),
|
|
661
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyProofOfSignatoryDocument.formId), children: /* @__PURE__ */ jsx(
|
|
662
|
+
ProofOfSignatoryDocument,
|
|
663
|
+
{
|
|
664
|
+
...getFormProps(props, forms.companyProofOfSignatoryDocument.formId),
|
|
665
|
+
id: forms.companyProofOfSignatoryDocument.formId,
|
|
666
|
+
heading: forms.companyProofOfSignatoryDocument.formHeading,
|
|
667
|
+
description: forms.companyProofOfSignatoryDocument.formDescription,
|
|
668
|
+
country
|
|
669
|
+
}
|
|
670
|
+
) }),
|
|
671
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyConstitutionalDocument.formId), children: /* @__PURE__ */ jsx(
|
|
672
|
+
MemoizedConstitutionalDocument,
|
|
673
|
+
{
|
|
674
|
+
...getFormProps(props, forms.companyConstitutionalDocument.formId),
|
|
675
|
+
id: forms.companyConstitutionalDocument.formId,
|
|
676
|
+
legalEntityType: LegalEntityType.SOLE_PROPRIETORSHIP,
|
|
677
|
+
country
|
|
678
|
+
}
|
|
679
|
+
) }),
|
|
680
|
+
/* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyFinancialInformation.formId), children: /* @__PURE__ */ jsx(
|
|
681
|
+
FinancialInformation,
|
|
682
|
+
{
|
|
683
|
+
...getFormProps(props, forms.companyFinancialInformation.formId),
|
|
684
|
+
heading: i18n.get("financialInformation"),
|
|
685
|
+
id: forms.companyFinancialInformation.formId,
|
|
686
|
+
country
|
|
687
|
+
}
|
|
688
|
+
) })
|
|
689
|
+
] });
|
|
690
|
+
}
|
|
691
|
+
const uniqBy = (arr, predicate) => {
|
|
692
|
+
if (!Array.isArray(arr)) {
|
|
693
|
+
return [];
|
|
694
|
+
}
|
|
695
|
+
const cb = (o) => o[predicate];
|
|
696
|
+
const pickedObjects = arr.filter((item) => item).reduce((map, item) => {
|
|
697
|
+
const key = cb(item);
|
|
698
|
+
if (!key) {
|
|
699
|
+
return map;
|
|
700
|
+
}
|
|
701
|
+
return map.has(key) ? map : map.set(key, item);
|
|
702
|
+
}, /* @__PURE__ */ new Map()).values();
|
|
703
|
+
return [...pickedObjects];
|
|
704
|
+
};
|
|
705
|
+
const LOW_RISK_COMPANY_DATA_COMPLIANCE_WINDOW = 1577664e5;
|
|
706
|
+
const KNOWN_BROKEN_PRIMARY_SOURCE_CONNECTIONS = [
|
|
707
|
+
StateCodesUS.Arkansas,
|
|
708
|
+
StateCodesUS.Connecticut,
|
|
709
|
+
StateCodesUS.Georgia,
|
|
710
|
+
StateCodesUS.Hawaii,
|
|
711
|
+
StateCodesUS.Indiana,
|
|
712
|
+
StateCodesUS.Kentucky,
|
|
713
|
+
StateCodesUS.Maryland,
|
|
714
|
+
StateCodesUS.Minnesota,
|
|
715
|
+
StateCodesUS.Missouri,
|
|
716
|
+
StateCodesUS.Montana,
|
|
717
|
+
StateCodesUS.NewHampshire,
|
|
718
|
+
StateCodesUS.NewMexico,
|
|
719
|
+
StateCodesUS.SouthCarolina,
|
|
720
|
+
StateCodesUS.Utah,
|
|
721
|
+
StateCodesUS.Vermont,
|
|
722
|
+
StateCodesUS.Wisconsin,
|
|
723
|
+
StateCodesUS.Wyoming
|
|
724
|
+
];
|
|
725
|
+
const KNOWN_DISALLOWED_INDEX_DATASET_STATES = [
|
|
726
|
+
StateCodesUS.California,
|
|
727
|
+
StateCodesUS.Florida,
|
|
728
|
+
StateCodesUS.Illinois,
|
|
729
|
+
StateCodesUS.Texas
|
|
730
|
+
];
|
|
731
|
+
const logger = createLogger();
|
|
732
|
+
function useBusinessData({
|
|
733
|
+
companyIndexSearch: companyIndexSearch2,
|
|
734
|
+
companyDeepSearch: companyDeepSearch2,
|
|
735
|
+
companyRegistrationNumberIndexSearch: companyRegistrationNumberIndexSearch2,
|
|
736
|
+
companyRegistrationNumberDeepSearch: companyRegistrationNumberDeepSearch2,
|
|
737
|
+
getCompanyDataset: getCompanyDataset2,
|
|
738
|
+
refreshCompanyDataset: refreshCompanyDataset2,
|
|
739
|
+
verifyTin: verifyTin2,
|
|
740
|
+
clearCompanyData: clearCompanyData2
|
|
741
|
+
}) {
|
|
742
|
+
const [searching, setSearching] = useState("idle");
|
|
743
|
+
const [fetching, setFetching] = useState("idle");
|
|
744
|
+
const [verifying, setVerifying] = useState("idle");
|
|
745
|
+
const [resettingTrustedData, setResettingTrustedData] = useState("idle");
|
|
746
|
+
const [searchResults, setSearchResults] = useState();
|
|
747
|
+
const [cachedSearch, setCachedSearch] = useState();
|
|
748
|
+
const [verifiedBusiness, setVerifiedBusiness] = useState();
|
|
749
|
+
const [invalidTin, setInvalidTin] = useState(false);
|
|
750
|
+
const primarySourceSearch = async (data, indexSearch, deepSearch) => {
|
|
751
|
+
let response;
|
|
752
|
+
try {
|
|
753
|
+
response = await deepSearch({
|
|
754
|
+
...data,
|
|
755
|
+
limit: data.limit ?? 15
|
|
756
|
+
});
|
|
757
|
+
} catch {
|
|
758
|
+
response = await indexSearch({
|
|
759
|
+
...data,
|
|
760
|
+
limit: data.limit ?? 15
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
return response;
|
|
764
|
+
};
|
|
765
|
+
const searchByRegistrationNumber = useCallback(
|
|
766
|
+
async (data) => {
|
|
767
|
+
const requestPayload = {
|
|
768
|
+
text: data.registrationNumber || "",
|
|
769
|
+
country: data.country,
|
|
770
|
+
state: data.state,
|
|
771
|
+
limit: data.limit ?? 15
|
|
772
|
+
};
|
|
773
|
+
return KNOWN_BROKEN_PRIMARY_SOURCE_CONNECTIONS.includes(data.state) ? await companyRegistrationNumberIndexSearch2(requestPayload) : await primarySourceSearch(
|
|
774
|
+
requestPayload,
|
|
775
|
+
companyRegistrationNumberIndexSearch2,
|
|
776
|
+
companyRegistrationNumberDeepSearch2
|
|
777
|
+
);
|
|
778
|
+
},
|
|
779
|
+
[companyRegistrationNumberDeepSearch2, companyRegistrationNumberIndexSearch2]
|
|
780
|
+
);
|
|
781
|
+
const searchByCompanyName = useCallback(
|
|
782
|
+
async (data) => {
|
|
783
|
+
return KNOWN_BROKEN_PRIMARY_SOURCE_CONNECTIONS.includes(data.state) ? await companyIndexSearch2({
|
|
784
|
+
text: data.name,
|
|
785
|
+
country: data.country,
|
|
786
|
+
state: data.state,
|
|
787
|
+
limit: data.limit ?? 15
|
|
788
|
+
}) : await primarySourceSearch(
|
|
789
|
+
{
|
|
790
|
+
text: data.name,
|
|
791
|
+
country: data.country,
|
|
792
|
+
state: data.state,
|
|
793
|
+
limit: data.limit ?? 15
|
|
794
|
+
},
|
|
795
|
+
companyIndexSearch2,
|
|
796
|
+
companyDeepSearch2
|
|
797
|
+
);
|
|
798
|
+
},
|
|
799
|
+
[companyDeepSearch2, companyIndexSearch2]
|
|
800
|
+
);
|
|
801
|
+
const searchForBusiness = useCallback(
|
|
802
|
+
async (data) => {
|
|
803
|
+
var _a;
|
|
804
|
+
if (searchResults && objectsDeepEqual(cachedSearch, data)) return searchResults;
|
|
805
|
+
try {
|
|
806
|
+
setSearching("loading");
|
|
807
|
+
if (data.registrationNumber) {
|
|
808
|
+
const registrationNumberResponse = await searchByRegistrationNumber(data);
|
|
809
|
+
if ((_a = registrationNumberResponse == null ? void 0 : registrationNumberResponse.results) == null ? void 0 : _a.length) {
|
|
810
|
+
const uniqueRegistrationNumberResponse = uniqBy(
|
|
811
|
+
registrationNumberResponse.results,
|
|
812
|
+
"id"
|
|
813
|
+
);
|
|
814
|
+
setSearchResults(uniqueRegistrationNumberResponse);
|
|
815
|
+
return uniqueRegistrationNumberResponse;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
const response = await searchByCompanyName(data);
|
|
819
|
+
const uniqueResponseResults = uniqBy(response == null ? void 0 : response.results, "id");
|
|
820
|
+
setSearchResults(uniqueResponseResults || []);
|
|
821
|
+
return (response == null ? void 0 : response.results) || [];
|
|
822
|
+
} catch (e) {
|
|
823
|
+
setSearching("error");
|
|
824
|
+
logger.error(e);
|
|
825
|
+
} finally {
|
|
826
|
+
setCachedSearch(data);
|
|
827
|
+
setSearching((prevState) => prevState !== "error" ? "loaded" : prevState);
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
[searchResults, cachedSearch, searchByCompanyName, searchByRegistrationNumber]
|
|
831
|
+
);
|
|
832
|
+
const fetchBusinessData = useCallback(
|
|
833
|
+
async (company, state) => {
|
|
834
|
+
const date = (/* @__PURE__ */ new Date()).toDateString();
|
|
835
|
+
const isDataCompliant = company.lastUpdate ? Date.parse(date) - Date.parse(company.lastUpdate) < LOW_RISK_COMPANY_DATA_COMPLIANCE_WINDOW : false;
|
|
836
|
+
try {
|
|
837
|
+
setFetching("loading");
|
|
838
|
+
setVerifying("idle");
|
|
839
|
+
setInvalidTin(false);
|
|
840
|
+
if (state) {
|
|
841
|
+
return isDataCompliant && !KNOWN_DISALLOWED_INDEX_DATASET_STATES.includes(state) ? await getCompanyDataset2({
|
|
842
|
+
companyId: company.id,
|
|
843
|
+
country: "US",
|
|
844
|
+
state
|
|
845
|
+
}) : await refreshCompanyDataset2({
|
|
846
|
+
companyId: company.id,
|
|
847
|
+
country: "US",
|
|
848
|
+
state
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
return isDataCompliant ? await getCompanyDataset2({
|
|
852
|
+
companyId: company.id,
|
|
853
|
+
country: "US"
|
|
854
|
+
}) : await refreshCompanyDataset2({
|
|
855
|
+
companyId: company.id,
|
|
856
|
+
country: "US"
|
|
857
|
+
});
|
|
858
|
+
} catch (e) {
|
|
859
|
+
setFetching("error");
|
|
860
|
+
logger.error(e);
|
|
861
|
+
} finally {
|
|
862
|
+
setFetching((prevState) => prevState !== "error" ? "loaded" : prevState);
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
[getCompanyDataset2, refreshCompanyDataset2]
|
|
866
|
+
);
|
|
867
|
+
const doTinVerification = useCallback(
|
|
868
|
+
async (data, tin) => {
|
|
869
|
+
const name = typeof data === "string" ? data : data.name;
|
|
870
|
+
try {
|
|
871
|
+
setVerifying("loading");
|
|
872
|
+
setVerifiedBusiness(void 0);
|
|
873
|
+
setInvalidTin(false);
|
|
874
|
+
const { matched } = await verifyTin2({ name, tin });
|
|
875
|
+
if (matched) {
|
|
876
|
+
if (typeof data === "object") setVerifiedBusiness(data);
|
|
877
|
+
} else {
|
|
878
|
+
setInvalidTin(true);
|
|
879
|
+
}
|
|
880
|
+
return matched;
|
|
881
|
+
} catch (e) {
|
|
882
|
+
setVerifying("error");
|
|
883
|
+
logger.error(e);
|
|
884
|
+
} finally {
|
|
885
|
+
setVerifying((prevState) => prevState !== "error" ? "loaded" : prevState);
|
|
886
|
+
}
|
|
887
|
+
},
|
|
888
|
+
[verifyTin2]
|
|
889
|
+
);
|
|
890
|
+
const clearTrustedBusinessData = useCallback(async () => {
|
|
891
|
+
try {
|
|
892
|
+
setResettingTrustedData("loading");
|
|
893
|
+
await clearCompanyData2();
|
|
894
|
+
} catch (e) {
|
|
895
|
+
setResettingTrustedData("error");
|
|
896
|
+
logger.error(e);
|
|
897
|
+
} finally {
|
|
898
|
+
setResettingTrustedData((prevState) => prevState !== "error" ? "loaded" : prevState);
|
|
899
|
+
}
|
|
900
|
+
}, [clearCompanyData2]);
|
|
901
|
+
const resetBusinessData = () => {
|
|
902
|
+
setSearchResults(void 0);
|
|
903
|
+
setVerifiedBusiness(void 0);
|
|
904
|
+
};
|
|
905
|
+
const resetTinVerification = () => {
|
|
906
|
+
setInvalidTin(false);
|
|
907
|
+
};
|
|
908
|
+
return {
|
|
909
|
+
// Methods
|
|
910
|
+
searchForBusiness,
|
|
911
|
+
fetchBusinessData,
|
|
912
|
+
verifyTin: doTinVerification,
|
|
913
|
+
clearTrustedBusinessData,
|
|
914
|
+
resetBusinessData,
|
|
915
|
+
resetTinVerification,
|
|
916
|
+
// Data
|
|
917
|
+
searching,
|
|
918
|
+
fetching,
|
|
919
|
+
verifying,
|
|
920
|
+
resettingTrustedData,
|
|
921
|
+
currentSearchName: cachedSearch == null ? void 0 : cachedSearch.name,
|
|
922
|
+
searchResults,
|
|
923
|
+
verifiedBusiness,
|
|
924
|
+
invalidTin
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
const mapApiDocumentToBusinessDetailsDocuments = (entityId) => {
|
|
928
|
+
const registrationDocument = getDocument(entityId, "registrationDocument") ?? null;
|
|
929
|
+
const taxDocument = getDocument(entityId, "vatDocument") ?? getDocument(entityId, "proofOfOrganizationTaxInfo") ?? null;
|
|
930
|
+
const proofOfDirector = getDocument(entityId, "proofOfDirector") ?? null;
|
|
931
|
+
const proofOfSignatory = getDocument(entityId, "proofOfSignatory") ?? null;
|
|
932
|
+
const constitutionalDocument = getDocument(entityId, "constitutionalDocument") ?? null;
|
|
933
|
+
return {
|
|
934
|
+
companyRegistrationDocument: registrationDocument ? { registrationDocument: [mapExistingFile(getPageName(registrationDocument))] } : void 0,
|
|
935
|
+
companyTaxDocument: taxDocument ? { taxDocument: [mapExistingFile(getPageName(taxDocument))] } : void 0,
|
|
936
|
+
companyProofOfDirectorDocument: proofOfDirector ? { proofOfDirector: [mapExistingFile(getPageName(proofOfDirector))] } : void 0,
|
|
937
|
+
companyProofOfSignatoryDocument: proofOfSignatory ? { proofOfSignatory: [mapExistingFile(getPageName(proofOfSignatory))] } : void 0,
|
|
938
|
+
companyConstitutionalDocument: constitutionalDocument ? {
|
|
939
|
+
constitutionalDocument: [mapExistingFile(getPageName(constitutionalDocument))]
|
|
940
|
+
} : void 0
|
|
941
|
+
};
|
|
942
|
+
};
|
|
943
|
+
const mapBasicInformation = (data) => {
|
|
944
|
+
if (!data) return;
|
|
945
|
+
return !!data.country && COUNTRIES_USING_COMPANY_SEARCH.includes(data.country) ? data : entriesOf(data).reduce((acc, [field]) => {
|
|
946
|
+
if (!FIELDS_NEEDED_FOR_COMPANY_SEARCH.includes(field)) {
|
|
947
|
+
return {
|
|
948
|
+
...acc,
|
|
949
|
+
[field]: data[field]
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
return acc;
|
|
953
|
+
}, {});
|
|
954
|
+
};
|
|
955
|
+
const mapDbaName = (legalEntity) => {
|
|
956
|
+
var _a, _b, _c, _d;
|
|
957
|
+
const entity = legalEntity.type === "organization" ? legalEntity.organization : legalEntity.soleProprietorship;
|
|
958
|
+
const dbaName = {};
|
|
959
|
+
if (typeof (entity == null ? void 0 : entity.doingBusinessAsAbsent) !== "undefined") {
|
|
960
|
+
dbaName.hasDoingBusinessAs = !entity.doingBusinessAsAbsent;
|
|
961
|
+
} else {
|
|
962
|
+
if (entity == null ? void 0 : entity.doingBusinessAs) {
|
|
963
|
+
dbaName.hasDoingBusinessAs = (entity == null ? void 0 : entity.doingBusinessAs) !== (legalEntity.type === "organization" ? (_a = legalEntity.organization) == null ? void 0 : _a.legalName : (_b = legalEntity.soleProprietorship) == null ? void 0 : _b.name);
|
|
964
|
+
} else {
|
|
965
|
+
dbaName.hasDoingBusinessAs = void 0;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
if ((_c = legalEntity.organization) == null ? void 0 : _c.doingBusinessAs) {
|
|
969
|
+
dbaName.doingBusinessAs = (_d = legalEntity.organization) == null ? void 0 : _d.doingBusinessAs;
|
|
970
|
+
}
|
|
971
|
+
return dbaName;
|
|
972
|
+
};
|
|
973
|
+
const mapIsUen = (taxInformation, registrationNumber, country) => {
|
|
974
|
+
const currentCountryTaxInfo = taxInformation == null ? void 0 : taxInformation.find((taxInfo) => taxInfo.country === country);
|
|
975
|
+
if (!currentCountryTaxInfo || country !== "SG") return {};
|
|
976
|
+
return {
|
|
977
|
+
registrationNumber: currentCountryTaxInfo.type === "UEN" ? currentCountryTaxInfo.number : registrationNumber,
|
|
978
|
+
isUen: currentCountryTaxInfo.type === "UEN"
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
const mapAdditionalInformation = (data, legalEntity) => {
|
|
982
|
+
if (!data) return;
|
|
983
|
+
const entity = legalEntity.type === "organization" ? legalEntity.organization : legalEntity.soleProprietorship;
|
|
984
|
+
const currentCountry = entity == null ? void 0 : entity.registeredAddress.country;
|
|
985
|
+
const dbaNameFields = mapDbaName(legalEntity);
|
|
986
|
+
const isUen = mapIsUen(
|
|
987
|
+
data.taxInformation,
|
|
988
|
+
data.registrationNumber,
|
|
989
|
+
currentCountry
|
|
990
|
+
);
|
|
991
|
+
const operationalAddressIsSame = (entity == null ? void 0 : entity.principalPlaceOfBusiness) && !objectsDeepEqual(entity == null ? void 0 : entity.principalPlaceOfBusiness, entity == null ? void 0 : entity.registeredAddress) ? operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME : operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME;
|
|
992
|
+
const result = entriesOf(data).reduce(
|
|
993
|
+
(acc, [field]) => {
|
|
994
|
+
if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) {
|
|
995
|
+
return {
|
|
996
|
+
...acc,
|
|
997
|
+
[field]: data[field]
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
if (!FIELDS_NEEDED_FOR_COMPANY_SEARCH.includes(field)) {
|
|
1001
|
+
return {
|
|
1002
|
+
...acc,
|
|
1003
|
+
[field]: data[field]
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
return acc;
|
|
1007
|
+
},
|
|
1008
|
+
{ operationalAddressIsSame }
|
|
1009
|
+
);
|
|
1010
|
+
return { ...result, ...dbaNameFields, ...isUen };
|
|
1011
|
+
};
|
|
1012
|
+
const mapLegalEntityToBusinessDetailsSchema = (legalEntity, parentEntity) => {
|
|
1013
|
+
if (!legalEntity) return {};
|
|
1014
|
+
const {
|
|
1015
|
+
companyRegistrationDocument,
|
|
1016
|
+
companyTaxDocument,
|
|
1017
|
+
companyProofOfDirectorDocument,
|
|
1018
|
+
companyProofOfSignatoryDocument,
|
|
1019
|
+
companyConstitutionalDocument
|
|
1020
|
+
} = mapApiDocumentToBusinessDetailsDocuments(legalEntity.id);
|
|
1021
|
+
const buildSolePropSchema = () => {
|
|
1022
|
+
var _a, _b, _c;
|
|
1023
|
+
const solePropData = formatObject(
|
|
1024
|
+
legalEntity,
|
|
1025
|
+
solePropBusinessDetailsKeyMapping
|
|
1026
|
+
);
|
|
1027
|
+
const country = ((_b = (_a = solePropData == null ? void 0 : solePropData.additionalInformation) == null ? void 0 : _a.registrationAddress) == null ? void 0 : _b.country) ?? ((_c = parentEntity == null ? void 0 : parentEntity.individual) == null ? void 0 : _c.residentialAddress.country);
|
|
1028
|
+
return {
|
|
1029
|
+
...solePropData,
|
|
1030
|
+
basicInformation: {
|
|
1031
|
+
...solePropData == null ? void 0 : solePropData.basicInformation,
|
|
1032
|
+
country
|
|
1033
|
+
},
|
|
1034
|
+
companyConstitutionalDocument
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
const orgSchema = {
|
|
1038
|
+
...formatObject(legalEntity, businessDetailsComponentsKeyMapping),
|
|
1039
|
+
companyRegistrationDocument,
|
|
1040
|
+
companyTaxDocument,
|
|
1041
|
+
companyProofOfDirectorDocument,
|
|
1042
|
+
companyProofOfSignatoryDocument,
|
|
1043
|
+
companyFinancialInformation: {}
|
|
1044
|
+
};
|
|
1045
|
+
const businessDetailsSchema = legalEntity.type === "organization" ? orgSchema : buildSolePropSchema();
|
|
1046
|
+
return entriesOf(businessDetailsSchema).reduce((componentData, [key]) => {
|
|
1047
|
+
var _a;
|
|
1048
|
+
switch (key) {
|
|
1049
|
+
case "basicInformation": {
|
|
1050
|
+
return {
|
|
1051
|
+
...componentData,
|
|
1052
|
+
[key]: mapBasicInformation(businessDetailsSchema[key])
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
case "companyStructure": {
|
|
1056
|
+
return {
|
|
1057
|
+
...componentData,
|
|
1058
|
+
[key]: {
|
|
1059
|
+
...businessDetailsSchema[key]
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
case "additionalInformation": {
|
|
1064
|
+
return {
|
|
1065
|
+
...componentData,
|
|
1066
|
+
[key]: mapAdditionalInformation(businessDetailsSchema[key], legalEntity)
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
case "companyRegistrationDocument": {
|
|
1070
|
+
return {
|
|
1071
|
+
...componentData,
|
|
1072
|
+
[key]: businessDetailsSchema[key]
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
case "companyTaxDocument": {
|
|
1076
|
+
return {
|
|
1077
|
+
...componentData,
|
|
1078
|
+
[key]: businessDetailsSchema[key]
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
case "companyProofOfDirectorDocument": {
|
|
1082
|
+
return {
|
|
1083
|
+
...componentData,
|
|
1084
|
+
[key]: businessDetailsSchema[key]
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
case "companyProofOfSignatoryDocument": {
|
|
1088
|
+
return {
|
|
1089
|
+
...componentData,
|
|
1090
|
+
[key]: businessDetailsSchema[key]
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
case "companyConstitutionalDocument": {
|
|
1094
|
+
return {
|
|
1095
|
+
...componentData,
|
|
1096
|
+
[key]: businessDetailsSchema[key]
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
case "companyFinancialInformation": {
|
|
1100
|
+
return ((_a = legalEntity == null ? void 0 : legalEntity.organization) == null ? void 0 : _a.financialReports) ? {
|
|
1101
|
+
...componentData,
|
|
1102
|
+
[key]: mapFinancialReportsToFinancialInformation(
|
|
1103
|
+
legalEntity.organization.financialReports
|
|
1104
|
+
)
|
|
1105
|
+
} : componentData;
|
|
1106
|
+
}
|
|
1107
|
+
default:
|
|
1108
|
+
return componentData;
|
|
1109
|
+
}
|
|
1110
|
+
}, {});
|
|
1111
|
+
};
|
|
1112
|
+
const adjustFormData = (oldFormData, newFormData) => {
|
|
1113
|
+
const schema = Array.from((/* @__PURE__ */ new Set([...keysOf(oldFormData), ...keysOf(newFormData)])).keys());
|
|
1114
|
+
return schema.reduce((acc, key) => {
|
|
1115
|
+
const oldValue = oldFormData[key];
|
|
1116
|
+
const newValue = newFormData[key];
|
|
1117
|
+
if (!isUndefinedOrNull(newValue)) return { ...acc, [key]: newValue };
|
|
1118
|
+
if (Array.isArray(oldValue)) return { ...acc, [key]: [] };
|
|
1119
|
+
if (typeof oldValue === "number") return { ...acc, [key]: null };
|
|
1120
|
+
if (typeof oldValue === "string") return { ...acc, [key]: "" };
|
|
1121
|
+
return { ...acc, [key]: "" };
|
|
1122
|
+
}, {});
|
|
1123
|
+
};
|
|
1124
|
+
const setRemovedFieldsOnSchemaToDeletedValue = (newData, existingData) => {
|
|
1125
|
+
const formIds = Array.from((/* @__PURE__ */ new Set([...keysOf(existingData), ...keysOf(newData)])).keys());
|
|
1126
|
+
return formIds.reduce((adjusted, formId) => {
|
|
1127
|
+
const oldFormData = existingData[formId];
|
|
1128
|
+
const newFormData = newData[formId];
|
|
1129
|
+
if (isUndefinedOrNull(oldFormData)) return { ...adjusted, [formId]: newFormData };
|
|
1130
|
+
if (isUndefinedOrNull(newFormData)) return adjusted;
|
|
1131
|
+
return { ...adjusted, [formId]: adjustFormData(oldFormData, newFormData) };
|
|
1132
|
+
}, {});
|
|
1133
|
+
};
|
|
1134
|
+
const formatFinancialInformationSummary = (data, i18n, country) => {
|
|
1135
|
+
if (!data) return {};
|
|
1136
|
+
const summary = {
|
|
1137
|
+
currency: data.currency,
|
|
1138
|
+
financialReportingDate: data.financialReportingDate
|
|
1139
|
+
};
|
|
1140
|
+
if (country === CountryCodes.UnitedKingdom) {
|
|
1141
|
+
summary.numberOfEmployees = `${data.numberOfEmployees}`;
|
|
1142
|
+
}
|
|
1143
|
+
if (data.balanceSheetTotal) {
|
|
1144
|
+
summary.balanceSheetTotal = summaryItem(
|
|
1145
|
+
"balanceSheetTotal",
|
|
1146
|
+
formatCurrency(data.balanceSheetTotal, data.currency, i18n.locale)
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
if (data.annualTurnover) {
|
|
1150
|
+
summary.annualTurnover = formatCurrency(data.annualTurnover, data.currency, i18n.locale);
|
|
1151
|
+
}
|
|
1152
|
+
return summary;
|
|
1153
|
+
};
|
|
1154
|
+
const mapBusinessDetailsDocumentToApiDocument = async (data, entityId) => {
|
|
1155
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1156
|
+
const {
|
|
1157
|
+
companyRegistrationDocument,
|
|
1158
|
+
companyTaxDocument,
|
|
1159
|
+
companyProofOfDirectorDocument,
|
|
1160
|
+
companyConstitutionalDocument,
|
|
1161
|
+
companyProofOfSignatoryDocument
|
|
1162
|
+
} = data;
|
|
1163
|
+
const taxDocumentType = COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT.includes(
|
|
1164
|
+
(_a = data.basicInformation) == null ? void 0 : _a.country
|
|
1165
|
+
) ? "proofOfOrganizationTaxInfo" : "vatDocument";
|
|
1166
|
+
const documents = await Promise.all([
|
|
1167
|
+
createDocumentRequest({
|
|
1168
|
+
entityId,
|
|
1169
|
+
entityType: "legalEntity",
|
|
1170
|
+
documentType: "registrationDocument",
|
|
1171
|
+
page1: (_b = companyRegistrationDocument == null ? void 0 : companyRegistrationDocument.registrationDocument) == null ? void 0 : _b[0]
|
|
1172
|
+
}),
|
|
1173
|
+
createDocumentRequest({
|
|
1174
|
+
entityId,
|
|
1175
|
+
entityType: "legalEntity",
|
|
1176
|
+
documentType: taxDocumentType,
|
|
1177
|
+
page1: (_c = companyTaxDocument == null ? void 0 : companyTaxDocument.taxDocument) == null ? void 0 : _c[0]
|
|
1178
|
+
}),
|
|
1179
|
+
createDocumentRequest({
|
|
1180
|
+
entityId,
|
|
1181
|
+
entityType: "legalEntity",
|
|
1182
|
+
documentType: "proofOfDirector",
|
|
1183
|
+
page1: (_d = companyProofOfDirectorDocument == null ? void 0 : companyProofOfDirectorDocument.proofOfDirector) == null ? void 0 : _d[0]
|
|
1184
|
+
}),
|
|
1185
|
+
createDocumentRequest({
|
|
1186
|
+
entityId,
|
|
1187
|
+
entityType: "legalEntity",
|
|
1188
|
+
documentType: "constitutionalDocument",
|
|
1189
|
+
page1: (_e = companyConstitutionalDocument == null ? void 0 : companyConstitutionalDocument.constitutionalDocument) == null ? void 0 : _e[0]
|
|
1190
|
+
}),
|
|
1191
|
+
createDocumentRequest({
|
|
1192
|
+
entityId,
|
|
1193
|
+
entityType: "legalEntity",
|
|
1194
|
+
documentType: "proofOfSignatory",
|
|
1195
|
+
page1: (_f = companyProofOfSignatoryDocument == null ? void 0 : companyProofOfSignatoryDocument.proofOfSignatory) == null ? void 0 : _f[0]
|
|
1196
|
+
})
|
|
1197
|
+
]);
|
|
1198
|
+
return documents.filter(Boolean);
|
|
1199
|
+
};
|
|
1200
|
+
const mapBusinessDetailsSchemaToLegalEntity = (data, accountHolder, isExperimentEnabled) => {
|
|
1201
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1202
|
+
const requestObj = {
|
|
1203
|
+
...formatObject(
|
|
1204
|
+
data,
|
|
1205
|
+
accountHolder === "mySoleProprietorName" ? solePropBusinessDetailsApiKeyMapping : businessDetailsApiKeyMapping
|
|
1206
|
+
)
|
|
1207
|
+
};
|
|
1208
|
+
(_a = requestObj.organization) == null ? true : delete _a.legalFormDescription;
|
|
1209
|
+
const taxData = COUNTRIES_USING_COMPANY_SEARCH.includes(
|
|
1210
|
+
(_b = data.basicInformation) == null ? void 0 : _b.country
|
|
1211
|
+
) ? (_c = data.basicInformation) == null ? void 0 : _c.taxInformation : (_d = data.additionalInformation) == null ? void 0 : _d.taxInformation;
|
|
1212
|
+
const registrationNumber = COUNTRIES_USING_COMPANY_SEARCH.includes(
|
|
1213
|
+
(_e = data.basicInformation) == null ? void 0 : _e.country
|
|
1214
|
+
) ? (_f = data.basicInformation) == null ? void 0 : _f.registrationNumber : (_g = data.additionalInformation) == null ? void 0 : _g.registrationNumber;
|
|
1215
|
+
const doingBusinessAs = ((_h = data.additionalInformation) == null ? void 0 : _h.doingBusinessAs) ?? "";
|
|
1216
|
+
const entityObject = isEmpty(data.companyStructure) ? requestObj.soleProprietorship : requestObj.organization;
|
|
1217
|
+
if (entityObject) {
|
|
1218
|
+
if (taxData) {
|
|
1219
|
+
entityObject.taxInformation = taxData;
|
|
1220
|
+
}
|
|
1221
|
+
if (!!requestObj.soleProprietorship && !((_i = requestObj.soleProprietorship) == null ? void 0 : _i.countryOfGoverningLaw) && !!((_j = data.basicInformation) == null ? void 0 : _j.country)) {
|
|
1222
|
+
requestObj.soleProprietorship.countryOfGoverningLaw = data.basicInformation.country;
|
|
1223
|
+
}
|
|
1224
|
+
if (registrationNumber) {
|
|
1225
|
+
entityObject.registrationNumber = registrationNumber;
|
|
1226
|
+
if (isExperimentEnabled("EnableRegistrationAndTaxAbsentStatesV4") && requestObj.organization) {
|
|
1227
|
+
requestObj.organization.registrationNumberAbsent = false;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
if (((_k = data.additionalInformation) == null ? void 0 : _k.exemptedFromRegistrationNumber) && isExperimentEnabled("EnableRegistrationAndTaxAbsentStatesV4") && requestObj.organization) {
|
|
1231
|
+
requestObj.organization.registrationNumberAbsent = (_l = data.additionalInformation) == null ? void 0 : _l.exemptedFromRegistrationNumber;
|
|
1232
|
+
}
|
|
1233
|
+
if ((_m = data.additionalInformation) == null ? void 0 : _m.vatAbsenceReason) {
|
|
1234
|
+
entityObject.vatNumber = "";
|
|
1235
|
+
}
|
|
1236
|
+
if (isExperimentEnabled("EnableDoingBusinessAsNameV4")) {
|
|
1237
|
+
if (typeof ((_n = data.additionalInformation) == null ? void 0 : _n.hasDoingBusinessAs) !== "undefined") {
|
|
1238
|
+
entityObject.doingBusinessAsAbsent = !((_o = data.additionalInformation) == null ? void 0 : _o.hasDoingBusinessAs);
|
|
1239
|
+
}
|
|
1240
|
+
} else {
|
|
1241
|
+
entityObject.doingBusinessAs = doingBusinessAs || ((_p = data.basicInformation) == null ? void 0 : _p.legalCompanyName);
|
|
1242
|
+
delete entityObject.doingBusinessAsAbsent;
|
|
1243
|
+
}
|
|
1244
|
+
if (((_q = data.additionalInformation) == null ? void 0 : _q.operationalAddressIsSame) === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME && entityObject.principalPlaceOfBusiness) {
|
|
1245
|
+
entityObject.principalPlaceOfBusiness = entityObject.registeredAddress;
|
|
1246
|
+
}
|
|
1247
|
+
if (!isEmpty(data.companyFinancialInformation)) {
|
|
1248
|
+
entityObject.financialReports = [
|
|
1249
|
+
mapFinancialInformationToFinancialReport(data.companyFinancialInformation)
|
|
1250
|
+
];
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
requestObj.type = requestObj.organization ? LegalEntityType.ORGANIZATION : LegalEntityType.SOLE_PROPRIETORSHIP;
|
|
1254
|
+
if ((entityObject == null ? void 0 : entityObject.registeredAddress.country) === "US") {
|
|
1255
|
+
delete entityObject.registrationNumber;
|
|
1256
|
+
}
|
|
1257
|
+
return requestObj;
|
|
1258
|
+
};
|
|
1259
|
+
const businessDetailsBase = {
|
|
1260
|
+
/* Base required fields */
|
|
1261
|
+
country: { rule: "REQUIRED" },
|
|
1262
|
+
entityType: { rule: "businessRequiresCompanyType" },
|
|
1263
|
+
legalCompanyName: { rule: "REQUIRED" },
|
|
1264
|
+
hasDoingBusinessAs: { rule: "REQUIRED" },
|
|
1265
|
+
registrationAddress: { rule: "REQUIRED" },
|
|
1266
|
+
operationalAddressIsSame: { rule: "REQUIRED" },
|
|
1267
|
+
/* Base optional fields */
|
|
1268
|
+
operationalAddress: { rule: "OPTIONAL" },
|
|
1269
|
+
/* Fields with custom country specific rules */
|
|
1270
|
+
stockExchangeMIC: { rule: "ifPubliclyTradedCompany" },
|
|
1271
|
+
stockISIN: { rule: "ifPubliclyTradedCompany" },
|
|
1272
|
+
stockTickerSymbol: { rule: "ifPubliclyTradedCompany" },
|
|
1273
|
+
dateOfIncorporation: { rule: "countryRequiresDateOfIncorporationForCompanies" },
|
|
1274
|
+
stateOrProvince: { rule: "countryUsingCompanySearch" },
|
|
1275
|
+
registrationNumber: { rule: "countryRequiresRegistrationNumber" },
|
|
1276
|
+
exemptedFromRegistrationNumber: { rule: "companyRegistrationNumberExemptionAllowed" },
|
|
1277
|
+
eInvoicingCode: { rule: "isEInvoicingCodeEnabled" },
|
|
1278
|
+
countryOfGoverningLaw: { rule: "countryOfGoverningLawRequired" },
|
|
1279
|
+
taxDocument: { rule: "ifCountryUsAndTinFailed" }
|
|
1280
|
+
};
|
|
1281
|
+
const taxInformationBase = {
|
|
1282
|
+
vatNumber: { rule: "countryUsesVat" },
|
|
1283
|
+
exemptedFromVat: { rule: "countryUsesVat" },
|
|
1284
|
+
vatAbsenceReason: { rule: "countryUsesVat" },
|
|
1285
|
+
taxInformation: { rule: "countryUsesTaxId" },
|
|
1286
|
+
exemptedFromTax: { rule: "countryHasTaxExemptions" },
|
|
1287
|
+
isUen: { rule: "countryUsesUenOrGst" }
|
|
1288
|
+
};
|
|
1289
|
+
const financialInformationBase = {
|
|
1290
|
+
numberOfEmployees: { rule: "countryRequiresFinancialInformation" },
|
|
1291
|
+
financialReportingDate: { rule: "countryRequiresFinancialInformation" }
|
|
1292
|
+
};
|
|
1293
|
+
const businessDetailsFieldsPerScenario = {
|
|
1294
|
+
L0: {
|
|
1295
|
+
country: { rule: "REQUIRED" },
|
|
1296
|
+
legalCompanyName: { rule: "REQUIRED" },
|
|
1297
|
+
stateOrProvince: { rule: "countryUsingCompanySearch" },
|
|
1298
|
+
...financialInformationBase
|
|
1299
|
+
},
|
|
1300
|
+
L1: { ...businessDetailsBase, ...financialInformationBase },
|
|
1301
|
+
L: {
|
|
1302
|
+
...businessDetailsBase,
|
|
1303
|
+
...taxInformationBase,
|
|
1304
|
+
...financialInformationBase
|
|
1305
|
+
},
|
|
1306
|
+
L_PROOFOFADDRESS: {
|
|
1307
|
+
// TODO this field does not exist
|
|
1308
|
+
// proofOfAddressDocument: { rule: 'REQUIRED' },
|
|
1309
|
+
},
|
|
1310
|
+
L_REGDOC: {
|
|
1311
|
+
registrationDocument: { rule: "REQUIRED" }
|
|
1312
|
+
},
|
|
1313
|
+
L_TAXDOC: {
|
|
1314
|
+
taxDocument: { rule: "REQUIRED" }
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
const businessDetailsCountryConfig = {
|
|
1318
|
+
[CountryCodes.Australia]: {
|
|
1319
|
+
entityType: { label: "companyType" },
|
|
1320
|
+
exemptedFromTax: { label: "doNotHaveAbn" },
|
|
1321
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveAcn" }
|
|
1322
|
+
},
|
|
1323
|
+
[CountryCodes.Austria]: {
|
|
1324
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveFirmenbuchnummer" }
|
|
1325
|
+
},
|
|
1326
|
+
[CountryCodes.Finland]: {
|
|
1327
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveYTunnus" }
|
|
1328
|
+
},
|
|
1329
|
+
[CountryCodes.Germany]: {
|
|
1330
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveHandelsregisternummer" }
|
|
1331
|
+
},
|
|
1332
|
+
[CountryCodes.HongKong]: {
|
|
1333
|
+
entityType: { label: "typeOfCompany" },
|
|
1334
|
+
registrationDocument: { label: "companyRegistrationDocument" },
|
|
1335
|
+
exemptedFromRegistrationNumber: { label: "iDoNotHaveCompanyRegistrationNumber" }
|
|
1336
|
+
},
|
|
1337
|
+
[CountryCodes.Japan]: {
|
|
1338
|
+
registrationDocument: { label: "chamberOfCommerceExtract" }
|
|
1339
|
+
},
|
|
1340
|
+
[CountryCodes.Lithuania]: {
|
|
1341
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveLtRegistrationNumber" }
|
|
1342
|
+
},
|
|
1343
|
+
[CountryCodes.Luxembourg]: {
|
|
1344
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveLuRegistrationNumber" }
|
|
1345
|
+
},
|
|
1346
|
+
[CountryCodes.Malaysia]: {
|
|
1347
|
+
registrationDocument: { label: "companyProfile" }
|
|
1348
|
+
},
|
|
1349
|
+
[CountryCodes.Mexico]: {
|
|
1350
|
+
registrationDocument: { label: "RfcDocument" }
|
|
1351
|
+
},
|
|
1352
|
+
[CountryCodes.NewZealand]: {
|
|
1353
|
+
taxDocument: { label: "irdDocument" }
|
|
1354
|
+
},
|
|
1355
|
+
[CountryCodes.Poland]: {
|
|
1356
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveRegonKrsNumber" }
|
|
1357
|
+
},
|
|
1358
|
+
[CountryCodes.PuertoRico]: {
|
|
1359
|
+
// exactly matches CountryCodes.UnitedStates, except `stateOrProvince`
|
|
1360
|
+
country: { label: "country__US__business" },
|
|
1361
|
+
exemptedFromTax: { label: "doNotHaveEIN" }
|
|
1362
|
+
},
|
|
1363
|
+
[CountryCodes.Singapore]: {
|
|
1364
|
+
registrationNumber: { label: "uen" },
|
|
1365
|
+
entityType: { label: "companyType" },
|
|
1366
|
+
isUen: { label: "iDoNotHaveGst" }
|
|
1367
|
+
},
|
|
1368
|
+
[CountryCodes.Sweden]: {
|
|
1369
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveOrganisationsnummer" }
|
|
1370
|
+
},
|
|
1371
|
+
[CountryCodes.Switzerland]: {
|
|
1372
|
+
exemptedFromRegistrationNumber: { label: "doNotHaveChRegistrationNumber" }
|
|
1373
|
+
},
|
|
1374
|
+
[CountryCodes.UnitedStates]: {
|
|
1375
|
+
country: { label: "country__US__business" },
|
|
1376
|
+
stateOrProvince: { label: "stateOrProvince__US__business" },
|
|
1377
|
+
doingBusinessAs: { label: "doingBusinessAs" },
|
|
1378
|
+
exemptedFromTax: { label: "doNotHaveEIN" }
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
const MANDATORY_FIELDS_BUSINESS_DETAILS = [
|
|
1382
|
+
"basicInformation.legalCompanyName",
|
|
1383
|
+
"basicInformation.country"
|
|
1384
|
+
];
|
|
1385
|
+
const parseBusinessDetailsScenarios = (scenarios, country) => augmentWithCountryConfigs(
|
|
1386
|
+
businessDetailsCountryConfig[country],
|
|
1387
|
+
composePerScenarioFormConfigurations(scenarios, businessDetailsFieldsPerScenario)
|
|
1388
|
+
);
|
|
1389
|
+
const canSubmit = (data) => MANDATORY_FIELDS_BUSINESS_DETAILS.every((detail) => {
|
|
1390
|
+
const value = getProp(data, detail);
|
|
1391
|
+
return !isEmpty$1(value);
|
|
1392
|
+
});
|
|
1393
|
+
const isDocumentsRequired = (forms) => forms.some((form) => documentFormsIds.includes(form.formId));
|
|
1394
|
+
const removeConditionalForms = (forms, isSkippingCompanyStructure) => isSkippingCompanyStructure ? forms.filter((f) => f.formId !== "companyStructure" && f.formId !== "companyType") : forms;
|
|
1395
|
+
const formatBasicInformation = (data, labels, datasetUtils, companyType, isCountryOfGoverningLawEnabled) => {
|
|
1396
|
+
var _a, _b, _c, _d, _e;
|
|
1397
|
+
const country = data == null ? void 0 : data.country;
|
|
1398
|
+
const registrationNumberLabel = resolveFieldMetadata(
|
|
1399
|
+
defaultFieldConfig[country],
|
|
1400
|
+
{
|
|
1401
|
+
companyType,
|
|
1402
|
+
registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country, companyType) : (_b = (_a = getCompanyRegistrationNumberOptions(country, companyType)) == null ? void 0 : _a[0]) == null ? void 0 : _b.id
|
|
1403
|
+
},
|
|
1404
|
+
defaultFieldMetadata
|
|
1405
|
+
).label;
|
|
1406
|
+
const taxIdLabel = resolveFieldMetadata(
|
|
1407
|
+
defaultFieldConfig$1[country],
|
|
1408
|
+
{
|
|
1409
|
+
taxIdNumberType: countryToTaxInfoTypeMap[country] ?? void 0,
|
|
1410
|
+
// TODO use type selector
|
|
1411
|
+
companyType: void 0
|
|
1412
|
+
},
|
|
1413
|
+
defaultFieldMetadata$1
|
|
1414
|
+
).label;
|
|
1415
|
+
const countryOfGoverningLaw = getCountryOfGoverningLaw(isCountryOfGoverningLawEnabled, data);
|
|
1416
|
+
return {
|
|
1417
|
+
[((_c = labels == null ? void 0 : labels.basicInformation) == null ? void 0 : _c.legalCompanyName) ?? "legalCompanyName"]: data.legalCompanyName,
|
|
1418
|
+
country: datasetUtils.getCountryName(data.country),
|
|
1419
|
+
[getKeyForField("stateOrProvince", data.country)]: datasetUtils.getStateName(
|
|
1420
|
+
data.stateOrProvince,
|
|
1421
|
+
data.country
|
|
1422
|
+
),
|
|
1423
|
+
[taxIdLabel]: (_e = (_d = data.taxInformation) == null ? void 0 : _d.find((taxId) => data.country === taxId.country)) == null ? void 0 : _e.number,
|
|
1424
|
+
[registrationNumberLabel]: data.registrationNumber,
|
|
1425
|
+
countryOfGoverningLaw: datasetUtils.getCountryName(countryOfGoverningLaw)
|
|
1426
|
+
};
|
|
1427
|
+
};
|
|
1428
|
+
const formatAdditionalInformation = (data, labels, country, companyType, i18n) => {
|
|
1429
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1430
|
+
const registrationNumberLabel = resolveFieldMetadata(
|
|
1431
|
+
defaultFieldConfig[country],
|
|
1432
|
+
{
|
|
1433
|
+
companyType,
|
|
1434
|
+
registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country, companyType) : (_b = (_a = getCompanyRegistrationNumberOptions(country, companyType)) == null ? void 0 : _a[0]) == null ? void 0 : _b.id
|
|
1435
|
+
},
|
|
1436
|
+
defaultFieldMetadata
|
|
1437
|
+
).label;
|
|
1438
|
+
const taxIdLabel = resolveFieldMetadata(
|
|
1439
|
+
defaultFieldConfig$1[country],
|
|
1440
|
+
{
|
|
1441
|
+
taxIdNumberType: countryToTaxInfoTypeMap[country] ?? void 0,
|
|
1442
|
+
// TODO use type selector
|
|
1443
|
+
companyType: void 0
|
|
1444
|
+
},
|
|
1445
|
+
defaultFieldMetadata$1
|
|
1446
|
+
).label;
|
|
1447
|
+
return {
|
|
1448
|
+
[((_c = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _c.doingBusinessAs) ?? "doingBusinessAs"]: data.doingBusinessAs,
|
|
1449
|
+
[registrationNumberLabel]: data.registrationNumber,
|
|
1450
|
+
[taxIdLabel]: data.isUen ? void 0 : (_e = (_d = data.taxInformation) == null ? void 0 : _d.find((taxId) => country === taxId.country)) == null ? void 0 : _e.number,
|
|
1451
|
+
[((_f = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _f.vatNumber) ?? "vatNumber"]: data.vatNumber,
|
|
1452
|
+
[((_g = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _g.vatAbsenceReason) ?? "vatAbsenceReason"]: data.vatAbsenceReason ? i18n.get(data.vatAbsenceReason) : void 0,
|
|
1453
|
+
[((_h = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _h.dateOfIncorporation) ?? "dateOfIncorporation"]: data.dateOfIncorporation,
|
|
1454
|
+
[((_i = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _i.stockExchangeMIC) ?? "stockExchangeMIC"]: data.stockExchangeMIC,
|
|
1455
|
+
[((_j = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _j.stockISIN) ?? "stockISIN"]: data.stockISIN,
|
|
1456
|
+
[((_k = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _k.stockTickerSymbol) ?? "stockTickerSymbol"]: data.stockTickerSymbol,
|
|
1457
|
+
[((_l = labels == null ? void 0 : labels.additionalInformation) == null ? void 0 : _l.eInvoicingCode) ?? "eInvoicingCode"]: data.eInvoicingCode
|
|
1458
|
+
};
|
|
1459
|
+
};
|
|
1460
|
+
const formatDataForSummary = (data, forms, labels, i18n, isExperimentEnabled) => {
|
|
1461
|
+
const datasetUtils = datasetUtilities(i18n.locale);
|
|
1462
|
+
return entriesOf(data).reduce((summaryData, [form]) => {
|
|
1463
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1464
|
+
if (!form || !data[form]) return summaryData;
|
|
1465
|
+
const isCountryOfGoverningLawEnabled = isExperimentEnabled(
|
|
1466
|
+
"EnableCountryOfGoverningLawForUKCompanies"
|
|
1467
|
+
);
|
|
1468
|
+
switch (form) {
|
|
1469
|
+
case "basicInformation":
|
|
1470
|
+
return {
|
|
1471
|
+
...summaryData,
|
|
1472
|
+
[form]: formatBasicInformation(
|
|
1473
|
+
data[form],
|
|
1474
|
+
labels,
|
|
1475
|
+
datasetUtils,
|
|
1476
|
+
(_a = data.companyStructure) == null ? void 0 : _a.entityType,
|
|
1477
|
+
isCountryOfGoverningLawEnabled
|
|
1478
|
+
)
|
|
1479
|
+
};
|
|
1480
|
+
case "companyStructure":
|
|
1481
|
+
return {
|
|
1482
|
+
...summaryData,
|
|
1483
|
+
[form]: {
|
|
1484
|
+
entityType: i18n.get(
|
|
1485
|
+
(_c = companyTypeMetadata[(_b = data[form]) == null ? void 0 : _b.entityType]) == null ? void 0 : _c.name
|
|
1486
|
+
)
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
case "additionalInformation":
|
|
1490
|
+
return {
|
|
1491
|
+
...summaryData,
|
|
1492
|
+
[form]: {
|
|
1493
|
+
hasInnerForms: true,
|
|
1494
|
+
additionalInformationFormName: formatAdditionalInformation(
|
|
1495
|
+
data[form],
|
|
1496
|
+
labels,
|
|
1497
|
+
(_d = data.basicInformation) == null ? void 0 : _d.country,
|
|
1498
|
+
(_e = data.companyStructure) == null ? void 0 : _e.entityType,
|
|
1499
|
+
i18n
|
|
1500
|
+
),
|
|
1501
|
+
registrationAddress: mapAddressLabels(data[form].registrationAddress, datasetUtils),
|
|
1502
|
+
operationalAddress: data[form].operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME ? mapAddressLabels(data[form].operationalAddress, datasetUtils) : void 0
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
case "companyRegistrationDocument":
|
|
1506
|
+
if (!isDocumentsRequired(forms)) return summaryData;
|
|
1507
|
+
return {
|
|
1508
|
+
...summaryData,
|
|
1509
|
+
[form]: {
|
|
1510
|
+
companyRegistrationDocument: {
|
|
1511
|
+
fileName: (_g = (_f = data[form].registrationDocument) == null ? void 0 : _f[0]) == null ? void 0 : _g.name
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
case "companyTaxDocument":
|
|
1516
|
+
if (!isDocumentsRequired(forms)) return summaryData;
|
|
1517
|
+
return {
|
|
1518
|
+
...summaryData,
|
|
1519
|
+
[form]: {
|
|
1520
|
+
companyTaxDocument: {
|
|
1521
|
+
fileName: (_i = (_h = data[form].taxDocument) == null ? void 0 : _h[0]) == null ? void 0 : _i.name
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
case "companyProofOfDirectorDocument":
|
|
1526
|
+
if (!isDocumentsRequired(forms)) return summaryData;
|
|
1527
|
+
return {
|
|
1528
|
+
...summaryData,
|
|
1529
|
+
[form]: {
|
|
1530
|
+
companyProofOfDirectorDocument: {
|
|
1531
|
+
fileName: (_k = (_j = data[form].proofOfDirector) == null ? void 0 : _j[0]) == null ? void 0 : _k.name
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
case "companyProofOfSignatoryDocument":
|
|
1536
|
+
if (!isDocumentsRequired(forms)) return summaryData;
|
|
1537
|
+
return {
|
|
1538
|
+
...summaryData,
|
|
1539
|
+
[form]: {
|
|
1540
|
+
companyProofOfSignatoryDocument: {
|
|
1541
|
+
fileName: (_m = (_l = data[form].proofOfSignatory) == null ? void 0 : _l[0]) == null ? void 0 : _m.name
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
case "companyFinancialInformation":
|
|
1546
|
+
return {
|
|
1547
|
+
...summaryData,
|
|
1548
|
+
[form]: formatFinancialInformationSummary(
|
|
1549
|
+
data[form],
|
|
1550
|
+
i18n,
|
|
1551
|
+
(_n = data == null ? void 0 : data.basicInformation) == null ? void 0 : _n.country
|
|
1552
|
+
)
|
|
1553
|
+
};
|
|
1554
|
+
default:
|
|
1555
|
+
return summaryData;
|
|
1556
|
+
}
|
|
1557
|
+
}, {});
|
|
1558
|
+
};
|
|
1559
|
+
async function submitDocuments({
|
|
1560
|
+
data,
|
|
1561
|
+
legalEntity,
|
|
1562
|
+
forms,
|
|
1563
|
+
documentUtils,
|
|
1564
|
+
additionalTrackingParams,
|
|
1565
|
+
userEvents
|
|
1566
|
+
}) {
|
|
1567
|
+
if (!isDocumentsRequired(forms)) return;
|
|
1568
|
+
const logger2 = createLogger();
|
|
1569
|
+
const formattedDocument = await mapBusinessDetailsDocumentToApiDocument(data, legalEntity.id);
|
|
1570
|
+
try {
|
|
1571
|
+
if (formattedDocument) {
|
|
1572
|
+
await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
|
|
1573
|
+
formattedDocument.forEach((doc) => {
|
|
1574
|
+
var _a;
|
|
1575
|
+
userEvents == null ? void 0 : userEvents.addTaskEvent("Success", {
|
|
1576
|
+
...additionalTrackingParams,
|
|
1577
|
+
actionType: "upload",
|
|
1578
|
+
documentType: doc.type,
|
|
1579
|
+
fileExtention: ((_a = doc.attachments) == null ? void 0 : _a.map((item) => getFileExtention(item.pageName))) ?? []
|
|
1580
|
+
});
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
} catch (err) {
|
|
1584
|
+
logger2.error(err);
|
|
1585
|
+
userEvents.addTaskEvent("Encountered error", {
|
|
1586
|
+
...additionalTrackingParams,
|
|
1587
|
+
actionType: "upload",
|
|
1588
|
+
returnType: err.errorCode,
|
|
1589
|
+
returnValue: err.title ?? err.message
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
async function submit({
|
|
1594
|
+
additionalTrackingParams,
|
|
1595
|
+
data,
|
|
1596
|
+
legalEntityResponse,
|
|
1597
|
+
associatedLegalArrangement,
|
|
1598
|
+
nestedLegalEntity,
|
|
1599
|
+
nestedLegalEntityDetails,
|
|
1600
|
+
problems,
|
|
1601
|
+
taskType,
|
|
1602
|
+
accountHolder,
|
|
1603
|
+
forms,
|
|
1604
|
+
documentUtils,
|
|
1605
|
+
i18n,
|
|
1606
|
+
showToast,
|
|
1607
|
+
setLoadingStatus,
|
|
1608
|
+
setProblems,
|
|
1609
|
+
handleUpdateLegalEntity,
|
|
1610
|
+
createLegalEntity,
|
|
1611
|
+
onExternalSubmit,
|
|
1612
|
+
isExperimentEnabled,
|
|
1613
|
+
userEvents
|
|
1614
|
+
}) {
|
|
1615
|
+
var _a, _b, _c, _d, _e;
|
|
1616
|
+
const logger2 = createLogger();
|
|
1617
|
+
setLoadingStatus("loading");
|
|
1618
|
+
const trackingPayload = {
|
|
1619
|
+
...additionalTrackingParams,
|
|
1620
|
+
actionType: "submit",
|
|
1621
|
+
companyStructure: ((_a = data.companyStructure) == null ? void 0 : _a.entityType) ?? null,
|
|
1622
|
+
countryOfRegistration: ((_b = data.basicInformation) == null ? void 0 : _b.country) ?? null,
|
|
1623
|
+
legalEntityName: accountHolder === "theCompanyIWorkFor" ? ((_c = data.basicInformation) == null ? void 0 : _c.legalCompanyName) ?? null : null,
|
|
1624
|
+
// Only send legalCompanyName for organizations
|
|
1625
|
+
usedAdditionalAddress: ((_d = data.additionalInformation) == null ? void 0 : _d.operationalAddressIsSame) === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME
|
|
1626
|
+
};
|
|
1627
|
+
const entityToUpdate = (() => {
|
|
1628
|
+
switch (taskType) {
|
|
1629
|
+
case TaskTypes.SOLE_PROPRIETOR_COMPANY:
|
|
1630
|
+
return associatedLegalArrangement;
|
|
1631
|
+
case TaskTypes.TRUST_MEMBER_COMPANY:
|
|
1632
|
+
case TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY:
|
|
1633
|
+
return nestedLegalEntity;
|
|
1634
|
+
case TaskTypes.BUSINESS_DETAILS:
|
|
1635
|
+
default:
|
|
1636
|
+
return legalEntityResponse;
|
|
1637
|
+
}
|
|
1638
|
+
})();
|
|
1639
|
+
const handleSubmitLegalEntity = async (legalEntity) => {
|
|
1640
|
+
if (taskType === TaskTypes.TRUST_MEMBER_COMPANY && !(nestedLegalEntity == null ? void 0 : nestedLegalEntity.id) || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY && !(nestedLegalEntity == null ? void 0 : nestedLegalEntity.id) || taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && !(associatedLegalArrangement == null ? void 0 : associatedLegalArrangement.id)) {
|
|
1641
|
+
return await createLegalEntity(legalEntity);
|
|
1642
|
+
} else {
|
|
1643
|
+
return handleUpdateLegalEntity({
|
|
1644
|
+
...drop("type").from(legalEntity),
|
|
1645
|
+
id: (entityToUpdate == null ? void 0 : entityToUpdate.id) ?? legalEntityResponse.id
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
const associateLegalEntityWithParent = async ({
|
|
1650
|
+
legalEntity,
|
|
1651
|
+
associatedLegalArrangement: associatedLegalArrangement2,
|
|
1652
|
+
nestedLegalEntityDetails: nestedLegalEntityDetails2
|
|
1653
|
+
}) => {
|
|
1654
|
+
if (nestedLegalEntityDetails2 && associatedLegalArrangement2) {
|
|
1655
|
+
const existingEntityAssociations = getOwnEntityAssociations(associatedLegalArrangement2);
|
|
1656
|
+
const existingRoles = existingEntityAssociations.filter((ea) => ea.legalEntityId === associatedLegalArrangement2.id).map(({ type }) => type);
|
|
1657
|
+
const newRoles = (nestedLegalEntityDetails2 == null ? void 0 : nestedLegalEntityDetails2.roles) ?? [];
|
|
1658
|
+
const rolesChanged = !doArraysMatch(existingRoles, newRoles);
|
|
1659
|
+
if (rolesChanged) {
|
|
1660
|
+
const updatedAssociations = {
|
|
1661
|
+
entityAssociations: [
|
|
1662
|
+
...newRoles.map((role) => ({
|
|
1663
|
+
type: role,
|
|
1664
|
+
legalEntityId: legalEntity.id
|
|
1665
|
+
})) || [],
|
|
1666
|
+
...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
|
|
1667
|
+
]
|
|
1668
|
+
};
|
|
1669
|
+
await handleUpdateLegalEntity({
|
|
1670
|
+
...updatedAssociations,
|
|
1671
|
+
id: associatedLegalArrangement2.id
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
return;
|
|
1675
|
+
} else {
|
|
1676
|
+
const updatedAssociations = {
|
|
1677
|
+
entityAssociations: [
|
|
1678
|
+
{
|
|
1679
|
+
type: LegalEntityType.SOLE_PROPRIETORSHIP,
|
|
1680
|
+
legalEntityId: legalEntity.id
|
|
1681
|
+
}
|
|
1682
|
+
]
|
|
1683
|
+
};
|
|
1684
|
+
await handleUpdateLegalEntity({ ...updatedAssociations, id: legalEntityResponse.id });
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
const savedLegalEntityData = legalEntityResponse ? mapLegalEntityToBusinessDetailsSchema(legalEntityResponse) : null;
|
|
1688
|
+
const filteredData = savedLegalEntityData ? setRemovedFieldsOnSchemaToDeletedValue(data, savedLegalEntityData) : data;
|
|
1689
|
+
if ((filteredData == null ? void 0 : filteredData.additionalInformation) && !((_e = filteredData == null ? void 0 : filteredData.additionalInformation) == null ? void 0 : _e.taxInformation)) {
|
|
1690
|
+
filteredData.additionalInformation.taxInformation = void 0;
|
|
1691
|
+
}
|
|
1692
|
+
const isCountryOfGoverningLawEnabled = isExperimentEnabled(
|
|
1693
|
+
"EnableCountryOfGoverningLawForUKCompanies"
|
|
1694
|
+
);
|
|
1695
|
+
const countryOfGoverningLaw = getCountryOfGoverningLaw(
|
|
1696
|
+
isCountryOfGoverningLawEnabled,
|
|
1697
|
+
filteredData == null ? void 0 : filteredData.basicInformation
|
|
1698
|
+
);
|
|
1699
|
+
if (filteredData == null ? void 0 : filteredData.basicInformation) {
|
|
1700
|
+
if (countryOfGoverningLaw) {
|
|
1701
|
+
filteredData.basicInformation.countryOfGoverningLaw = countryOfGoverningLaw;
|
|
1702
|
+
} else {
|
|
1703
|
+
delete filteredData.basicInformation.countryOfGoverningLaw;
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
try {
|
|
1707
|
+
const mappedLegalEntity = {
|
|
1708
|
+
...mapBusinessDetailsSchemaToLegalEntity(filteredData, accountHolder, isExperimentEnabled),
|
|
1709
|
+
entityAssociations: filterOutUnwantedAssociationsIfRootLE(
|
|
1710
|
+
taskType,
|
|
1711
|
+
entityToUpdate,
|
|
1712
|
+
accountHolder
|
|
1713
|
+
)
|
|
1714
|
+
};
|
|
1715
|
+
const legalEntity = await handleSubmitLegalEntity(mappedLegalEntity);
|
|
1716
|
+
if (taskType === TaskTypes.TRUST_MEMBER_COMPANY || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY || taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && !(associatedLegalArrangement == null ? void 0 : associatedLegalArrangement.id)) {
|
|
1717
|
+
await associateLegalEntityWithParent({
|
|
1718
|
+
legalEntity,
|
|
1719
|
+
associatedLegalArrangement,
|
|
1720
|
+
nestedLegalEntityDetails
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
await submitDocuments({
|
|
1724
|
+
data,
|
|
1725
|
+
legalEntity,
|
|
1726
|
+
additionalTrackingParams,
|
|
1727
|
+
documentUtils,
|
|
1728
|
+
forms,
|
|
1729
|
+
userEvents
|
|
1730
|
+
});
|
|
1731
|
+
userEvents == null ? void 0 : userEvents.addTaskEvent("Success", trackingPayload);
|
|
1732
|
+
showToast({ label: i18n.get("successfullyUpdatedDetails"), variant: "success" });
|
|
1733
|
+
onExternalSubmit == null ? void 0 : onExternalSubmit(data);
|
|
1734
|
+
} catch (err) {
|
|
1735
|
+
if (isValidationError(err)) {
|
|
1736
|
+
setProblems({
|
|
1737
|
+
...problems,
|
|
1738
|
+
validationErrors: processValidationErrors(err, TaskTypes.BUSINESS_DETAILS)
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
if (isMaintenanceModeError(err)) {
|
|
1742
|
+
showToast({
|
|
1743
|
+
label: i18n.get("maintenanceModeMessage"),
|
|
1744
|
+
variant: "error",
|
|
1745
|
+
duration: "indefinite"
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
if (!isValidationError(err) && !isMaintenanceModeError(err)) {
|
|
1749
|
+
showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
|
|
1750
|
+
}
|
|
1751
|
+
logger2.error(err);
|
|
1752
|
+
userEvents == null ? void 0 : userEvents.addTaskEvent("Encountered error", {
|
|
1753
|
+
...trackingPayload,
|
|
1754
|
+
returnType: err == null ? void 0 : err.errorCode,
|
|
1755
|
+
returnValue: (err == null ? void 0 : err.title) || "backend"
|
|
1756
|
+
});
|
|
1757
|
+
} finally {
|
|
1758
|
+
setLoadingStatus("success");
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
const getCountryOfGoverningLaw = (isCountryOfGoverningLawEnabled, basicData) => {
|
|
1762
|
+
if (!isCountryOfGoverningLawEnabled || (basicData == null ? void 0 : basicData.country) !== CountryCodes.UnitedKingdom) {
|
|
1763
|
+
return void 0;
|
|
1764
|
+
}
|
|
1765
|
+
if (isCountryOfGoverningLawEnabled && (basicData == null ? void 0 : basicData.country) === CountryCodes.UnitedKingdom && !(basicData == null ? void 0 : basicData.countryOfGoverningLaw)) {
|
|
1766
|
+
return CountryCodes.UnitedKingdom;
|
|
1767
|
+
}
|
|
1768
|
+
return basicData == null ? void 0 : basicData.countryOfGoverningLaw;
|
|
1769
|
+
};
|
|
1770
|
+
function BusinessDetailsDropin({
|
|
1771
|
+
country,
|
|
1772
|
+
problems,
|
|
1773
|
+
legalEntityResponse,
|
|
1774
|
+
associatedLegalArrangement,
|
|
1775
|
+
// initially undefined when creating entity
|
|
1776
|
+
nestedLegalEntity,
|
|
1777
|
+
// initially undefined when creating entity
|
|
1778
|
+
nestedLegalEntityDetails,
|
|
1779
|
+
// has entity roles for association logic
|
|
1780
|
+
taskName,
|
|
1781
|
+
hideSidebar,
|
|
1782
|
+
taskType,
|
|
1783
|
+
onChange,
|
|
1784
|
+
onSubmit: onExternalSubmit,
|
|
1785
|
+
handleHomeClick
|
|
1786
|
+
}) {
|
|
1787
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1788
|
+
const formRef = useRef(null);
|
|
1789
|
+
const { accountHolder, setAccountHolder } = useAccountHolder();
|
|
1790
|
+
const { showToast } = useToastContext();
|
|
1791
|
+
const { i18n } = useI18nContext();
|
|
1792
|
+
const userEvents = useAnalyticsContext();
|
|
1793
|
+
const { isExperimentEnabled } = useExperimentsContext();
|
|
1794
|
+
const { isSettingEnabled } = useSettingsContext();
|
|
1795
|
+
const { baseUrl, rootLegalEntityId } = useApiContext();
|
|
1796
|
+
const {
|
|
1797
|
+
state: { currentState }
|
|
1798
|
+
} = useStateContext();
|
|
1799
|
+
useEffect(() => {
|
|
1800
|
+
onChange == null ? void 0 : onChange(currentState);
|
|
1801
|
+
}, [currentState, onChange]);
|
|
1802
|
+
const isSoleProp = accountHolder === "mySoleProprietorName";
|
|
1803
|
+
const formWith2Views = "basicInformation";
|
|
1804
|
+
const isAssociationTaskType = useMemo(() => {
|
|
1805
|
+
if (!taskType) {
|
|
1806
|
+
return accountHolder !== "theCompanyIWorkFor";
|
|
1807
|
+
}
|
|
1808
|
+
return taskType !== TaskTypes.BUSINESS_DETAILS;
|
|
1809
|
+
}, [accountHolder, taskType]);
|
|
1810
|
+
const legalEntityType = !isSoleProp ? LegalEntityType.ORGANIZATION : LegalEntityType.SOLE_PROPRIETORSHIP;
|
|
1811
|
+
const isManualTinVerificationEnabledAndUS = country === CountryCodes.UnitedStates;
|
|
1812
|
+
const currentCountry = useMemo(
|
|
1813
|
+
() => {
|
|
1814
|
+
var _a2;
|
|
1815
|
+
return ((_a2 = currentState.data.basicInformation) == null ? void 0 : _a2.country) ?? country;
|
|
1816
|
+
},
|
|
1817
|
+
[(_a = currentState.data.basicInformation) == null ? void 0 : _a.country, country]
|
|
1818
|
+
);
|
|
1819
|
+
const isSkippingCompanyStructure = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange) && organizationTypesToSkipCompanyStructureForm.includes(
|
|
1820
|
+
(_b = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _b.type
|
|
1821
|
+
) && accountHolder !== "aTrust" || isSoleProp;
|
|
1822
|
+
useEffect(() => {
|
|
1823
|
+
var _a2, _b2;
|
|
1824
|
+
const isBankAccountRequested = (_b2 = (_a2 = legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities) == null ? void 0 : _a2.issueBankAccount) == null ? void 0 : _b2.requested;
|
|
1825
|
+
setIsBankAccountRequestedForOrganization(isBankAccountRequested);
|
|
1826
|
+
}, [legalEntityResponse]);
|
|
1827
|
+
const subjectEntity = !isAssociationTaskType ? legalEntityResponse : isSoleProp ? associatedLegalArrangement : nestedLegalEntity;
|
|
1828
|
+
const associatedLeTrackingParams = useMemo(
|
|
1829
|
+
() => getAssociatedLeAnalyticsPayload({
|
|
1830
|
+
associatedLegalEntity: associatedLegalArrangement
|
|
1831
|
+
}),
|
|
1832
|
+
[associatedLegalArrangement]
|
|
1833
|
+
);
|
|
1834
|
+
useEffect(() => {
|
|
1835
|
+
userEvents.updateBaseTrackingPayload({ task: taskType });
|
|
1836
|
+
userEvents.addTaskEvent("Landed on page", {
|
|
1837
|
+
actionType: "start",
|
|
1838
|
+
...associatedLeTrackingParams
|
|
1839
|
+
});
|
|
1840
|
+
}, []);
|
|
1841
|
+
const [tinMatched, setTinMatched] = useState(void 0);
|
|
1842
|
+
const [initialData, setInitialData] = useState(() => {
|
|
1843
|
+
return mapLegalEntityToBusinessDetailsSchema(
|
|
1844
|
+
!isAssociationTaskType ? legalEntityResponse : isSoleProp ? associatedLegalArrangement ?? legalEntityResponse : nestedLegalEntity,
|
|
1845
|
+
isSoleProp ? legalEntityResponse : void 0
|
|
1846
|
+
);
|
|
1847
|
+
});
|
|
1848
|
+
const [trustedFields, setTrustedFields] = useState((subjectEntity == null ? void 0 : subjectEntity.trustedFields) ?? void 0);
|
|
1849
|
+
const [currentProblems, setCurrentProblems] = useState(
|
|
1850
|
+
problems ?? ((_d = (_c = getCapabilityProblems(legalEntityResponse, currentCountry)) == null ? void 0 : _c.LegalEntity) == null ? void 0 : _d[legalEntityResponse.id])
|
|
1851
|
+
);
|
|
1852
|
+
const [showCompanyStructure, setShowCompanyStructure] = useState(
|
|
1853
|
+
currentCountry !== "US" && !isSoleProp
|
|
1854
|
+
);
|
|
1855
|
+
const [showBusinessSelection, setShowBusinessSelection] = useState(false);
|
|
1856
|
+
const [loadingStatus, setLoadingStatus] = useState("success");
|
|
1857
|
+
const [businessMismatchModalOpen, setBusinessMismatchModalOpen] = useState(false);
|
|
1858
|
+
const documentUtils = documentApiUtils({
|
|
1859
|
+
baseUrl: baseUrl.value,
|
|
1860
|
+
rootLegalEntityId: rootLegalEntityId.value
|
|
1861
|
+
});
|
|
1862
|
+
useEffect(() => {
|
|
1863
|
+
var _a2;
|
|
1864
|
+
if (!((_a2 = subjectEntity == null ? void 0 : subjectEntity.documentDetails) == null ? void 0 : _a2.length)) return;
|
|
1865
|
+
documentUtils.fetchDocuments(subjectEntity.documentDetails, subjectEntity.id).then(() => {
|
|
1866
|
+
setInitialData(
|
|
1867
|
+
mapLegalEntityToBusinessDetailsSchema(
|
|
1868
|
+
subjectEntity,
|
|
1869
|
+
isSoleProp ? legalEntityResponse : void 0
|
|
1870
|
+
)
|
|
1871
|
+
);
|
|
1872
|
+
}).catch(
|
|
1873
|
+
() => showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" })
|
|
1874
|
+
);
|
|
1875
|
+
}, []);
|
|
1876
|
+
const parseConfiguration = useCallback(
|
|
1877
|
+
({ scenarios, country: country2 }) => parseBusinessDetailsScenarios(scenarios, country2),
|
|
1878
|
+
[]
|
|
1879
|
+
);
|
|
1880
|
+
const {
|
|
1881
|
+
fieldConfigurations
|
|
1882
|
+
} = useScenarioConfiguration({
|
|
1883
|
+
legalEntityType,
|
|
1884
|
+
parseConfiguration,
|
|
1885
|
+
setLoadingStatus,
|
|
1886
|
+
country: currentCountry
|
|
1887
|
+
});
|
|
1888
|
+
const customRules = useMemo(
|
|
1889
|
+
() => rules({
|
|
1890
|
+
data: currentState.data,
|
|
1891
|
+
country: currentCountry,
|
|
1892
|
+
taskType: taskType ?? TaskTypes.BUSINESS_DETAILS,
|
|
1893
|
+
isExperimentEnabled,
|
|
1894
|
+
accountHolder,
|
|
1895
|
+
tinMatched,
|
|
1896
|
+
rootLegalEntity: legalEntityResponse
|
|
1897
|
+
}),
|
|
1898
|
+
[
|
|
1899
|
+
currentState.data,
|
|
1900
|
+
currentCountry,
|
|
1901
|
+
taskType,
|
|
1902
|
+
isExperimentEnabled,
|
|
1903
|
+
accountHolder,
|
|
1904
|
+
tinMatched,
|
|
1905
|
+
legalEntityResponse
|
|
1906
|
+
]
|
|
1907
|
+
);
|
|
1908
|
+
const initialForms = useMemo(() => getForms(currentCountry), [currentCountry]);
|
|
1909
|
+
const derivedProps = useMemo(
|
|
1910
|
+
() => getPropsFromConfigurations(
|
|
1911
|
+
fieldConfigurations,
|
|
1912
|
+
initialForms,
|
|
1913
|
+
(currentProblems == null ? void 0 : currentProblems.remediationActions) ? Object.values(currentProblems == null ? void 0 : currentProblems.remediationActions) : [],
|
|
1914
|
+
(currentProblems == null ? void 0 : currentProblems.missingData) ?? [],
|
|
1915
|
+
subjectEntity ? subjectEntity.type === LegalEntityType.SOLE_PROPRIETORSHIP ? getFieldsWithExistingData(
|
|
1916
|
+
subjectEntity,
|
|
1917
|
+
solePropBusinessDetailsApiKeyMapping,
|
|
1918
|
+
solePropBusinessDetailsDocumentMapping
|
|
1919
|
+
) : getFieldsWithExistingData(
|
|
1920
|
+
subjectEntity,
|
|
1921
|
+
businessDetailsApiKeyMapping,
|
|
1922
|
+
businessDetailsDocumentMapping
|
|
1923
|
+
) : [],
|
|
1924
|
+
customRules,
|
|
1925
|
+
{},
|
|
1926
|
+
{},
|
|
1927
|
+
subjectEntity == null ? void 0 : subjectEntity.type,
|
|
1928
|
+
trustedFields
|
|
1929
|
+
),
|
|
1930
|
+
[
|
|
1931
|
+
fieldConfigurations,
|
|
1932
|
+
initialForms,
|
|
1933
|
+
currentProblems == null ? void 0 : currentProblems.remediationActions,
|
|
1934
|
+
currentProblems == null ? void 0 : currentProblems.missingData,
|
|
1935
|
+
subjectEntity,
|
|
1936
|
+
customRules,
|
|
1937
|
+
trustedFields
|
|
1938
|
+
]
|
|
1939
|
+
);
|
|
1940
|
+
const forms = useMemo(() => {
|
|
1941
|
+
const requiredForms = getRequiredForms(
|
|
1942
|
+
initialForms,
|
|
1943
|
+
derivedProps == null ? void 0 : derivedProps.requiredFields,
|
|
1944
|
+
derivedProps == null ? void 0 : derivedProps.optionalFields
|
|
1945
|
+
);
|
|
1946
|
+
const validityAddedForms = addValidityToForms(
|
|
1947
|
+
requiredForms,
|
|
1948
|
+
currentState.validityByForm,
|
|
1949
|
+
currentProblems
|
|
1950
|
+
);
|
|
1951
|
+
return removeConditionalForms(
|
|
1952
|
+
validityAddedForms,
|
|
1953
|
+
currentCountry !== "US" ? isSkippingCompanyStructure : !showCompanyStructure
|
|
1954
|
+
);
|
|
1955
|
+
}, [
|
|
1956
|
+
initialForms,
|
|
1957
|
+
derivedProps == null ? void 0 : derivedProps.requiredFields,
|
|
1958
|
+
derivedProps == null ? void 0 : derivedProps.optionalFields,
|
|
1959
|
+
currentState.validityByForm,
|
|
1960
|
+
currentProblems,
|
|
1961
|
+
currentCountry,
|
|
1962
|
+
isSkippingCompanyStructure,
|
|
1963
|
+
showCompanyStructure
|
|
1964
|
+
]);
|
|
1965
|
+
const summaryData = useMemo(
|
|
1966
|
+
() => ({
|
|
1967
|
+
data: formatDataForSummary(
|
|
1968
|
+
currentState.data,
|
|
1969
|
+
forms,
|
|
1970
|
+
derivedProps == null ? void 0 : derivedProps.labels,
|
|
1971
|
+
i18n,
|
|
1972
|
+
isExperimentEnabled
|
|
1973
|
+
),
|
|
1974
|
+
omitted: {
|
|
1975
|
+
keys: ["operationalAddressIsSame"]
|
|
1976
|
+
}
|
|
1977
|
+
}),
|
|
1978
|
+
[currentState.data, derivedProps == null ? void 0 : derivedProps.labels, forms, i18n, isExperimentEnabled]
|
|
1979
|
+
);
|
|
1980
|
+
const canSubmitForm = useMemo(
|
|
1981
|
+
() => canSubmit(currentState.data) && hasDataChanged(initialData, currentState.data),
|
|
1982
|
+
[initialData, currentState.data]
|
|
1983
|
+
);
|
|
1984
|
+
const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
|
|
1985
|
+
const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
|
|
1986
|
+
const submitTask = useCallback(() => {
|
|
1987
|
+
setAccountHolder(accountHolder);
|
|
1988
|
+
return submit({
|
|
1989
|
+
additionalTrackingParams: associatedLeTrackingParams,
|
|
1990
|
+
data: currentState.data,
|
|
1991
|
+
legalEntityResponse,
|
|
1992
|
+
associatedLegalArrangement,
|
|
1993
|
+
nestedLegalEntity,
|
|
1994
|
+
nestedLegalEntityDetails,
|
|
1995
|
+
problems: currentProblems,
|
|
1996
|
+
taskType: taskType ?? TaskTypes.BUSINESS_DETAILS,
|
|
1997
|
+
accountHolder: accountHolder ?? "theCompanyIWorkFor",
|
|
1998
|
+
forms,
|
|
1999
|
+
documentUtils,
|
|
2000
|
+
i18n,
|
|
2001
|
+
showToast,
|
|
2002
|
+
setLoadingStatus,
|
|
2003
|
+
setProblems: setCurrentProblems,
|
|
2004
|
+
handleUpdateLegalEntity: updateLegalEntity,
|
|
2005
|
+
createLegalEntity,
|
|
2006
|
+
onExternalSubmit,
|
|
2007
|
+
isExperimentEnabled,
|
|
2008
|
+
userEvents
|
|
2009
|
+
});
|
|
2010
|
+
}, [
|
|
2011
|
+
setAccountHolder,
|
|
2012
|
+
accountHolder,
|
|
2013
|
+
associatedLeTrackingParams,
|
|
2014
|
+
currentState.data,
|
|
2015
|
+
legalEntityResponse,
|
|
2016
|
+
associatedLegalArrangement,
|
|
2017
|
+
nestedLegalEntity,
|
|
2018
|
+
nestedLegalEntityDetails,
|
|
2019
|
+
currentProblems,
|
|
2020
|
+
taskType,
|
|
2021
|
+
forms,
|
|
2022
|
+
documentUtils,
|
|
2023
|
+
i18n,
|
|
2024
|
+
showToast,
|
|
2025
|
+
updateLegalEntity,
|
|
2026
|
+
createLegalEntity,
|
|
2027
|
+
onExternalSubmit,
|
|
2028
|
+
isExperimentEnabled,
|
|
2029
|
+
userEvents
|
|
2030
|
+
]);
|
|
2031
|
+
const {
|
|
2032
|
+
handleNextClick,
|
|
2033
|
+
handleBackClick,
|
|
2034
|
+
activeForm,
|
|
2035
|
+
shouldValidate,
|
|
2036
|
+
setShouldValidate,
|
|
2037
|
+
gotoFormByFormIndex,
|
|
2038
|
+
steps
|
|
2039
|
+
} = useFormComposer({
|
|
2040
|
+
problems: currentProblems,
|
|
2041
|
+
navigationTrackingParams: associatedLeTrackingParams,
|
|
2042
|
+
forms,
|
|
2043
|
+
onSubmit: submitTask
|
|
2044
|
+
});
|
|
2045
|
+
const { mutateAsync: tinVerificationFn } = useVerifyTin();
|
|
2046
|
+
const { mutateAsync: clearCompanyData2 } = useClearCompanyData();
|
|
2047
|
+
const { mutateAsync: getCompanyDataset2 } = useCompanyDataset();
|
|
2048
|
+
const { mutateAsync: refreshCompanyDataset2 } = useRefreshCompanyDataset();
|
|
2049
|
+
const { mutateAsync: companyIndexSearch2 } = useCompanyIndexSearch();
|
|
2050
|
+
const { mutateAsync: companyDeepSearch2 } = useCompanyDeepSearch();
|
|
2051
|
+
const { mutateAsync: companyRegistrationNumberDeepSearch2 } = useCompanyRegistrationNumberDeepSearch();
|
|
2052
|
+
const { mutateAsync: companyRegistrationNumberIndexSearch2 } = useCompanyRegistrationNumberIndexSearch();
|
|
2053
|
+
const {
|
|
2054
|
+
searchForBusiness,
|
|
2055
|
+
fetchBusinessData,
|
|
2056
|
+
verifyTin: verifyTin2,
|
|
2057
|
+
clearTrustedBusinessData,
|
|
2058
|
+
resetBusinessData,
|
|
2059
|
+
resetTinVerification,
|
|
2060
|
+
searching,
|
|
2061
|
+
fetching,
|
|
2062
|
+
verifying,
|
|
2063
|
+
resettingTrustedData,
|
|
2064
|
+
currentSearchName,
|
|
2065
|
+
searchResults,
|
|
2066
|
+
invalidTin,
|
|
2067
|
+
verifiedBusiness
|
|
2068
|
+
} = useBusinessData({
|
|
2069
|
+
companyIndexSearch: companyIndexSearch2,
|
|
2070
|
+
companyDeepSearch: companyDeepSearch2,
|
|
2071
|
+
companyRegistrationNumberIndexSearch: companyRegistrationNumberIndexSearch2,
|
|
2072
|
+
companyRegistrationNumberDeepSearch: companyRegistrationNumberDeepSearch2,
|
|
2073
|
+
getCompanyDataset: getCompanyDataset2,
|
|
2074
|
+
refreshCompanyDataset: refreshCompanyDataset2,
|
|
2075
|
+
verifyTin: tinVerificationFn,
|
|
2076
|
+
clearCompanyData: clearCompanyData2
|
|
2077
|
+
});
|
|
2078
|
+
const proceedToManualDataEntry = useCallback(async () => {
|
|
2079
|
+
await clearTrustedBusinessData().then(async () => {
|
|
2080
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
2081
|
+
if (!isManualTinVerificationEnabledAndUS) {
|
|
2082
|
+
setShowCompanyStructure(true);
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
const businessName = ((_b2 = (_a2 = currentState == null ? void 0 : currentState.data) == null ? void 0 : _a2.basicInformation) == null ? void 0 : _b2.legalCompanyName) || "";
|
|
2086
|
+
const taxInformation = (_d2 = (_c2 = currentState == null ? void 0 : currentState.data) == null ? void 0 : _c2.basicInformation) == null ? void 0 : _d2.taxInformation;
|
|
2087
|
+
const tin = ((_e2 = taxInformation == null ? void 0 : taxInformation.find((taxId) => currentCountry === taxId.country)) == null ? void 0 : _e2.number) || "";
|
|
2088
|
+
if (!businessName || !tin) {
|
|
2089
|
+
setShowCompanyStructure(true);
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
const tinMatch = await verifyTin2(businessName, tin);
|
|
2093
|
+
if (tinMatch) {
|
|
2094
|
+
setShowCompanyStructure(true);
|
|
2095
|
+
setBusinessMismatchModalOpen(false);
|
|
2096
|
+
} else {
|
|
2097
|
+
setBusinessMismatchModalOpen(true);
|
|
2098
|
+
setTinMatched(false);
|
|
2099
|
+
if ((subjectEntity == null ? void 0 : subjectEntity.id) && (subjectEntity == null ? void 0 : subjectEntity.type)) {
|
|
2100
|
+
userEvents.addTaskEvent("Opened modal", {
|
|
2101
|
+
actionType: "open",
|
|
2102
|
+
label: "tinVerificationFailure",
|
|
2103
|
+
legalEntityId: subjectEntity.id,
|
|
2104
|
+
entityType: subjectEntity.type
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
});
|
|
2109
|
+
}, [
|
|
2110
|
+
clearTrustedBusinessData,
|
|
2111
|
+
isManualTinVerificationEnabledAndUS,
|
|
2112
|
+
(_f = (_e = currentState == null ? void 0 : currentState.data) == null ? void 0 : _e.basicInformation) == null ? void 0 : _f.legalCompanyName,
|
|
2113
|
+
(_h = (_g = currentState == null ? void 0 : currentState.data) == null ? void 0 : _g.basicInformation) == null ? void 0 : _h.taxInformation,
|
|
2114
|
+
verifyTin2,
|
|
2115
|
+
currentCountry,
|
|
2116
|
+
subjectEntity == null ? void 0 : subjectEntity.id,
|
|
2117
|
+
subjectEntity == null ? void 0 : subjectEntity.type,
|
|
2118
|
+
userEvents
|
|
2119
|
+
]);
|
|
2120
|
+
const handleCompanySearch = useCallback(
|
|
2121
|
+
async (currentData) => {
|
|
2122
|
+
var _a2, _b2;
|
|
2123
|
+
if (!(currentData == null ? void 0 : currentData.legalCompanyName) || !(currentData == null ? void 0 : currentData.country) || !(currentData == null ? void 0 : currentData.stateOrProvince)) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
setShowBusinessSelection(true);
|
|
2127
|
+
const results = await searchForBusiness({
|
|
2128
|
+
name: currentData.legalCompanyName,
|
|
2129
|
+
country: currentData.country,
|
|
2130
|
+
state: currentData.stateOrProvince,
|
|
2131
|
+
registrationNumber: currentData.registrationNumber
|
|
2132
|
+
});
|
|
2133
|
+
if (!results || !Array.isArray(results) || !results.length) {
|
|
2134
|
+
await proceedToManualDataEntry();
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
if ((results == null ? void 0 : results.length) === 1) {
|
|
2138
|
+
const result = results[0];
|
|
2139
|
+
const nameMatch = isNormalizedStringMatch(currentData.legalCompanyName, result.name);
|
|
2140
|
+
if (!nameMatch) {
|
|
2141
|
+
return;
|
|
2142
|
+
} else {
|
|
2143
|
+
const businessData = await fetchBusinessData(
|
|
2144
|
+
result,
|
|
2145
|
+
currentData.stateOrProvince
|
|
2146
|
+
);
|
|
2147
|
+
if (businessData) {
|
|
2148
|
+
const tin = ((_b2 = (_a2 = currentData == null ? void 0 : currentData.taxInformation) == null ? void 0 : _a2.find((taxId) => currentCountry === taxId.country)) == null ? void 0 : _b2.number) || "";
|
|
2149
|
+
const tinMatch = await verifyTin2(businessData, tin);
|
|
2150
|
+
if (tinMatch) {
|
|
2151
|
+
if (!businessData.legalForm) setShowCompanyStructure(true);
|
|
2152
|
+
handleNextClick();
|
|
2153
|
+
}
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
},
|
|
2159
|
+
[
|
|
2160
|
+
searchForBusiness,
|
|
2161
|
+
proceedToManualDataEntry,
|
|
2162
|
+
fetchBusinessData,
|
|
2163
|
+
verifyTin2,
|
|
2164
|
+
handleNextClick,
|
|
2165
|
+
currentCountry
|
|
2166
|
+
]
|
|
2167
|
+
);
|
|
2168
|
+
const isBusinessSelection = useMemo(
|
|
2169
|
+
() => showBusinessSelection && activeForm.formId === formWith2Views,
|
|
2170
|
+
[activeForm.formId, showBusinessSelection]
|
|
2171
|
+
);
|
|
2172
|
+
const hideFooter = isBusinessSelection === true && (searching === "loading" || fetching === "loading" || verifying === "loading" || resettingTrustedData === "loading");
|
|
2173
|
+
const hideNextButton = useMemo(() => {
|
|
2174
|
+
if (activeForm.formId === formWith2Views) return isBusinessSelection;
|
|
2175
|
+
else return false;
|
|
2176
|
+
}, [activeForm.formId, isBusinessSelection]);
|
|
2177
|
+
const showBackButton = useMemo(() => {
|
|
2178
|
+
if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) return false;
|
|
2179
|
+
if (isBusinessSelection) {
|
|
2180
|
+
return searching !== "loading" || fetching !== "loading" || verifying !== "loading" || resettingTrustedData !== "loading";
|
|
2181
|
+
}
|
|
2182
|
+
return false;
|
|
2183
|
+
}, [currentCountry, isBusinessSelection, searching, fetching, verifying, resettingTrustedData]);
|
|
2184
|
+
const goToForm = useCallback(
|
|
2185
|
+
(index) => {
|
|
2186
|
+
if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) {
|
|
2187
|
+
return gotoFormByFormIndex(index);
|
|
2188
|
+
}
|
|
2189
|
+
const selectedFormId = forms[index].formId;
|
|
2190
|
+
if (selectedFormId === formWith2Views) {
|
|
2191
|
+
if (verifiedBusiness) setShowBusinessSelection(false);
|
|
2192
|
+
if (activeForm.formId === "companyStructure" && (searchResults == null ? void 0 : searchResults.length)) {
|
|
2193
|
+
setShowCompanyStructure(false);
|
|
2194
|
+
}
|
|
2195
|
+
return gotoFormByFormIndex(index);
|
|
2196
|
+
} else {
|
|
2197
|
+
if (verifiedBusiness) return gotoFormByFormIndex(index);
|
|
2198
|
+
if (activeForm.formId !== formWith2Views) return gotoFormByFormIndex(index);
|
|
2199
|
+
if (activeForm.formId === formWith2Views && !isBusinessSelection) {
|
|
2200
|
+
handleCompanySearch(currentState.data.basicInformation);
|
|
2201
|
+
setShowBusinessSelection(true);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
},
|
|
2205
|
+
[
|
|
2206
|
+
currentCountry,
|
|
2207
|
+
forms,
|
|
2208
|
+
activeForm.formId,
|
|
2209
|
+
isBusinessSelection,
|
|
2210
|
+
gotoFormByFormIndex,
|
|
2211
|
+
verifiedBusiness,
|
|
2212
|
+
searchResults == null ? void 0 : searchResults.length,
|
|
2213
|
+
handleCompanySearch,
|
|
2214
|
+
currentState.data.basicInformation
|
|
2215
|
+
]
|
|
2216
|
+
);
|
|
2217
|
+
const nextClick = useCallback(() => {
|
|
2218
|
+
var _a2, _b2;
|
|
2219
|
+
if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry) || isSoleProp)
|
|
2220
|
+
return handleNextClick();
|
|
2221
|
+
const toFormName = (_a2 = forms[forms.findIndex((form) => form.formId === activeForm.formId) + 1]) == null ? void 0 : _a2.formName;
|
|
2222
|
+
if (activeForm.formId === formWith2Views && ((_b2 = currentState.validityByForm) == null ? void 0 : _b2.basicInformation) && !isBusinessSelection && !verifiedBusiness) {
|
|
2223
|
+
trackNavigation({
|
|
2224
|
+
userEvents,
|
|
2225
|
+
actionType: "next",
|
|
2226
|
+
toForm: toFormName || "home",
|
|
2227
|
+
label: "next",
|
|
2228
|
+
returnValue: "success"
|
|
2229
|
+
});
|
|
2230
|
+
handleCompanySearch(currentState.data.basicInformation);
|
|
2231
|
+
} else {
|
|
2232
|
+
handleNextClick();
|
|
2233
|
+
}
|
|
2234
|
+
}, [
|
|
2235
|
+
currentCountry,
|
|
2236
|
+
isSoleProp,
|
|
2237
|
+
handleNextClick,
|
|
2238
|
+
forms,
|
|
2239
|
+
activeForm.formId,
|
|
2240
|
+
(_i = currentState.validityByForm) == null ? void 0 : _i.basicInformation,
|
|
2241
|
+
currentState.data.basicInformation,
|
|
2242
|
+
isBusinessSelection,
|
|
2243
|
+
verifiedBusiness,
|
|
2244
|
+
handleCompanySearch
|
|
2245
|
+
]);
|
|
2246
|
+
const backClick = useCallback(() => {
|
|
2247
|
+
if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) handleBackClick == null ? void 0 : handleBackClick();
|
|
2248
|
+
else {
|
|
2249
|
+
switch (activeForm.formId) {
|
|
2250
|
+
case formWith2Views: {
|
|
2251
|
+
trackNavigation({
|
|
2252
|
+
userEvents,
|
|
2253
|
+
actionType: "back",
|
|
2254
|
+
toForm: "basicDetails",
|
|
2255
|
+
label: "back"
|
|
2256
|
+
});
|
|
2257
|
+
if (showBusinessSelection) setShowBusinessSelection(false);
|
|
2258
|
+
break;
|
|
2259
|
+
}
|
|
2260
|
+
case "companyStructure": {
|
|
2261
|
+
if (searching === "error") {
|
|
2262
|
+
setShowBusinessSelection(false);
|
|
2263
|
+
setShowCompanyStructure(false);
|
|
2264
|
+
handleBackClick == null ? void 0 : handleBackClick();
|
|
2265
|
+
break;
|
|
2266
|
+
}
|
|
2267
|
+
if (searching !== "loading" && searchResults && !searchResults.length) {
|
|
2268
|
+
setShowBusinessSelection(false);
|
|
2269
|
+
} else if (!verifiedBusiness) setShowCompanyStructure(false);
|
|
2270
|
+
handleBackClick == null ? void 0 : handleBackClick();
|
|
2271
|
+
break;
|
|
2272
|
+
}
|
|
2273
|
+
case "additionalInformation": {
|
|
2274
|
+
if (verifiedBusiness) setShowBusinessSelection(false);
|
|
2275
|
+
handleBackClick == null ? void 0 : handleBackClick();
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
default:
|
|
2279
|
+
handleBackClick == null ? void 0 : handleBackClick();
|
|
2280
|
+
break;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}, [
|
|
2284
|
+
currentCountry,
|
|
2285
|
+
handleBackClick,
|
|
2286
|
+
activeForm.formId,
|
|
2287
|
+
showBusinessSelection,
|
|
2288
|
+
searching,
|
|
2289
|
+
searchResults,
|
|
2290
|
+
verifiedBusiness
|
|
2291
|
+
]);
|
|
2292
|
+
const homeClick = () => {
|
|
2293
|
+
trackNavigation({
|
|
2294
|
+
userEvents,
|
|
2295
|
+
actionType: "save",
|
|
2296
|
+
toForm: "home",
|
|
2297
|
+
label: "home"
|
|
2298
|
+
});
|
|
2299
|
+
handleHomeClick == null ? void 0 : handleHomeClick();
|
|
2300
|
+
};
|
|
2301
|
+
const handleBusinessMismatchContinue = useCallback(() => {
|
|
2302
|
+
setShowCompanyStructure(true);
|
|
2303
|
+
setTrustedFields([]);
|
|
2304
|
+
setBusinessMismatchModalOpen(false);
|
|
2305
|
+
trackNavigation({
|
|
2306
|
+
userEvents,
|
|
2307
|
+
actionType: "next",
|
|
2308
|
+
toForm: "additionalInformationFormName",
|
|
2309
|
+
label: "TIN Continue Anyways"
|
|
2310
|
+
});
|
|
2311
|
+
}, [setShowCompanyStructure, setTrustedFields, setBusinessMismatchModalOpen]);
|
|
2312
|
+
const handleBusinessMismatchCancel = useCallback(() => {
|
|
2313
|
+
backClick == null ? void 0 : backClick();
|
|
2314
|
+
setBusinessMismatchModalOpen(false);
|
|
2315
|
+
setTinMatched(void 0);
|
|
2316
|
+
trackNavigation({
|
|
2317
|
+
userEvents,
|
|
2318
|
+
actionType: "back",
|
|
2319
|
+
toForm: "basicDetails",
|
|
2320
|
+
label: "TIN Edit Details"
|
|
2321
|
+
});
|
|
2322
|
+
}, [backClick, setTinMatched, setBusinessMismatchModalOpen]);
|
|
2323
|
+
useEffect(() => {
|
|
2324
|
+
var _a2, _b2;
|
|
2325
|
+
if (((_a2 = currentState.data.basicInformation) == null ? void 0 : _a2.legalCompanyName) !== currentSearchName && ((_b2 = currentState.data.basicInformation) == null ? void 0 : _b2.legalCompanyName) !== (verifiedBusiness == null ? void 0 : verifiedBusiness.name)) {
|
|
2326
|
+
setShowCompanyStructure(false);
|
|
2327
|
+
resetBusinessData();
|
|
2328
|
+
}
|
|
2329
|
+
}, [currentSearchName, (_j = currentState.data.basicInformation) == null ? void 0 : _j.legalCompanyName, verifiedBusiness]);
|
|
2330
|
+
useEffect(() => {
|
|
2331
|
+
var _a2;
|
|
2332
|
+
if ((trustedFields == null ? void 0 : trustedFields.length) && ((_a2 = legalEntityResponse.organization) == null ? void 0 : _a2.registeredAddress.country) !== currentCountry) {
|
|
2333
|
+
setTrustedFields(void 0);
|
|
2334
|
+
}
|
|
2335
|
+
}, [currentCountry]);
|
|
2336
|
+
return /* @__PURE__ */ jsxs(
|
|
2337
|
+
FormWrapper,
|
|
2338
|
+
{
|
|
2339
|
+
taskName: taskName ?? "businessDetails",
|
|
2340
|
+
gotoFormByFormIndex: goToForm,
|
|
2341
|
+
hideSidebar,
|
|
2342
|
+
hideFooter,
|
|
2343
|
+
loadingStatus,
|
|
2344
|
+
forms,
|
|
2345
|
+
activeForm,
|
|
2346
|
+
validateForm: () => setShouldValidate(true),
|
|
2347
|
+
navigationTrackingParams: associatedLeTrackingParams,
|
|
2348
|
+
onSubmit: submitTask,
|
|
2349
|
+
problems: currentProblems,
|
|
2350
|
+
canSubmit: canSubmitForm,
|
|
2351
|
+
summary: summaryData,
|
|
2352
|
+
handleNextClick: nextClick,
|
|
2353
|
+
handleBackClick: backClick,
|
|
2354
|
+
handleHomeClick: homeClick,
|
|
2355
|
+
steps,
|
|
2356
|
+
showBackButton,
|
|
2357
|
+
hideNextButton,
|
|
2358
|
+
children: [
|
|
2359
|
+
/* @__PURE__ */ jsx(
|
|
2360
|
+
BusinessDetails,
|
|
2361
|
+
{
|
|
2362
|
+
...derivedProps,
|
|
2363
|
+
ref: formRef,
|
|
2364
|
+
data: initialData,
|
|
2365
|
+
country: currentCountry,
|
|
2366
|
+
problems: currentProblems,
|
|
2367
|
+
activeForm,
|
|
2368
|
+
shouldValidate,
|
|
2369
|
+
isTopLevelEntity: taskType === TaskTypes.BUSINESS_DETAILS,
|
|
2370
|
+
showBusinessSelection,
|
|
2371
|
+
setShowBusinessSelection,
|
|
2372
|
+
showCompanyStructure,
|
|
2373
|
+
setShowCompanyStructure,
|
|
2374
|
+
searchResults,
|
|
2375
|
+
invalidTin,
|
|
2376
|
+
resetTinVerification,
|
|
2377
|
+
verifiedBusiness,
|
|
2378
|
+
searching,
|
|
2379
|
+
fetching,
|
|
2380
|
+
verifying,
|
|
2381
|
+
resettingTrustedData,
|
|
2382
|
+
fetchBusinessData,
|
|
2383
|
+
verifyTin: verifyTin2,
|
|
2384
|
+
proceedToManualDataEntry,
|
|
2385
|
+
handleNextClick: nextClick,
|
|
2386
|
+
taskType
|
|
2387
|
+
}
|
|
2388
|
+
),
|
|
2389
|
+
businessMismatchModalOpen && /* @__PURE__ */ jsx(
|
|
2390
|
+
Confirm,
|
|
2391
|
+
{
|
|
2392
|
+
title: i18n.get("businessSelection__tinVerificationFailureModalHeader"),
|
|
2393
|
+
description: i18n.get("businessSelection__tinVerificationFailureModalContent"),
|
|
2394
|
+
cancelText: i18n.get("businessSelection__tinVerificationFailureModalSecondaryButton"),
|
|
2395
|
+
confirmText: i18n.get("businessSelection__tinVerificationFailureModalPrimaryButton"),
|
|
2396
|
+
onCancel: handleBusinessMismatchCancel,
|
|
2397
|
+
onConfirm: handleBusinessMismatchContinue
|
|
2398
|
+
}
|
|
2399
|
+
)
|
|
2400
|
+
]
|
|
2401
|
+
}
|
|
2402
|
+
);
|
|
2403
|
+
}
|
|
2404
|
+
export {
|
|
2405
|
+
BusinessDetailsDropin
|
|
2406
|
+
};
|