@adyen/kyc-components 3.89.0 → 3.90.0-beta.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.
Files changed (159) hide show
  1. package/dist/{AcceptTermsOfServiceComponent-Dw5F8ZKQ.js → AcceptTermsOfServiceComponent-C15N0ZUF.js} +42 -60
  2. package/dist/{Accordion-DP7ihhCi.js → Accordion-DxAvtqyN.js} +1 -1
  3. package/dist/{AccountSetupRejected-BjjuX_Vh.js → AccountSetupRejected-CJEC9V31.js} +3 -3
  4. package/dist/{ActionBar-LBeWfJy2.js → ActionBar-CMaTcnyU.js} +1 -1
  5. package/dist/{Address-DvJBiSDY.js → Address-DhPHns9b.js} +25 -56
  6. package/dist/{Alert-uQtl0hSh.js → Alert-4jvSqn2I.js} +6 -6
  7. package/dist/{Avatar-CDLbKRZS.js → Avatar-CowRz5rB.js} +1 -1
  8. package/dist/{BusinessDetailsMultiformDropin-DtnVx-uQ.js → BusinessDetailsDropin-CoQA-QZn.js} +1268 -3090
  9. package/dist/{BusinessFinancingComponent-DQ6OoqwG.js → BusinessFinancingComponent-BUXvPO_t.js} +6 -5
  10. package/dist/{BusinessFinancingDropin-Bw_jVxVY.js → BusinessFinancingDropin-D7HQ0fxW.js} +23 -33
  11. package/dist/{BusinessFinancingPage-BCecT_U6.js → BusinessFinancingPage-BNCloKBm.js} +3 -3
  12. package/dist/{BusinessTypeSelectionPage-Bohuv12F.js → BusinessTypeSelectionPage-ClaW0q1b.js} +8 -9
  13. package/dist/{Card-BhinbOTz.js → Card-B4wvck_n.js} +2 -2
  14. package/dist/{ConstitutionalDocument-CoMojmXO.js → ConstitutionalDocument-SKhWRnWx.js} +3 -3
  15. package/dist/{CountryField-DNOtItPS.js → CountryField-BaYyWFXk.js} +6 -6
  16. package/dist/{CreateIndividualComponent-85qgG0sT.js → CreateIndividualComponent-M_rhCRjG.js} +5 -5
  17. package/dist/{CreateTransferInstrumentComponent-D4-Yla9J.js → CreateTransferInstrumentComponent-BJxSbJY3.js} +4 -4
  18. package/dist/{Currency-6i-D39G4.js → Currency-Bl8pKCpj.js} +7 -7
  19. package/dist/{CustomerSupport-CP6NVYUM.js → CustomerSupport-BBp_kAB6.js} +10 -10
  20. package/dist/{DebugModal-BtwHvJcw.js → DebugModal-D6ROPhng.js} +9 -9
  21. package/dist/{DecisionMakerDetailsPage-DWbiEKY5.js → DecisionMakerDetailsPage-BtUhVF6C.js} +6 -6
  22. package/dist/{DecisionMakers-rPNoo6IF.js → DecisionMakers-Ctwwbd-q.js} +20 -20
  23. package/dist/{EmbeddedStatus-BCUb0GA8.js → EmbeddedStatus-B33cCsYP.js} +2 -2
  24. package/dist/{EndStateLayout-Cy7__eeV.js → EndStateLayout-C-njoytF.js} +1 -1
  25. package/dist/{EntityAssociation-BEUkGJTF.js → EntityAssociation-94E5qp1C.js} +8 -8
  26. package/dist/{EntityGuidanceStatus-Cg4xuAhZ.js → EntityGuidanceStatus-SgjcGk5p.js} +2 -2
  27. package/dist/FormFlow-Poe97Z6i.js +186 -0
  28. package/dist/{FormNavigation-Bm-rQTB6.js → FormNavigation-B0D8RWB0.js} +3 -3
  29. package/dist/{FormWrapper-BL7nl_vR.js → FormWrapper-4wa6SP_P.js} +10 -10
  30. package/dist/{IndividualOnfido-Dx7sDvU7.js → IndividualOnfido-fz_JSugv.js} +71 -74
  31. package/dist/{IndividualOnfidoDropin-BLYsnG1Z.js → IndividualOnfidoDropin-Duc8XgvR.js} +30 -33
  32. package/dist/{InputText-BFGfIa6S.js → InputText--yiwNMDS.js} +6 -6
  33. package/dist/{Introduction-WI4letTI.js → Introduction-T5fyomwa.js} +4 -4
  34. package/dist/{JpAddress-CN0KeBU3.js → JpAddress-BrDgtuyI.js} +8 -8
  35. package/dist/{LegalRepresentativeDetailsPage-sC9jXdl9.js → LegalRepresentativeDetailsPage-BK0gMJgs.js} +4 -4
  36. package/dist/{ListItem-BSmaxh8U.js → ListItem-B8H6RY9f.js} +2 -2
  37. package/dist/{ManageIndividualComponent-B2X32yuw.js → ManageIndividualComponent-BrBjHu3-.js} +4 -4
  38. package/dist/{ManageTermsOfServiceComponent-BhWr8WWC.js → ManageTermsOfServiceComponent-Dqy8vOUA.js} +4 -4
  39. package/dist/{ManageTransferInstrumentComponent-DZhADt5d.js → ManageTransferInstrumentComponent-Bx6Netyq.js} +12 -12
  40. package/dist/{MaybeModal-CM-ZFMXJ.js → MaybeModal-BwPaMUks.js} +15 -4
  41. package/dist/{Modal-BD_n0sBL.js → Modal-DupiiqVr.js} +4 -4
  42. package/dist/{OnboardingDropinComponent-BJwAxfRi.js → OnboardingDropinComponent-Do1mhuK-.js} +1406 -1731
  43. package/dist/{PayoutDetailsDropin-DLvSAnjp.js → PayoutDetailsDropin-BvEqGrIA.js} +60 -40
  44. package/dist/ProgressBar-B7gTQncy.js +47 -0
  45. package/dist/{Review-CiY3BsOG.js → Review-BBENKcjD.js} +7 -7
  46. package/dist/{RootBusinessDetailsPage-Srl5cazZ.js → RootBusinessDetailsPage-DpdZ4vqu.js} +7 -22
  47. package/dist/{RootBusinessLinesPage-Cfenkise.js → RootBusinessLinesPage-YoF28HOQ.js} +146 -41
  48. package/dist/{RootIndividualDetailsPage-DGAk88Y3.js → RootIndividualDetailsPage-DNivhou9.js} +6 -6
  49. package/dist/{SignPCIComponent-DJi8Bz9v.js → SignPCIComponent-DN5PE2Sc.js} +10 -10
  50. package/dist/{SingpassSelection-Xat6qz4U.js → SingpassSelection-uLhOFdfh.js} +4 -4
  51. package/dist/{SoleProprietorshipPage-CdgDcCTM.js → SoleProprietorshipPage-BUwCiVtH.js} +5 -19
  52. package/dist/{SourceOfFundsPage-Ua8eMuPJ.js → SourceOfFundsPage-D7B5ReUC.js} +25 -25
  53. package/dist/{fieldConfigurations-Cn3dxVBx.js → Spacer-D3By5Y6E.js} +34 -24
  54. package/dist/{StepProgressIndicator-DMCfBNo8.js → StepProgressIndicator-CvbjwImE.js} +1 -1
  55. package/dist/{StoreProvider-DNjJYfsz.js → StoreProvider-BLtYcc3h.js} +130 -98
  56. package/dist/{Summary-CAbxQN0G.js → Summary-Buc_vuRS.js} +4 -4
  57. package/dist/{TaxReportingDropin-OWQZjL5Q.js → TaxReportingDropin-1dhULaM8.js} +16 -16
  58. package/dist/{TrustDetailsPage-C7M97OVV.js → TrustDetailsPage-BtRNXF3Z.js} +27 -27
  59. package/dist/{TrustMemberCompanyPage-4kTYgCkN.js → TrustMemberCompanyPage-B2Khgije.js} +6 -22
  60. package/dist/{TrustMemberIndividualPage-VmdZ3ykT.js → TrustMemberIndividualPage-CL7Yv-FS.js} +4 -4
  61. package/dist/{TrustMemberRoleAndTypePage-DAut1Py_.js → TrustMemberRoleAndTypePage-F_7iqOo2.js} +15 -15
  62. package/dist/{TrustMembersOverview-BcS1acNZ.js → TrustMembersOverview-BfI58H5u.js} +12 -12
  63. package/dist/{UnincorporatedPartnershipIndividualPage-DzBRXrgY.js → UnincorporatedPartnershipIndividualPage-Doc7RvyT.js} +4 -4
  64. package/dist/{UnincorporatedPartnershipMemberCompanyPage-B3JCg123.js → UnincorporatedPartnershipMemberCompanyPage-D5Arebes.js} +6 -22
  65. package/dist/{UnincorporatedPartnershipMemberRoleAndTypePage-DxkpBhtl.js → UnincorporatedPartnershipMemberRoleAndTypePage-oCjJEXYT.js} +9 -9
  66. package/dist/{UnincorporatedPartnershipMembersOverview-CSLXoQ00.js → UnincorporatedPartnershipMembersOverview-Dh6kUlMq.js} +9 -9
  67. package/dist/{VerificationErrorAlert-BiZAvrYw.js → VerificationErrorAlert-DUpyVrCU.js} +4 -4
  68. package/dist/{ViewVerificationStatusComponent-DTi9b2nQ.js → ViewVerificationStatusComponent-BcauKtPB.js} +4 -4
  69. package/dist/adyen-business-financing.js +8 -4
  70. package/dist/adyen-individual-configuration.js +2 -2
  71. package/dist/adyen-individual-status.js +2 -2
  72. package/dist/adyen-kyc-components.js +20 -20
  73. package/dist/adyen-onboarding.js +2 -2
  74. package/dist/adyen-terms-of-service-management.js +2 -2
  75. package/dist/adyen-terms-of-service-status.js +2 -2
  76. package/dist/adyen-transfer-instrument-configuration.js +2 -2
  77. package/dist/adyen-transfer-instrument-management.js +2 -2
  78. package/dist/adyen-verification-status.js +2 -2
  79. package/dist/cross-circle-fill-maan7Z5S.js +17 -0
  80. package/dist/{debouncedInputEvent-Bba-hcta.js → debouncedInputEvent-lq58yTg6.js} +2 -2
  81. package/dist/{documentUtils-C5RFy4hT.js → documentUtils-CdJ4Sc-B.js} +3 -3
  82. package/dist/{dropinUtils-C0F3KZO2.js → dropinUtils-L7Zcqfg9.js} +4 -4
  83. package/dist/en-US-AgtwE4Fl.js +63 -0
  84. package/dist/{getFieldsWithExistingData-DWED-oo0.js → getFieldsWithExistingData-D1vsiEEX.js} +1 -1
  85. package/dist/{getName-BCYK96HK.js → getName-Du9QmiTF.js} +2 -9
  86. package/dist/{hasDataChanged-Bb4fjyW0.js → hasDataChanged-BWko8Wa4.js} +2 -2
  87. package/dist/{iframeWidget-DHRg4j16.js → iframeWidget-CQOg-QHE.js} +4 -4
  88. package/dist/info-filled-SQotHmT9.js +17 -0
  89. package/dist/{localizeDateString-D2VELC17.js → localizeDateString-BJJ8B0Hs.js} +1 -1
  90. package/dist/{mapExistingFile-NFM0K_Ff.js → mapExistingFile-D_q68JAm.js} +2 -2
  91. package/dist/{mapFinancialReportsToFinancialInformation-DTGPz1l3.js → mapFinancialReportsToFinancialInformation-BJZ89yJV.js} +3 -3
  92. package/dist/{mapJpAddressSchemaToAddressLocalizations-CWaLWjPG.js → mapJpAddressSchemaToAddressLocalizations-CHcGrBAs.js} +3 -3
  93. package/dist/{mapLegalEntityToIndividualOnfidoSchema-cQypVW3G.js → mapLegalEntityToIndividualOnfidoSchema-Cqerm1wl.js} +3 -3
  94. package/dist/{mapTransferInstrumentToPayoutAccount-C7KdOS7n.js → mapTransferInstrumentToPayoutAccount-CboZmyKj.js} +1 -1
  95. package/dist/{process-field-configurations-C0KZNWpM.js → process-field-configurations-D7pGneC_.js} +3 -3
  96. package/dist/{resolveEnvironment-DTtUw6Ma.js → resolveEnvironment-Q9yFO0a9.js} +3 -3
  97. package/dist/{rules-BAJYGmzD.js → rules-LsdRG331.js} +5 -5
  98. package/dist/style.css +268 -233
  99. package/dist/styles-CLV89_hH.js +268 -233
  100. package/dist/types/api/companySelection/useCompanySelection.d.ts +2 -18
  101. package/dist/types/components/Business/forms/AdditionalInformation/AdditionalInformation.d.ts +8 -2
  102. package/dist/types/components/Business/forms/BasicInformation/BasicInformation.d.ts +1 -3
  103. package/dist/types/components/Business/forms/BasicInformation/types.d.ts +5 -18
  104. package/dist/types/components/Business/forms/BusinessDetails/types.d.ts +0 -21
  105. package/dist/types/components/Business/forms/BusinessSelection/BusinessSelection.d.ts +13 -2
  106. package/dist/types/components/Business/forms/BusinessSelection/types.d.ts +0 -11
  107. package/dist/types/components/Business/forms/CompanyStructure/CompanyStructure.d.ts +3 -2
  108. package/dist/types/components/Business/forms/CompanyStructure/types.d.ts +0 -6
  109. package/dist/types/components/Business/mapping/businessDetails/mapLegalEntityToBusinessDetailsSchema.d.ts +1 -2
  110. package/dist/types/components/Business/tasks/BusinessDetailsDropin/BusinessDetailsDropin.d.ts +3 -3
  111. package/dist/types/components/Business/tasks/BusinessDetailsDropin/types.d.ts +7 -4
  112. package/dist/types/components/Business/tasks/BusinessDetailsDropin/utils.d.ts +23 -2
  113. package/dist/types/components/BusinessLines/forms/SctaForm/SctaInfoModal.d.ts +3 -0
  114. package/dist/types/components/Contract/tasks/ServiceAgreementDropin/ServiceAgreementDropin.d.ts +1 -1
  115. package/dist/types/components/Contract/tasks/ServiceAgreementDropin/types.d.ts +2 -2
  116. package/dist/types/components/Shared/FormFlow/FormFlow.d.ts +1 -1
  117. package/dist/types/components/Shared/FormFlow/FormFlow.types.d.ts +0 -2
  118. package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
  119. package/dist/types/components/ui/atoms/Link/Link.types.d.ts +1 -1
  120. package/dist/types/components/ui/atoms/Loader/Loader.d.ts +1 -5
  121. package/dist/types/components/ui/atoms/Modal/MaybeModal.d.ts +1 -1
  122. package/dist/types/components/ui/atoms/Svg/svgs.d.ts +4 -0
  123. package/dist/types/context/ExperimentContext/types.d.ts +6 -5
  124. package/dist/types/utils/entityStatusUtil.d.ts +1 -1
  125. package/dist/{types-ah0h1b0B.js → types-B9IVn1Zt.js} +1 -1
  126. package/dist/{types-CZiCRYe4.js → types-CBwe7M_O.js} +1 -1
  127. package/dist/{types-CHr4VLHl.js → types-Dk94b8kx.js} +7 -6
  128. package/dist/{types-Dkw7AD_s.js → types-GIbEJ_5v.js} +1 -1
  129. package/dist/{useAssociatedLegalEntity-Bpoe0x8J.js → useAssociatedLegalEntity-BLnxc-jt.js} +1 -1
  130. package/dist/{useCreateLegalEntity-DtaRGhpP.js → useCreateLegalEntity-BD9PcstC.js} +2 -2
  131. package/dist/{useDataset-C9sM8-li.js → useDataset-BEeSTdTX.js} +4 -4
  132. package/dist/{useForm-qFwVSrMn.js → useForm-ByJEO5yi.js} +10 -9
  133. package/dist/{useGlobalData-CLwdtjOK.js → useGlobalData-CyYyTpXW.js} +5 -5
  134. package/dist/{useMultiForm-dL39Nti3.js → useMultiForm-CEmUnHA9.js} +3 -3
  135. package/dist/{useOnboardingStatus-Dt6w5foF.js → useOnboardingStatus-bt6QJFFl.js} +1 -1
  136. package/dist/{useScenarios-CYjnoPWJ.js → useScenarios-BdwSb0HX.js} +2 -2
  137. package/dist/{useTermsOfServiceStatus-CkN3EPcT.js → useTermsOfServiceStatus-B51PQgY1.js} +1 -1
  138. package/dist/{useToastContext-DWDTMVQy.js → useToastContext-DGtZBX02.js} +2 -2
  139. package/dist/{useUnincorporatedPartnershipMembers-BUD479gc.js → useUnincorporatedPartnershipMembers-C5OUWIiP.js} +4 -4
  140. package/dist/{useUpdateBusinessLines-CuSEV6Pn.js → useUpdateBusinessLines-DKicYyWN.js} +2 -2
  141. package/dist/{useUpdateLegalEntity-D8pso2fd.js → useUpdateLegalEntity-oC3jKNtm.js} +3 -3
  142. package/dist/{utils-d_sm0jYZ.js → utils-BYzUEzaG.js} +6 -6
  143. package/dist/{utils-C1IouPHe.js → utils-DaXTVI0w.js} +3 -3
  144. package/dist/{validate-D3pmCoUJ.js → validate-BTAaa27x.js} +1 -1
  145. package/dist/{validate-CUiZu8-L.js → validate-DBklijcP.js} +1 -1
  146. package/dist/{validationError-XPhMc766.js → validationError-B6JKQAKI.js} +1 -1
  147. package/package.json +2 -2
  148. package/dist/FormFlow-0LZI37J0.js +0 -224
  149. package/dist/en-US-CBsokt1L.js +0 -42
  150. package/dist/types/components/Business/forms/AdditionalInformation/AdditionalInformationMultiform.d.ts +0 -9
  151. package/dist/types/components/Business/forms/BasicInformation/BasicInformationMultiform.d.ts +0 -11
  152. package/dist/types/components/Business/forms/BusinessDetails/BusinessDetails.d.ts +0 -3
  153. package/dist/types/components/Business/forms/BusinessSelection/BusinessSelectionMultiform.d.ts +0 -14
  154. package/dist/types/components/Business/forms/CompanyStructure/CompanyStructureMultiform.d.ts +0 -4
  155. package/dist/types/components/Business/tasks/BusinessDetailsMultiformDropin/BusinessDetailsMultiformDropin.d.ts +0 -5
  156. package/dist/types/components/Business/tasks/BusinessDetailsMultiformDropin/types.d.ts +0 -2
  157. package/dist/types/components/Business/tasks/BusinessDetailsMultiformDropin/utils.d.ts +0 -23
  158. /package/dist/types/components/Business/{tasks/BusinessDetailsMultiformDropin → forms/BusinessDetails}/BusinessDetailsMultiform.d.ts +0 -0
  159. /package/dist/types/components/Business/tasks/{BusinessDetailsMultiformDropin → BusinessDetailsDropin}/validate.d.ts +0 -0
@@ -2,50 +2,45 @@
2
2
  {
3
3
  try {
4
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] = "4c1e5149-ed8e-4a5b-9c4c-27d217da69e7", e._sentryDebugIdIdentifier = "sentry-dbid-4c1e5149-ed8e-4a5b-9c4c-27d217da69e7");
5
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "523e1492-8067-4cc7-81c7-de8ee434a4bb", e._sentryDebugIdIdentifier = "sentry-dbid-523e1492-8067-4cc7-81c7-de8ee434a4bb");
6
6
  } catch (e) {
7
7
  }
8
8
  }
9
9
  ;
10
10
  import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
11
- import { u as useTranslation, B as Button, G as Typography, C as CountryCodes, O as TaskTypes, r as LegalEntityTypes, $ as entriesOf, bC as businessDetailsComponentsKeyMapping, bD as solePropBusinessDetailsKeyMapping, aj as objectsDeepEqual, ap as keysOf, i as isUndefinedOrNull, bE as solePropBusinessDetailsApiKeyMapping, bp as businessDetailsApiKeyMapping, P as createLogger, b8 as filterOutUnwantedAssociationsIfRootLE, W as isEmpty$1, b6 as drop, af as getOwnEntityAssociations, aV as doArraysMatch, K as useAccountHolder, a0 as useAnalyticsContext, Z as useExperimentsContext, o as useSettingsContext, b as useApiContext, a2 as useQueryClient, bF as solePropBusinessDetailsDocumentMapping, bG as businessDetailsDocumentMapping, c as useLegalEntity, R as ROOT_LE, L as Loader } from "./StoreProvider-DNjJYfsz.js";
12
- import { useState, useEffect, useRef, useCallback, useMemo } from "preact/hooks";
13
- import { g as getForms, B as BasicInformation, C as CompanyStructure, A as AdditionalInformation, F as FinancialInformation, h as getDefaultRegistrationNumberType, i as getDefaultVatNumberType, j as FIELDS_NEEDED_FOR_COMPANY_SEARCH, k as companyTypeMetadata, l as documentFormsIds, r as registrationNumberDefaultFieldMetadata, m as inferCompanyRegistrationNumberType, o as registrationNumberDefaultFieldConfig, v as verifiedBusiness, s as setIsBankAccountRequestedForOrganization, p as useCompanySearch, q as useCompanySelection, t as useVerifyTin, w as useClearCompanyData, x as useBusinessLines, y as isNormalizedStringMatch, z as setVerifiedBusiness, D as useDebouncedState, G as legalFormFieldMetadata, H as stockTickerSymbolFieldMetadata, I as stockISINFieldMetadata, J as stockExchangeMICFieldMetadata, K as dateOfIncorporationFieldMetadata, L as industryCodeFieldMetadata, M as eInvoicingCodeFieldMetadata, N as vatAbsenceReasonMetadata, P as defaultFieldMetadata, Q as defaultFieldConfig, R as doingBusinessAsFieldMetadata, S as doingBusinessAsAbsentFieldMetadata, T as useIndustryCodes, U as INDUSTRY_CODE_FIELD, V as VerifiedBusinessCard, W as LEGAL_FORM_FIELDS, X as DBA_NAME_FIELD, Y as DBANameField, Z as BUSINESS_REGISTRATION_NUMBER_FIELD, _ as BusinessRegistrationNumberField, $ as VAT_NUMBER_FIELD, a0 as VatNumberField, a1 as EInvoicingCodeField, a2 as EINVOICING_CODE_FIELD, a3 as IndustryCodeField, a4 as DATE_OF_INCORPORATION_FIELD, a5 as DateOfIncorporationField, a6 as STOCK_EXCHANGE_MIC_FIELD, a7 as StockExchangeMICField, a8 as STOCK_ISIN_FIELD, a9 as StockISINField, aa as STOCK_TICKER_SYMBOL_FIELD, ab as StockTickerSymbolField, ac as ADDITIONAL_INFORMATION_FORM_ID, ad as localizedLegalCompanyNameFieldConfig, ae as defaultFieldMetadata$1, af as defaultFieldConfig$1, ag as defaultFieldMetadataV4, ah as defaultFieldMetadata$2, ai as defaultFieldConfigV4, aj as defaultFieldConfig$2, ak as useLegalCompanyNameField, al as COUNTRY_OF_GOVERNING_LAW_FIELD, am as CountryOfGoverningLawField, an as LEGAL_COMPANY_NAME_FIELD, ao as isBankAccountRequestedForOrganization, ap as companyTypeOptions, aq as useCompanyTypeExamples, E as EntityTypeRadioGroupCard, ar as BusinessSelectionMultiform, as as isVerifiedSingleCompanySearchResult, at as exemptFromRegistrationNumberDefaultFieldMetadata, au as CountryOfGoverningLawFieldValidation, av as CountryFieldValidation, aw as financialInfoValidationWithEmployeesRules, ax as CompanyStructureValidation, ay as tinMatched, az as businessMismatchModalOpen, aA as applyVerifiedBusinessData } from "./OnboardingDropinComponent-BJwAxfRi.js";
14
- import { u as useCreateBusinessLine, a as useUpdateBusinessLine } from "./useUpdateBusinessLines-CuSEV6Pn.js";
15
- import { u as useCreateLegalEntity } from "./useCreateLegalEntity-DtaRGhpP.js";
16
- import { u as useUpdateLegalEntity } from "./useUpdateLegalEntity-D8pso2fd.js";
17
- import { S as SettingNames, I as InputText } from "./InputText-BFGfIa6S.js";
18
- import { h as hasDataChanged } from "./hasDataChanged-Bb4fjyW0.js";
19
- import { a as useGlobalData, b as useStateContext } from "./useGlobalData-CLwdtjOK.js";
20
- import { a as useToastContext } from "./useToastContext-DWDTMVQy.js";
21
- import { c as composePerScenarioFormConfigurations, g as getPropsFromConfigurations } from "./process-field-configurations-C0KZNWpM.js";
22
- import { g as getRequiredForms, a as addValidityToForms, u as useFormComposer } from "./dropinUtils-C0F3KZO2.js";
23
- import { m as mapExistingFile, g as getPageName, u as useScenarioConfiguration } from "./mapExistingFile-NFM0K_Ff.js";
24
- import { a as datasetUtilities, C as Confirm } from "./useDataset-C9sM8-li.js";
25
- import { o as organizationTypesToSkipCompanyStructureForm } from "./utils-d_sm0jYZ.js";
26
- import { F as FormWrapper } from "./FormWrapper-BL7nl_vR.js";
27
- import { a as getDocument, c as createDocumentRequest, b as getFileExtention, d as documentApiUtils } from "./documentUtils-C5RFy4hT.js";
28
- import { g as getFieldsWithExistingData } from "./getFieldsWithExistingData-DWED-oo0.js";
29
- import { f as formatCurrency, A as ALLOWED_SOF_SERVICES } from "./utils-C1IouPHe.js";
30
- import cx from "classnames";
31
- import { a0 as MemoizedDocumentUpload, C as CompanyTypesValues, n as COUNTRIES_USING_COMPANY_SEARCH, a1 as isRegistrationNumberAbsentStateV4Scenario, E as isEmpty, a2 as COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT, r as requestingBanking, e as requestingIssuing, a as getCompanyRegistrationNumberOptions, t as taxInformationDefaultFieldMetadata, a3 as countryToTaxInfoTypeMap, i as taxInformationDefaultFieldConfig, a4 as rules, T as TAX_INFORMATION_FIELD, j as TaxInformationField, u as useAllowedCountries, m as COUNTRY_OF_GOVERNING_LAW_POSSIBLE } from "./IndividualOnfido-Dx7sDvU7.js";
32
- import { M as MemoizedConstitutionalDocument } from "./ConstitutionalDocument-CoMojmXO.js";
33
- import { g as getFormProps, s as summaryItem, m as mergeFieldMetadataIntoProps, c as createFormUtils, H as Header, E as ErrorPanel, C as CountryField, b as COUNTRY_FIELD, a as Link } from "./CountryField-DNOtItPS.js";
34
- import { F as FormContextProvider, a as FormFlow } from "./FormFlow-0LZI37J0.js";
35
- import { u as useMultiForm } from "./useMultiForm-dL39Nti3.js";
11
+ import { u as useTranslation, B as Button, G as Typography, C as CountryCodes, O as TaskTypes, r as LegalEntityTypes, W as isEmpty, a0 as entriesOf, bC as businessDetailsComponentsKeyMapping, bD as solePropBusinessDetailsKeyMapping, aj as objectsDeepEqual, ap as keysOf, i as isUndefinedOrNull, bE as solePropBusinessDetailsApiKeyMapping, bp as businessDetailsApiKeyMapping, P as createLogger, b8 as filterOutUnwantedAssociationsIfRootLE, b6 as drop, af as getOwnEntityAssociations, aV as doArraysMatch, b as useApiContext, a2 as useAnalyticsContext, a1 as useQueryClient, X as useExperimentsContext, o as useSettingsContext, K as useAccountHolder, bF as solePropBusinessDetailsDocumentMapping, bG as businessDetailsDocumentMapping } from "./StoreProvider-BLtYcc3h.js";
12
+ import { useState, useEffect, useMemo, useCallback } from "preact/hooks";
13
+ import { F as FinancialInformation, A as AdditionalInformation, C as CompanyStructure, B as BusinessSelection, h as BasicInformation, i as getDefaultRegistrationNumberType, j as getDefaultVatNumberType, o as operationalAddressIsSameIds, k as FIELDS_NEEDED_FOR_COMPANY_SEARCH, v as verifiedBusiness, l as isVerifiedSingleCompanySearchResult, m as companyTypeMetadata, p as documentFormsIds, r as registrationNumberDefaultFieldMetadata, q as inferCompanyRegistrationNumberType, s as registrationNumberDefaultFieldConfig, t as stockTickerSymbolFieldMetadata, w as stockISINFieldMetadata, x as stockExchangeMICFieldMetadata, y as dateOfIncorporationFieldMetadata, z as industryCodeFieldMetadata, D as eInvoicingCodeFieldMetadata, G as vatAbsenceReasonMetadata, H as exemptFromRegistrationNumberDefaultFieldMetadata, I as doingBusinessAsFieldMetadata, J as doingBusinessAsAbsentFieldMetadata, K as defaultFieldMetadata, L as defaultFieldConfig, M as defaultFieldMetadata$1, N as defaultFieldConfig$1, P as defaultFieldMetadataV4, Q as defaultFieldMetadata$2, R as defaultFieldConfigV4, S as defaultFieldConfig$2, g as getForms, T as useBusinessLines, U as financialInfoValidationWithEmployeesRules, V as tinMatched, W as businessMismatchModalOpen, X as useCompanySearch, Y as useVerifyTin, Z as handleCompanySelection, _ as applyVerifiedBusinessData } from "./OnboardingDropinComponent-Do1mhuK-.js";
14
+ import { u as useCreateBusinessLine, a as useUpdateBusinessLine } from "./useUpdateBusinessLines-DKicYyWN.js";
15
+ import { u as useCreateLegalEntity } from "./useCreateLegalEntity-BD9PcstC.js";
16
+ import { u as useUpdateLegalEntity } from "./useUpdateLegalEntity-oC3jKNtm.js";
17
+ import { F as FormContextProvider, a as FormFlow } from "./FormFlow-Poe97Z6i.js";
18
+ import { a as useToastContext } from "./useToastContext-DGtZBX02.js";
19
+ import { c as composePerScenarioFormConfigurations, g as getPropsFromConfigurations } from "./process-field-configurations-D7pGneC_.js";
20
+ import { a as addValidityToForms, u as useFormComposer } from "./dropinUtils-L7Zcqfg9.js";
21
+ import { u as useMultiForm } from "./useMultiForm-CEmUnHA9.js";
22
+ import { m as mapExistingFile, g as getPageName, u as useScenarioConfiguration } from "./mapExistingFile-D_q68JAm.js";
23
+ import { a as datasetUtilities, C as Confirm } from "./useDataset-BEeSTdTX.js";
24
+ import { a as getDocument, c as createDocumentRequest, b as getFileExtention, d as documentApiUtils } from "./documentUtils-CdJ4Sc-B.js";
25
+ import { g as getFieldsWithExistingData } from "./getFieldsWithExistingData-D1vsiEEX.js";
26
+ import { f as formatCurrency, A as ALLOWED_SOF_SERVICES } from "./utils-DaXTVI0w.js";
27
+ import { u as useFormContext, i as isDateOlderThanAYear, o as mapAddressLabels, p as getKeyForField } from "./Address-DhPHns9b.js";
28
+ import { _ as MemoizedDocumentUpload, C as CompanyTypesValues, l as COUNTRIES_USING_COMPANY_SEARCH, $ as isRegistrationNumberAbsentStateV4Scenario, B as isEmpty$1, a0 as COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT, r as requestingBanking, e as requestingIssuing, a as getCompanyRegistrationNumberOptions, t as taxInformationDefaultFieldMetadata, a1 as countryToTaxInfoTypeMap, f as taxInformationDefaultFieldConfig, a2 as rules } from "./IndividualOnfido-fz_JSugv.js";
29
+ import { M as MemoizedConstitutionalDocument } from "./ConstitutionalDocument-SKhWRnWx.js";
30
+ import { M as Modal, a as ModalContent } from "./Modal-DupiiqVr.js";
36
31
  import { b as mapAddressLocalizationToJpAddressSchema, a as mapApiScriptLocalizationToSchemaFields, m as mapSchemaFieldsToApiScriptLocalization } from "./mapAddressLocalizationToJpAddressSchema-vJWbpAyq.js";
37
- import { m as mapFinancialReportsToFinancialInformation, a as mapFinancialInformationToFinancialReport } from "./mapFinancialReportsToFinancialInformation-DTGPz1l3.js";
38
- import { o as operationalAddressIsSameIds, k as isDateOlderThanAYear, r as mapAddressLabels, s as getKeyForField, i as useFormContext, g as getAddressSchemaForCountry, C as COUNTRIES_WITH_STATES_DATASET, u as useAddressCleanse, b as formatAddressForCleanse, m as mapAddressData, A as Address, d as getNestedTrustedFields, e as getAddressSchemaLabelsByCountry, S as STATE_FIELD, h as StateField } from "./Address-DvJBiSDY.js";
39
- import { f as formatObject, g as getProp } from "./utils-DNSfZiio.js";
40
- import { m as mapJpAddressSchemaToAddressLocalizations, a as mapJpAddressSummary } from "./mapJpAddressSchemaToAddressLocalizations-CWaLWjPG.js";
41
- import { i as isValidationError, p as processValidationErrors, a as isMaintenanceModeError } from "./validationError-XPhMc766.js";
42
- import { r as resolveFieldMetadata } from "./fieldConfigurations-Cn3dxVBx.js";
43
- import { Suspense, lazy } from "preact/compat";
44
- import { C as Checkbox } from "./debouncedInputEvent-Bba-hcta.js";
45
- import { F as Field } from "./useForm-qFwVSrMn.js";
46
- import { L as LegalFormField } from "./Currency-6i-D39G4.js";
47
- import { M as Modal, a as ModalContent } from "./Modal-BD_n0sBL.js";
48
- import { s as summaryStep } from "./Summary-CAbxQN0G.js";
32
+ import { m as mapFinancialReportsToFinancialInformation, a as mapFinancialInformationToFinancialReport } from "./mapFinancialReportsToFinancialInformation-BJZ89yJV.js";
33
+ import { f as formatObject } from "./utils-DNSfZiio.js";
34
+ import { S as SettingNames } from "./InputText--yiwNMDS.js";
35
+ import { m as mapJpAddressSchemaToAddressLocalizations, a as mapJpAddressSummary } from "./mapJpAddressSchemaToAddressLocalizations-CHcGrBAs.js";
36
+ import { o as organizationTypesToSkipCompanyStructureForm } from "./utils-BYzUEzaG.js";
37
+ import { s as summaryItem } from "./CountryField-BaYyWFXk.js";
38
+ import { s as summaryStep } from "./Summary-Buc_vuRS.js";
39
+ import { i as isValidationError, p as processValidationErrors, a as isMaintenanceModeError } from "./validationError-B6JKQAKI.js";
40
+ import { r as resolveFieldMetadata } from "./Spacer-D3By5Y6E.js";
41
+ const stripWhitespace = (str) => str.replace(/\s/g, "");
42
+ const toNormalizedString = (s) => stripWhitespace(s.toLowerCase());
43
+ const isNormalizedStringMatch = (s1, s2) => toNormalizedString(s1) === toNormalizedString(s2);
49
44
  const documentTypes$2 = [
50
45
  { id: "Internal company document", name: "internalCompanyDocument" },
51
46
  { id: "Business registry statement", name: "businessRegistryStatement" }
@@ -448,3126 +443,1316 @@ function TaxDocument({
448
443
  }
449
444
  );
450
445
  }
451
- function BusinessDetails(props) {
452
- const { t } = useTranslation(["common", "business"]);
453
- const { companyStructure } = useGlobalData();
454
- const {
455
- country,
456
- isTopLevelEntity,
457
- activeForm,
458
- showCompanyStructure,
459
- showBusinessSelection,
460
- setShowBusinessSelection,
461
- setShowCompanyStructure,
462
- loading,
463
- searchResults,
464
- taskType,
465
- handleNextClick,
466
- proceedToManualDataEntry
467
- } = props;
468
- const forms = getForms(country);
469
- const formWrapperClasses = (formId) => activeForm?.formId !== formId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper";
470
- const classNames = cx("adyen-kyc-business-details", {
471
- "adyen-kyc-business-details--hide": activeForm?.formId === "summary"
472
- });
473
- const companyType = taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY ? CompanyTypesValues.SOLE_PROPRIETORSHIP : companyStructure?.entityType;
474
- return /* @__PURE__ */ jsxs("div", { className: classNames, children: [
475
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.basicInformation.formId), children: /* @__PURE__ */ jsx(
476
- BasicInformation,
477
- {
478
- ...getFormProps(props, forms.basicInformation.formId),
479
- id: forms.basicInformation.formId,
480
- country,
481
- companyType,
482
- isTopLevelEntity,
483
- showBusinessSelection,
484
- showCompanyStructure,
485
- isActiveForm: activeForm?.formId === forms.basicInformation.formId,
486
- loading,
487
- proceedToManualDataEntry,
488
- searchResults,
489
- setShowBusinessSelection,
490
- setShowCompanyStructure,
491
- handleNextClick,
492
- disableCountry: taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY
493
- }
494
- ) }),
495
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyStructure.formId), children: /* @__PURE__ */ jsx(
496
- CompanyStructure,
497
- {
498
- ...getFormProps(props, forms.companyStructure.formId),
499
- id: forms.companyStructure.formId,
500
- country,
501
- showCompanyStructure
502
- }
503
- ) }),
504
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.additionalInformation.formId), children: /* @__PURE__ */ jsx(
505
- AdditionalInformation,
506
- {
507
- ...getFormProps(props, forms.additionalInformation.formId),
508
- id: forms.additionalInformation.formId,
509
- country,
510
- companyType,
511
- showCompanyStructure
512
- }
513
- ) }),
514
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyRegistrationDocument.formId), children: /* @__PURE__ */ jsx(
515
- RegistrationDocument,
516
- {
517
- ...getFormProps(props, forms.companyRegistrationDocument.formId),
518
- id: forms.companyRegistrationDocument.formId,
519
- country,
520
- companyType
521
- }
522
- ) }),
523
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyTaxDocument.formId), children: country === "US" ? /* @__PURE__ */ jsx(
524
- TaxDocument,
525
- {
526
- ...getFormProps(props, forms.companyTaxDocument.formId),
527
- id: forms.companyTaxDocument.formId,
528
- country,
529
- companyType
530
- }
531
- ) : /* @__PURE__ */ jsx(
532
- MemoizedDocumentUpload,
533
- {
534
- ...getFormProps(props, forms.companyTaxDocument.formId),
535
- id: forms.companyTaxDocument.formId,
536
- heading: t(($) => $["companyTaxDocumentFormHeading"], { ns: "business" }),
537
- description: t(($) => $["companyTaxDocumentFormDescription"], { ns: "business" }),
538
- documentField: "taxDocument",
539
- documentType: "vatDocument",
540
- hidePageCount: true,
541
- guidanceContent: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
542
- /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-upload-field__subtitle", children: [
543
- " ",
544
- t(($) => $["requirements"], { ns: "common" })
545
- ] }),
546
- /* @__PURE__ */ jsxs("ul", { children: [
547
- /* @__PURE__ */ jsx("li", { children: t(($) => $["containsNameOfCompany"], { ns: "business" }) }),
548
- /* @__PURE__ */ jsx("li", { children: t(($) => $["documentShowsTaxIdOfCompany"], { ns: "business" }) }),
549
- /* @__PURE__ */ jsx("li", { children: t(($) => $["issuedByTheTaxAuthority"], { ns: "business" }) })
550
- ] })
551
- ] })
552
- }
553
- ) }),
554
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyProofOfDirectorDocument.formId), children: /* @__PURE__ */ jsx(
555
- ProofOfDirectorDocument,
556
- {
557
- ...getFormProps(props, forms.companyProofOfDirectorDocument.formId),
558
- id: forms.companyProofOfDirectorDocument.formId,
559
- country
560
- }
561
- ) }),
562
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyProofOfSignatoryDocument.formId), children: /* @__PURE__ */ jsx(
563
- ProofOfSignatoryDocument,
564
- {
565
- ...getFormProps(props, forms.companyProofOfSignatoryDocument.formId),
566
- id: forms.companyProofOfSignatoryDocument.formId,
567
- country
568
- }
569
- ) }),
570
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyProofOfOwnershipDocument.formId), children: /* @__PURE__ */ jsx(
571
- ProofOfOwnershipDocument,
572
- {
573
- ...getFormProps(props, forms.companyProofOfOwnershipDocument.formId),
574
- id: forms.companyProofOfOwnershipDocument.formId,
575
- country
576
- }
577
- ) }),
578
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyConstitutionalDocument.formId), children: /* @__PURE__ */ jsx(
579
- MemoizedConstitutionalDocument,
580
- {
581
- ...getFormProps(props, forms.companyConstitutionalDocument.formId),
582
- id: forms.companyConstitutionalDocument.formId,
583
- legalEntityType: LegalEntityTypes.SOLE_PROPRIETORSHIP,
584
- country
585
- }
586
- ) }),
587
- /* @__PURE__ */ jsx("div", { className: formWrapperClasses(forms.companyFinancialInformation.formId), children: /* @__PURE__ */ jsx(
588
- FinancialInformation,
589
- {
590
- ...getFormProps(props, forms.companyFinancialInformation.formId),
591
- id: forms.companyFinancialInformation.formId,
592
- country
593
- }
594
- ) })
595
- ] });
596
- }
597
- const mapApiDocumentToBusinessDetailsDocuments = (entityId) => {
598
- const registrationDocument = getDocument(entityId, "registrationDocument") ?? null;
599
- const taxDocument = getDocument(entityId, "vatDocument") ?? getDocument(entityId, "proofOfOrganizationTaxInfo") ?? null;
600
- const proofOfDirector = getDocument(entityId, "proofOfDirector") ?? null;
601
- const proofOfSignatory = getDocument(entityId, "proofOfSignatory") ?? null;
602
- const proofOfOwnership = getDocument(entityId, "proofOfOwnership") ?? null;
603
- const constitutionalDocument = getDocument(entityId, "constitutionalDocument") ?? null;
604
- return {
605
- companyRegistrationDocument: registrationDocument ? { registrationDocument: [mapExistingFile(getPageName(registrationDocument))] } : void 0,
606
- companyTaxDocument: taxDocument ? { taxDocument: [mapExistingFile(getPageName(taxDocument))] } : void 0,
607
- companyProofOfDirectorDocument: proofOfDirector ? { proofOfDirector: [mapExistingFile(getPageName(proofOfDirector))] } : void 0,
608
- companyProofOfSignatoryDocument: proofOfSignatory ? { proofOfSignatory: [mapExistingFile(getPageName(proofOfSignatory))] } : void 0,
609
- companyProofOfOwnershipDocument: proofOfOwnership ? { proofOfOwnership: [mapExistingFile(getPageName(proofOfOwnership))] } : void 0,
610
- companyConstitutionalDocument: constitutionalDocument ? {
611
- constitutionalDocument: [mapExistingFile(getPageName(constitutionalDocument))]
612
- } : void 0
613
- };
614
- };
615
- const mapBasicInformation = (data) => {
616
- if (!data) return;
617
- return !!data.country && COUNTRIES_USING_COMPANY_SEARCH.includes(data.country) ? data : entriesOf(data).reduce((acc, [field]) => {
618
- if (!FIELDS_NEEDED_FOR_COMPANY_SEARCH.includes(field)) {
619
- return {
620
- ...acc,
621
- [field]: data[field]
622
- };
623
- }
624
- return acc;
625
- }, {});
626
- };
627
- const mapDbaName = (legalEntity) => {
628
- const entity = legalEntity.type === "organization" ? legalEntity.organization : legalEntity.soleProprietorship;
629
- const dbaName = {};
630
- if (typeof entity?.doingBusinessAsAbsent !== "undefined") {
631
- dbaName.hasDoingBusinessAs = !entity.doingBusinessAsAbsent;
632
- } else {
633
- if (entity?.doingBusinessAs) {
634
- dbaName.hasDoingBusinessAs = entity?.doingBusinessAs !== (legalEntity.type === "organization" ? legalEntity.organization?.legalName : legalEntity.soleProprietorship?.name);
635
- } else {
636
- dbaName.hasDoingBusinessAs = void 0;
637
- }
638
- }
639
- if (legalEntity.organization?.doingBusinessAs) {
640
- dbaName.doingBusinessAs = legalEntity.organization?.doingBusinessAs;
641
- }
642
- return dbaName;
643
- };
644
- const mapIsUen = (taxInformation, registrationNumber, country) => {
645
- const currentCountryTaxInfo = taxInformation?.find((taxInfo) => taxInfo.country === country);
646
- if (!currentCountryTaxInfo || country !== "SG") return {};
647
- return {
648
- registrationNumber: currentCountryTaxInfo.type === "UEN" ? currentCountryTaxInfo.number : registrationNumber,
649
- isUen: currentCountryTaxInfo.type === "UEN"
650
- };
651
- };
652
- const mapAdditionalInformation = (data, legalEntity) => {
653
- if (!data) return;
654
- const entity = legalEntity.type === "organization" ? legalEntity.organization : legalEntity.soleProprietorship;
655
- const currentCountry = entity?.registeredAddress.country;
656
- const dbaNameFields = mapDbaName(legalEntity);
657
- const isUen = mapIsUen(
658
- data.taxInformation,
659
- data.registrationNumber,
660
- currentCountry
661
- );
662
- const companyType = legalEntity.type === "organization" ? legalEntity.organization?.type : CompanyTypesValues.SOLE_PROPRIETORSHIP;
663
- const registrationNumberType = getDefaultRegistrationNumberType(
664
- entity?.registrationNumber,
665
- currentCountry,
666
- companyType
667
- );
668
- const vatNumberType = getDefaultVatNumberType(entity?.vatNumber, currentCountry);
669
- const operationalAddressIsSame = entity?.principalPlaceOfBusiness && !objectsDeepEqual(entity?.principalPlaceOfBusiness, entity?.registeredAddress) ? operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME : operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME;
670
- if (entity?.registeredAddress?.localization) {
671
- data.registrationAddress = {
672
- ...data.registrationAddress,
673
- ...mapAddressLocalizationToJpAddressSchema(entity.registeredAddress.localization)
674
- };
675
- }
676
- if (entity?.principalPlaceOfBusiness?.localization) {
677
- data.operationalAddress = {
678
- ...data.operationalAddress,
679
- ...mapAddressLocalizationToJpAddressSchema(entity.principalPlaceOfBusiness.localization)
680
- };
681
- }
682
- const result = entriesOf(data).reduce(
683
- (acc, [field]) => {
684
- if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) {
685
- return {
686
- ...acc,
687
- [field]: data[field]
688
- };
689
- }
690
- if (!FIELDS_NEEDED_FOR_COMPANY_SEARCH.includes(field)) {
691
- return {
692
- ...acc,
693
- [field]: data[field]
694
- };
695
- }
696
- return acc;
697
- },
698
- { operationalAddressIsSame, registrationNumberType, vatNumberType }
699
- );
700
- return { ...result, ...dbaNameFields, ...isUen };
701
- };
702
- const mapLegalNameLocalization = (data) => {
703
- const localization = data.organization?.localization;
704
- if (!localization) return {};
705
- let result = {};
706
- for (const { script, fields } of localization) {
707
- const schemaFieldsFromLocalization = mapApiScriptLocalizationToSchemaFields({
708
- script,
709
- fields: {
710
- // mismatch between API `legalName` and schema `legalCompanyName`
711
- legalCompanyName: fields.legalName
712
- }
713
- });
714
- result = {
715
- ...result,
716
- ...schemaFieldsFromLocalization
717
- };
718
- }
719
- return result;
720
- };
721
- const mapLegalEntityToBusinessDetailsSchema = (legalEntity, parentEntity, isExperimentEnabled) => {
722
- if (!legalEntity) return {};
723
- const {
724
- companyRegistrationDocument,
725
- companyTaxDocument,
726
- companyProofOfDirectorDocument,
727
- companyProofOfSignatoryDocument,
728
- companyProofOfOwnershipDocument,
729
- companyConstitutionalDocument
730
- } = mapApiDocumentToBusinessDetailsDocuments(legalEntity.id);
731
- const buildSolePropSchema = () => {
732
- const solePropData = formatObject(
733
- legalEntity,
734
- solePropBusinessDetailsKeyMapping
735
- );
736
- const country = solePropData?.additionalInformation?.registrationAddress?.country ?? parentEntity?.individual?.residentialAddress.country;
737
- if (legalEntity?.soleProprietorship?.financialReports && solePropData) {
738
- solePropData.companyFinancialInformation = mapFinancialReportsToFinancialInformation(
739
- legalEntity.soleProprietorship.financialReports
740
- );
741
- }
742
- return {
743
- ...solePropData,
744
- basicInformation: {
745
- ...solePropData?.basicInformation,
746
- country
747
- },
748
- companyConstitutionalDocument
749
- };
750
- };
751
- const orgSchema = isExperimentEnabled?.("EnableBusinessDetailsMultiForm") ? {
752
- ...formatObject(legalEntity, businessDetailsComponentsKeyMapping),
753
- businessSelection: {},
754
- companyRegistrationDocument,
755
- companyTaxDocument,
756
- companyProofOfDirectorDocument,
757
- companyProofOfSignatoryDocument,
758
- companyProofOfOwnershipDocument,
759
- companyFinancialInformation: {}
760
- } : {
761
- ...formatObject(legalEntity, businessDetailsComponentsKeyMapping),
762
- companyRegistrationDocument,
763
- companyTaxDocument,
764
- companyProofOfDirectorDocument,
765
- companyProofOfSignatoryDocument,
766
- companyProofOfOwnershipDocument,
767
- companyFinancialInformation: {}
768
- };
769
- const businessDetailsSchema = legalEntity.type === "organization" ? orgSchema : buildSolePropSchema();
770
- return entriesOf(businessDetailsSchema).reduce((componentData, [key]) => {
771
- switch (key) {
772
- case "basicInformation": {
773
- return {
774
- ...componentData,
775
- [key]: {
776
- ...mapBasicInformation(businessDetailsSchema[key]),
777
- ...mapLegalNameLocalization(legalEntity)
778
- }
779
- };
780
- }
781
- case "businessSelection": {
782
- return {
783
- ...componentData,
784
- [key]: {
785
- hasSelectedBusiness: false
786
- }
787
- };
788
- }
789
- case "companyStructure": {
790
- return {
791
- ...componentData,
792
- [key]: {
793
- ...businessDetailsSchema[key]
794
- }
795
- };
796
- }
797
- case "additionalInformation": {
798
- return {
799
- ...componentData,
800
- [key]: mapAdditionalInformation(businessDetailsSchema[key], legalEntity)
801
- };
802
- }
803
- case "companyRegistrationDocument": {
804
- return {
805
- ...componentData,
806
- [key]: businessDetailsSchema[key]
807
- };
808
- }
809
- case "companyTaxDocument": {
810
- return {
811
- ...componentData,
812
- [key]: businessDetailsSchema[key]
813
- };
814
- }
815
- case "companyProofOfDirectorDocument": {
816
- return {
817
- ...componentData,
818
- [key]: businessDetailsSchema[key]
819
- };
820
- }
821
- case "companyProofOfSignatoryDocument": {
822
- return {
823
- ...componentData,
824
- [key]: businessDetailsSchema[key]
825
- };
826
- }
827
- case "companyProofOfOwnershipDocument": {
828
- return {
829
- ...componentData,
830
- [key]: businessDetailsSchema[key]
831
- };
832
- }
833
- case "companyConstitutionalDocument": {
834
- return {
835
- ...componentData,
836
- [key]: businessDetailsSchema[key]
837
- };
838
- }
839
- case "companyFinancialInformation": {
840
- const financialReports = legalEntity.type === "organization" ? legalEntity?.organization?.financialReports : legalEntity?.soleProprietorship?.financialReports;
841
- return financialReports?.length ? {
842
- ...componentData,
843
- [key]: mapFinancialReportsToFinancialInformation(financialReports)
844
- } : componentData;
845
- }
846
- default:
847
- return componentData;
848
- }
849
- }, {});
850
- };
851
- const businessDetailsBase = {
852
- /* Base required fields */
853
- country: { rule: "REQUIRED" },
854
- entityType: { rule: "businessRequiresCompanyType" },
855
- legalCompanyName: { rule: "REQUIRED" },
856
- jaHaniLegalCompanyName: { rule: "japaneseLegalCompanyName" },
857
- jaKanaLegalCompanyName: { rule: "japaneseLegalCompanyName" },
858
- hasDoingBusinessAs: { rule: "REQUIRED" },
859
- doingBusinessAs: { rule: "requireDoingBusinessAsName" },
860
- registrationAddress: { rule: "REQUIRED" },
861
- operationalAddressIsSame: { rule: "REQUIRED" },
862
- /* Base optional fields */
863
- operationalAddress: { rule: "OPTIONAL" },
864
- /* Fields with custom country specific rules */
865
- hasSelectedBusiness: { rule: "requireBusinessSelection" },
866
- stockExchangeMIC: { rule: "ifPubliclyTradedCompany" },
867
- stockISIN: { rule: "ifPubliclyTradedCompany" },
868
- stockTickerSymbol: { rule: "ifPubliclyTradedCompany" },
869
- dateOfIncorporation: { rule: "isDateOfIncorporationRequired" },
870
- stateOrProvince: { rule: "countryUsingCompanySearch" },
871
- registrationNumber: { rule: "countryRequiresRegistrationNumber" },
872
- registrationNumberType: { rule: "registrationNumberType" },
873
- exemptedFromRegistrationNumber: { rule: "companyRegistrationNumberExemptionAllowed" },
874
- eInvoicingCode: { rule: "isEInvoicingCodeEnabled" },
875
- countryOfGoverningLaw: { rule: "countryOfGoverningLawRequired" },
876
- taxDocument: { rule: "ifCountryUsAndTinFailed" },
877
- /* Fields derived from capabilities */
878
- industryCodes: { rule: "isIndustryCodeRequired" }
879
- };
880
- const taxInformationBase = {
881
- vatNumber: { rule: "countryUsesVat" },
882
- vatNumberType: { rule: "vatNumberType" },
883
- exemptedFromVat: { rule: "isVatExempt" },
884
- vatAbsenceReason: { rule: "isVatExempt" },
885
- taxInformation: { rule: "countryUsesTaxId" },
886
- exemptedFromTax: { rule: "countryHasTaxExemptions" },
887
- isUen: { rule: "countryUsesUenOrGst" }
888
- };
889
- const financialInformationBase = {
890
- numberOfEmployees: { rule: "countryRequiresFinancialInformation" },
891
- financialReportingDate: { rule: "isFinancialReportingFieldsRequired" },
892
- currency: { rule: "isFinancialReportingFieldsRequired" },
893
- reportedValueOption: { rule: "isFinancialReportingFieldsRequired" },
894
- annualTurnover: { rule: "annualTurnoverRequired" },
895
- netAssets: { rule: "netAssetsRequired" },
896
- balanceSheetTotal: { rule: "balanceSheetTotalRequired" }
897
- };
898
- const businessDetailsFieldsPerScenario = {
899
- L0: {
900
- country: { rule: "REQUIRED" },
901
- legalCompanyName: { rule: "REQUIRED" },
902
- stateOrProvince: { rule: "countryUsingCompanySearch" },
903
- ...financialInformationBase
904
- },
905
- L1: {
906
- ...businessDetailsBase,
907
- ...financialInformationBase
908
- },
909
- L: {
910
- ...businessDetailsBase,
911
- ...taxInformationBase,
912
- ...financialInformationBase
913
- },
914
- L_PROOFOFADDRESS: {
915
- // TODO this field does not exist
916
- // proofOfAddressDocument: { rule: 'REQUIRED' },
917
- },
918
- L_REGDOC: {
919
- registrationDocument: { rule: "REQUIRED" }
920
- },
921
- L_TAXDOC: {
922
- taxDocument: { rule: "REQUIRED" }
923
- },
924
- L_BAFIN: {
925
- legalForm: { rule: "REQUIRED" }
926
- }
927
- };
928
- const adjustFormData = (oldFormData, newFormData) => {
929
- const schema = Array.from((/* @__PURE__ */ new Set([...keysOf(oldFormData), ...keysOf(newFormData)])).keys());
930
- return schema.reduce((acc, key) => {
931
- const oldValue = oldFormData[key];
932
- const newValue = newFormData[key];
933
- if (!isUndefinedOrNull(newValue)) return { ...acc, [key]: newValue };
934
- if (Array.isArray(oldValue)) return { ...acc, [key]: [] };
935
- if (typeof oldValue === "number") return { ...acc, [key]: null };
936
- if (typeof oldValue === "string") return { ...acc, [key]: "" };
937
- return { ...acc, [key]: "" };
938
- }, {});
939
- };
940
- const setRemovedFieldsOnSchemaToDeletedValue = (newData, existingData) => {
941
- const formIds = Array.from((/* @__PURE__ */ new Set([...keysOf(existingData), ...keysOf(newData)])).keys());
942
- return formIds.reduce((adjusted, formId) => {
943
- const oldFormData = existingData[formId];
944
- const newFormData = newData[formId];
945
- if (isUndefinedOrNull(oldFormData)) return { ...adjusted, [formId]: newFormData };
946
- if (isUndefinedOrNull(newFormData)) return adjusted;
947
- return { ...adjusted, [formId]: adjustFormData(oldFormData, newFormData) };
948
- }, {});
949
- };
950
- const formatFinancialInformationSummary = (data, language, country, dateOfIncorporation) => {
951
- let summary;
952
- if (!data) return void 0;
953
- if (dateOfIncorporation && !isDateOlderThanAYear(dateOfIncorporation)) {
954
- if (country === CountryCodes.UnitedKingdom) {
955
- summary = { numberOfEmployees: `${data.numberOfEmployees}` };
956
- return summary;
957
- }
958
- return void 0;
959
- }
960
- summary = {
961
- currency: data.currency,
962
- financialReportingDate: data.financialReportingDate
963
- };
964
- if (country === CountryCodes.UnitedKingdom) {
965
- summary.numberOfEmployees = `${data.numberOfEmployees}`;
966
- }
967
- if (data.balanceSheetTotal) {
968
- summary.balanceSheetTotal = summaryItem(
969
- "balanceSheetTotal",
970
- formatCurrency(data.balanceSheetTotal, data.currency, language)
971
- );
972
- }
973
- if (data.annualTurnover) {
974
- summary.annualTurnover = formatCurrency(data.annualTurnover, data.currency, language);
975
- }
976
- return summary;
977
- };
978
- const mapBusinessDetailsDocumentToApiDocument = async (data, entityId) => {
979
- const {
980
- companyRegistrationDocument,
981
- companyTaxDocument,
982
- companyProofOfDirectorDocument,
983
- companyConstitutionalDocument,
984
- companyProofOfSignatoryDocument,
985
- companyProofOfOwnershipDocument,
986
- basicInformation
987
- } = data;
988
- const taxDocumentType = COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT.includes(
989
- basicInformation?.country
990
- ) ? "proofOfOrganizationTaxInfo" : "vatDocument";
991
- const documents = await Promise.all([
992
- createDocumentRequest({
993
- entityId,
994
- entityType: "legalEntity",
995
- documentType: "registrationDocument",
996
- page1: companyRegistrationDocument?.registrationDocument?.[0]
997
- }),
998
- createDocumentRequest({
999
- entityId,
1000
- entityType: "legalEntity",
1001
- documentType: taxDocumentType,
1002
- page1: companyTaxDocument?.taxDocument?.[0]
1003
- }),
1004
- createDocumentRequest({
1005
- entityId,
1006
- entityType: "legalEntity",
1007
- documentType: "proofOfDirector",
1008
- page1: companyProofOfDirectorDocument?.proofOfDirector?.[0]
1009
- }),
1010
- createDocumentRequest({
1011
- entityId,
1012
- entityType: "legalEntity",
1013
- documentType: "constitutionalDocument",
1014
- page1: companyConstitutionalDocument?.constitutionalDocument?.[0]
1015
- }),
1016
- createDocumentRequest({
1017
- entityId,
1018
- entityType: "legalEntity",
1019
- documentType: "proofOfSignatory",
1020
- page1: companyProofOfSignatoryDocument?.proofOfSignatory?.[0]
1021
- }),
1022
- createDocumentRequest({
1023
- entityId,
1024
- entityType: "legalEntity",
1025
- documentType: "proofOfOwnership",
1026
- page1: companyProofOfOwnershipDocument?.proofOfOwnership?.[0],
1027
- page2: companyProofOfOwnershipDocument?.proofOfOwnership?.[1]
1028
- })
1029
- ]);
1030
- return documents.filter(Boolean);
1031
- };
1032
- const mapBusinessDetailsSchemaToLegalEntity = (data, accountHolder, isExperimentEnabled) => {
1033
- const requestObj = {
1034
- ...formatObject(
1035
- data,
1036
- accountHolder === "mySoleProprietorName" ? solePropBusinessDetailsApiKeyMapping : businessDetailsApiKeyMapping
1037
- )
1038
- };
1039
- delete requestObj.organization?.legalFormDescription;
1040
- const canSaveRegNumberAbsentState = isExperimentEnabled("EnableRegistrationAndTaxAbsentStatesV4") && isRegistrationNumberAbsentStateV4Scenario(
1041
- data.basicInformation?.country,
1042
- data.companyStructure?.entityType
1043
- );
1044
- const taxData = COUNTRIES_USING_COMPANY_SEARCH.includes(
1045
- data.basicInformation?.country
1046
- ) ? data.basicInformation?.taxInformation : data.additionalInformation?.taxInformation;
1047
- const registrationNumber = COUNTRIES_USING_COMPANY_SEARCH.includes(
1048
- data.basicInformation?.country
1049
- ) ? data.basicInformation?.registrationNumber : data.additionalInformation?.registrationNumber;
1050
- const localization = [
1051
- mapSchemaFieldsToApiScriptLocalization(data.basicInformation ?? {}, "jaHani"),
1052
- mapSchemaFieldsToApiScriptLocalization(data.basicInformation ?? {}, "jaKana")
1053
- ].filter(({ fields }) => !isEmpty(fields)).map(({ script, fields }) => ({
1054
- script,
1055
- // mismatch between API `legalName` and schema `legalCompanyName`
1056
- fields: { legalName: fields.legalCompanyName }
1057
- }));
1058
- const doingBusinessAs = data.additionalInformation?.doingBusinessAs ?? "";
1059
- const entityObject = isEmpty(data.companyStructure) ? requestObj.soleProprietorship : requestObj.organization;
1060
- if (entityObject) {
1061
- if (taxData) {
1062
- entityObject.taxInformation = taxData;
1063
- }
1064
- if (!!requestObj.soleProprietorship && !requestObj.soleProprietorship?.countryOfGoverningLaw && !!data.basicInformation?.country) {
1065
- requestObj.soleProprietorship.countryOfGoverningLaw = data.basicInformation.country;
1066
- }
1067
- if (registrationNumber) {
1068
- entityObject.registrationNumber = registrationNumber;
1069
- if (canSaveRegNumberAbsentState && requestObj.organization) {
1070
- requestObj.organization.registrationNumberAbsent = false;
1071
- }
1072
- }
1073
- if (requestObj.organization && entityObject && localization.length > 0) {
1074
- entityObject.localization = localization;
1075
- }
1076
- if (data.additionalInformation?.exemptedFromRegistrationNumber && canSaveRegNumberAbsentState && requestObj.organization) {
1077
- requestObj.organization.registrationNumberAbsent = data.additionalInformation?.exemptedFromRegistrationNumber;
1078
- }
1079
- if (data.additionalInformation?.vatAbsenceReason) {
1080
- entityObject.vatNumber = "";
1081
- }
1082
- if (isExperimentEnabled("EnableDoingBusinessAsNameV4")) {
1083
- if (typeof data.additionalInformation?.hasDoingBusinessAs !== "undefined") {
1084
- entityObject.doingBusinessAsAbsent = !data.additionalInformation?.hasDoingBusinessAs;
1085
- }
1086
- } else {
1087
- entityObject.doingBusinessAs = doingBusinessAs || data.basicInformation?.legalCompanyName;
1088
- delete entityObject.doingBusinessAsAbsent;
1089
- }
1090
- if (data.additionalInformation?.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME && entityObject.principalPlaceOfBusiness) {
1091
- entityObject.principalPlaceOfBusiness = entityObject.registeredAddress;
1092
- }
1093
- if (entityObject.registeredAddress) {
1094
- const addressLocalizations = mapJpAddressSchemaToAddressLocalizations(
1095
- data.additionalInformation?.registrationAddress
1096
- );
1097
- if (addressLocalizations.length > 0)
1098
- entityObject.registeredAddress.localization = addressLocalizations;
1099
- }
1100
- if (!isEmpty(data.companyFinancialInformation)) {
1101
- const isIncorporationDateDependencyEnabled = isExperimentEnabled(
1102
- "EnableIncorporationDateBasedFinancialValidationForHO"
1103
- );
1104
- entityObject.financialReports = [
1105
- mapFinancialInformationToFinancialReport(
1106
- data.companyFinancialInformation,
1107
- isIncorporationDateDependencyEnabled ? data?.additionalInformation?.dateOfIncorporation : void 0
1108
- )
1109
- ];
1110
- }
1111
- }
1112
- requestObj.type = requestObj.organization ? LegalEntityTypes.ORGANIZATION : LegalEntityTypes.SOLE_PROPRIETORSHIP;
1113
- if (entityObject?.registeredAddress.country === "US") {
1114
- delete entityObject.registrationNumber;
1115
- }
1116
- if (!canSaveRegNumberAbsentState) {
1117
- delete requestObj.organization?.registrationNumberAbsent;
1118
- }
1119
- return requestObj;
1120
- };
1121
- const MANDATORY_FIELDS_BUSINESS_DETAILS = [
1122
- "basicInformation.legalCompanyName",
1123
- "basicInformation.country"
1124
- ];
1125
- const canSubmit = (data) => MANDATORY_FIELDS_BUSINESS_DETAILS.every((detail) => {
1126
- const value = getProp(data, detail);
1127
- return !isEmpty$1(value);
1128
- });
1129
- const isDocumentsRequired = (forms) => forms.some((form) => documentFormsIds.includes(form.formId));
1130
- const removeConditionalForms = (forms, isSkippingCompanyStructure) => isSkippingCompanyStructure ? forms.filter((f) => f.formId !== "companyStructure" && f.formId !== "companyType") : forms;
1131
- const formatBasicInformation = (data, datasetUtils, companyType, isCountryOfGoverningLawEnabled) => {
1132
- const country = data?.country;
1133
- const registrationNumberLabel = resolveFieldMetadata(
1134
- registrationNumberDefaultFieldConfig[country],
1135
- {
1136
- companyType,
1137
- registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data?.registrationNumber, country, companyType) : getCompanyRegistrationNumberOptions(country, companyType)?.[0]?.id
1138
- },
1139
- registrationNumberDefaultFieldMetadata
1140
- ).label;
1141
- const taxIdLabel = resolveFieldMetadata(
1142
- taxInformationDefaultFieldConfig[country],
1143
- {
1144
- taxIdNumberType: countryToTaxInfoTypeMap[country] ?? void 0,
1145
- // TODO use type selector
1146
- companyType: void 0
1147
- },
1148
- taxInformationDefaultFieldMetadata
1149
- ).label;
1150
- const countryOfGoverningLaw = getCountryOfGoverningLaw(isCountryOfGoverningLawEnabled, data);
1151
- return {
1152
- ["legalCompanyName"]: data.legalCompanyName,
1153
- country: datasetUtils.getCountryName(data.country),
1154
- [getKeyForField("stateOrProvince", data.country)]: datasetUtils.getStateName(
1155
- data.stateOrProvince,
1156
- data.country
1157
- ),
1158
- [taxIdLabel]: data.taxInformation?.find((taxId) => data.country === taxId.country)?.number,
1159
- [registrationNumberLabel]: data.registrationNumber,
1160
- countryOfGoverningLaw: datasetUtils.getCountryName(countryOfGoverningLaw)
1161
- };
1162
- };
1163
- const formatAdditionalInformation = (data, country, companyType, t) => {
1164
- const registrationNumberLabel = resolveFieldMetadata(
1165
- registrationNumberDefaultFieldConfig[country],
1166
- {
1167
- companyType,
1168
- registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data?.registrationNumber, country, companyType) : getCompanyRegistrationNumberOptions(country, companyType)?.[0]?.id
1169
- },
1170
- registrationNumberDefaultFieldMetadata
1171
- ).label;
1172
- const taxIdLabel = resolveFieldMetadata(
1173
- taxInformationDefaultFieldConfig[country],
1174
- {
1175
- taxIdNumberType: countryToTaxInfoTypeMap[country] ?? void 0,
1176
- // TODO use type selector
1177
- companyType: void 0
1178
- },
1179
- taxInformationDefaultFieldMetadata
1180
- ).label;
1181
- return {
1182
- ["businessStructure"]: data.legalFormLabel,
1183
- ["doingBusinessAs"]: data.doingBusinessAs,
1184
- ["industry"]: data.industryCodes?.[0].name,
1185
- [registrationNumberLabel]: data.registrationNumber,
1186
- [taxIdLabel]: data.isUen ? void 0 : data.taxInformation?.find((taxId) => country === taxId.country)?.number,
1187
- ["vatNumber"]: data.vatNumber,
1188
- ["vatAbsenceReason"]: data.vatAbsenceReason ? t(($) => $[data.vatAbsenceReason], { ns: "common" }) : void 0,
1189
- ["dateOfIncorporation"]: data.dateOfIncorporation,
1190
- ["stockExchangeMIC"]: data.stockExchangeMIC,
1191
- ["stockISIN"]: data.stockISIN,
1192
- ["stockTickerSymbol"]: data.stockTickerSymbol,
1193
- ["eInvoicingCode"]: data.eInvoicingCode
1194
- };
1195
- };
1196
- const formatDataForSummary = (data, forms, t, language, isExperimentEnabled) => {
1197
- const datasetUtils = datasetUtilities(language);
1198
- return entriesOf(data).reduce((summaryData, [form]) => {
1199
- if (!form || !data[form]) return summaryData;
1200
- const isCountryOfGoverningLawEnabled = isExperimentEnabled(
1201
- "EnableCountryOfGoverningLawForUKCompanies"
1202
- );
1203
- switch (form) {
446
+ function BusinessDetailsMultiform({
447
+ taskType,
448
+ country,
449
+ activeForm,
450
+ shouldValidate,
451
+ problems = {},
452
+ handleNextClick,
453
+ handleBackClick,
454
+ setLoadingStatus,
455
+ isTopLevelEntity
456
+ }) {
457
+ const { t } = useTranslation(["common", "business"]);
458
+ const { form } = useFormContext();
459
+ const companyType = taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY ? CompanyTypesValues.SOLE_PROPRIETORSHIP : form.data.companyStructure?.entityType;
460
+ function handleChange(formName, fieldName, mode) {
461
+ return form.handleChangeFor(fieldName, formName, mode);
462
+ }
463
+ const renderActiveForm = (activeForm2) => {
464
+ switch (activeForm2.formId) {
1204
465
  case "basicInformation":
1205
- return {
1206
- ...summaryData,
1207
- [form]: formatBasicInformation(
1208
- data[form],
1209
- datasetUtils,
1210
- data.companyStructure?.entityType,
1211
- isCountryOfGoverningLawEnabled
1212
- )
1213
- };
466
+ return /* @__PURE__ */ jsx(
467
+ BasicInformation,
468
+ {
469
+ id: activeForm2.formId,
470
+ country,
471
+ shouldValidate,
472
+ validationErrors: problems.validationErrors?.[activeForm2.formId],
473
+ verificationErrors: problems.verificationErrors?.[activeForm2.formId],
474
+ companyType,
475
+ isTopLevelEntity,
476
+ disableCountry: taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY
477
+ }
478
+ );
479
+ case "businessSelection":
480
+ return /* @__PURE__ */ jsx(
481
+ BusinessSelection,
482
+ {
483
+ id: activeForm2.formId,
484
+ country,
485
+ shouldValidate,
486
+ validationErrors: problems.validationErrors?.[activeForm2.formId],
487
+ verificationErrors: problems.verificationErrors?.[activeForm2.formId],
488
+ handleNextClick,
489
+ handleBackClick,
490
+ setLoadingStatus
491
+ }
492
+ );
1214
493
  case "companyStructure":
1215
- return {
1216
- ...summaryData,
1217
- [form]: {
1218
- entityType: t(
1219
- ($) => $[companyTypeMetadata[data["companyStructure"]?.entityType]?.name],
1220
- {
1221
- ns: "business"
1222
- }
1223
- )
494
+ return /* @__PURE__ */ jsx(
495
+ CompanyStructure,
496
+ {
497
+ id: activeForm2.formId,
498
+ country,
499
+ shouldValidate,
500
+ validationErrors: problems.validationErrors?.[activeForm2.formId],
501
+ verificationErrors: problems.verificationErrors?.[activeForm2.formId]
1224
502
  }
1225
- };
503
+ );
1226
504
  case "additionalInformation":
1227
- return {
1228
- ...summaryData,
1229
- [form]: {
1230
- hasInnerForms: true,
1231
- additionalInformationFormName: formatAdditionalInformation(
1232
- data[form],
1233
- data.basicInformation?.country,
1234
- data.companyStructure?.entityType,
1235
- t
1236
- ),
1237
- registrationAddress: data.basicInformation?.country === CountryCodes.Japan ? mapJpAddressSummary(data[form].registrationAddress, datasetUtils) : mapAddressLabels(data[form].registrationAddress, datasetUtils),
1238
- operationalAddress: data[form].operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME ? data.basicInformation?.country === CountryCodes.Japan ? mapJpAddressSummary(data[form].operationalAddress, datasetUtils) : mapAddressLabels(data[form].operationalAddress, datasetUtils) : void 0
1239
- }
1240
- };
1241
- case "companyRegistrationDocument":
1242
- if (!isDocumentsRequired(forms)) return summaryData;
1243
- return {
1244
- ...summaryData,
1245
- [form]: {
1246
- companyRegistrationDocument: {
1247
- fileName: data[form].registrationDocument?.[0]?.name
1248
- }
505
+ return /* @__PURE__ */ jsx(
506
+ AdditionalInformation,
507
+ {
508
+ id: activeForm2.formId,
509
+ country,
510
+ companyType,
511
+ shouldValidate,
512
+ validationErrors: problems.validationErrors?.[activeForm2.formId],
513
+ verificationErrors: problems.verificationErrors?.[activeForm2.formId]
1249
514
  }
1250
- };
515
+ );
1251
516
  case "companyTaxDocument":
1252
- if (!isDocumentsRequired(forms)) return summaryData;
1253
- return {
1254
- ...summaryData,
1255
- [form]: {
1256
- companyTaxDocument: {
1257
- fileName: data[form].taxDocument?.[0]?.name
1258
- }
517
+ return country === "US" ? /* @__PURE__ */ jsx(
518
+ TaxDocument,
519
+ {
520
+ id: activeForm2.formId,
521
+ country,
522
+ companyType,
523
+ shouldValidate,
524
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
525
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {},
526
+ data: form.data.companyTaxDocument,
527
+ errors: form.errors.companyTaxDocument,
528
+ valid: form.valid.companyTaxDocument,
529
+ allFields: form.allFields?.companyTaxDocument,
530
+ requiredFields: form.requiredFields?.companyTaxDocument,
531
+ optionalFields: form.optionalFields?.companyTaxDocument,
532
+ trustedFields: form.trustedFields?.companyTaxDocument,
533
+ handleFieldChange: () => handleChange("companyTaxDocument", "taxDocument")
1259
534
  }
1260
- };
535
+ ) : /* @__PURE__ */ jsx(
536
+ MemoizedDocumentUpload,
537
+ {
538
+ id: activeForm2.formId,
539
+ country,
540
+ companyType,
541
+ shouldValidate,
542
+ heading: t(($) => $["companyTaxDocumentFormHeading"], { ns: "business" }),
543
+ description: t(($) => $["companyTaxDocumentFormDescription"], { ns: "business" }),
544
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
545
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {},
546
+ data: form.data.companyTaxDocument,
547
+ errors: form.errors.companyTaxDocument,
548
+ valid: form.valid.companyTaxDocument,
549
+ allFields: form.allFields?.companyTaxDocument,
550
+ requiredFields: form.requiredFields?.companyTaxDocument,
551
+ optionalFields: form.optionalFields?.companyTaxDocument,
552
+ trustedFields: form.trustedFields?.companyTaxDocument,
553
+ handleFieldChange: () => handleChange("companyTaxDocument", "taxDocument"),
554
+ documentField: "taxDocument",
555
+ documentType: "vatDocument",
556
+ hidePageCount: true,
557
+ guidanceContent: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
558
+ /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-upload-field__subtitle", children: [
559
+ " ",
560
+ t(($) => $["requirements"], { ns: "common" })
561
+ ] }),
562
+ /* @__PURE__ */ jsxs("ul", { children: [
563
+ /* @__PURE__ */ jsx("li", { children: t(($) => $["containsNameOfCompany"], { ns: "business" }) }),
564
+ /* @__PURE__ */ jsx("li", { children: t(($) => $["documentShowsTaxIdOfCompany"], { ns: "business" }) }),
565
+ /* @__PURE__ */ jsx("li", { children: t(($) => $["issuedByTheTaxAuthority"], { ns: "business" }) })
566
+ ] })
567
+ ] })
568
+ }
569
+ );
570
+ case "companyRegistrationDocument":
571
+ return /* @__PURE__ */ jsx(
572
+ RegistrationDocument,
573
+ {
574
+ id: activeForm2.formId,
575
+ country,
576
+ companyType,
577
+ data: form.data.companyRegistrationDocument,
578
+ errors: form.errors.companyRegistrationDocument,
579
+ valid: form.valid.companyRegistrationDocument,
580
+ allFields: form.allFields?.companyRegistrationDocument,
581
+ requiredFields: form.requiredFields?.companyRegistrationDocument,
582
+ optionalFields: form.optionalFields?.companyRegistrationDocument,
583
+ trustedFields: form.trustedFields?.companyRegistrationDocument,
584
+ handleFieldChange: () => handleChange("companyRegistrationDocument", "registrationDocument"),
585
+ shouldValidate,
586
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
587
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
588
+ }
589
+ );
1261
590
  case "companyProofOfDirectorDocument":
1262
- if (!isDocumentsRequired(forms)) return summaryData;
1263
- return {
1264
- ...summaryData,
1265
- [form]: {
1266
- companyProofOfDirectorDocument: {
1267
- fileName: data[form].proofOfDirector?.[0]?.name
1268
- }
591
+ return /* @__PURE__ */ jsx(
592
+ ProofOfDirectorDocument,
593
+ {
594
+ id: activeForm2.formId,
595
+ country,
596
+ data: form.data?.companyProofOfDirectorDocument,
597
+ errors: form.errors.companyProofOfDirectorDocument,
598
+ valid: form.valid.companyProofOfDirectorDocument,
599
+ allFields: form.allFields?.companyProofOfDirectorDocument,
600
+ requiredFields: form.requiredFields?.companyProofOfDirectorDocument,
601
+ optionalFields: form.optionalFields?.companyProofOfDirectorDocument,
602
+ trustedFields: form.trustedFields?.companyProofOfDirectorDocument,
603
+ handleFieldChange: () => handleChange("companyProofOfDirectorDocument", "proofOfDirector"),
604
+ shouldValidate,
605
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
606
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
607
+ }
608
+ );
609
+ case "companyProofOfSignatoryDocument":
610
+ return /* @__PURE__ */ jsx(
611
+ ProofOfSignatoryDocument,
612
+ {
613
+ id: activeForm2.formId,
614
+ country,
615
+ data: form.data?.companyProofOfSignatoryDocument,
616
+ errors: form.errors.companyProofOfSignatoryDocument,
617
+ valid: form.valid.companyProofOfSignatoryDocument,
618
+ allFields: form.allFields?.companyProofOfSignatoryDocument,
619
+ requiredFields: form.requiredFields?.companyProofOfSignatoryDocument,
620
+ optionalFields: form.optionalFields?.companyProofOfSignatoryDocument,
621
+ trustedFields: form.trustedFields?.companyProofOfSignatoryDocument,
622
+ handleFieldChange: () => handleChange("companyProofOfSignatoryDocument", "proofOfSignatory"),
623
+ shouldValidate,
624
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
625
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
626
+ }
627
+ );
628
+ case "companyProofOfOwnershipDocument":
629
+ return /* @__PURE__ */ jsx(
630
+ ProofOfOwnershipDocument,
631
+ {
632
+ id: activeForm2.formId,
633
+ country,
634
+ data: form.data?.companyProofOfOwnershipDocument,
635
+ errors: form.errors.companyProofOfOwnershipDocument,
636
+ valid: form.valid.companyProofOfOwnershipDocument,
637
+ allFields: form.allFields?.companyProofOfOwnershipDocument,
638
+ requiredFields: form.requiredFields?.companyProofOfOwnershipDocument,
639
+ optionalFields: form.optionalFields?.companyProofOfOwnershipDocument,
640
+ trustedFields: form.trustedFields?.companyProofOfOwnershipDocument,
641
+ handleFieldChange: () => handleChange("companyProofOfOwnershipDocument", "proofOfOwnership"),
642
+ shouldValidate,
643
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
644
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
1269
645
  }
1270
- };
1271
- case "companyProofOfSignatoryDocument":
1272
- if (!isDocumentsRequired(forms)) return summaryData;
1273
- return {
1274
- ...summaryData,
1275
- [form]: {
1276
- companyProofOfSignatoryDocument: {
1277
- fileName: data[form].proofOfSignatory?.[0]?.name
1278
- }
646
+ );
647
+ case "companyConstitutionalDocument":
648
+ return /* @__PURE__ */ jsx(
649
+ MemoizedConstitutionalDocument,
650
+ {
651
+ id: activeForm2.formId,
652
+ legalEntityType: LegalEntityTypes.SOLE_PROPRIETORSHIP,
653
+ country,
654
+ data: form.data?.companyConstitutionalDocument,
655
+ errors: form.errors.companyConstitutionalDocument,
656
+ valid: form.valid.companyConstitutionalDocument,
657
+ allFields: form.allFields?.companyConstitutionalDocument,
658
+ requiredFields: form.requiredFields?.companyConstitutionalDocument,
659
+ optionalFields: form.optionalFields?.companyConstitutionalDocument,
660
+ trustedFields: form.trustedFields?.companyConstitutionalDocument,
661
+ handleFieldChange: () => handleChange("companyConstitutionalDocument", "constitutionalDocument"),
662
+ shouldValidate,
663
+ fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
664
+ formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
1279
665
  }
1280
- };
1281
- case "companyProofOfOwnershipDocument":
1282
- if (!isDocumentsRequired(forms)) return summaryData;
1283
- return {
1284
- ...summaryData,
1285
- [form]: {
1286
- companyProofOfOwnershipDocument: {
1287
- fileName: data[form].proofOfOwnership?.map((doc) => doc.name).join("\n")
1288
- }
666
+ );
667
+ case "companyFinancialInformation":
668
+ return /* @__PURE__ */ jsx(
669
+ FinancialInformation,
670
+ {
671
+ multiForm: form,
672
+ id: activeForm2.formId,
673
+ country,
674
+ data: form.data?.companyFinancialInformation,
675
+ allFields: form.allFields?.companyFinancialInformation,
676
+ requiredFields: form.requiredFields?.companyFinancialInformation,
677
+ optionalFields: form.optionalFields?.companyFinancialInformation,
678
+ trustedFields: form.trustedFields?.companyFinancialInformation,
679
+ shouldValidate
1289
680
  }
1290
- };
1291
- case "companyFinancialInformation": {
1292
- const isIncorporationDateDependencyEnabled = isExperimentEnabled(
1293
- "EnableIncorporationDateBasedFinancialValidationForHO"
1294
681
  );
1295
- return {
1296
- ...summaryData,
1297
- [form]: formatFinancialInformationSummary(
1298
- data[form],
1299
- language,
1300
- data?.basicInformation?.country,
1301
- isIncorporationDateDependencyEnabled ? data?.additionalInformation?.dateOfIncorporation : void 0
1302
- )
1303
- };
1304
- }
1305
682
  default:
1306
- return summaryData;
1307
- }
1308
- }, {});
1309
- };
1310
- async function submitDocuments({
1311
- data,
1312
- legalEntity,
1313
- forms,
1314
- documentUtils,
1315
- userEvents
1316
- }) {
1317
- if (!isDocumentsRequired(forms)) return;
1318
- const logger = createLogger();
1319
- const formattedDocument = await mapBusinessDetailsDocumentToApiDocument(data, legalEntity.id);
1320
- try {
1321
- if (formattedDocument) {
1322
- await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
1323
- formattedDocument.forEach((doc) => {
1324
- userEvents?.addTaskEvent("Success", {
1325
- actionType: "upload",
1326
- documentType: doc.type,
1327
- fileExtention: doc.attachments?.map((item) => getFileExtention(item.pageName)).filter((item) => item !== void 0) ?? []
1328
- });
1329
- });
683
+ return null;
1330
684
  }
1331
- } catch (err) {
1332
- logger.error(err);
1333
- userEvents.addTaskEvent("Encountered error", {
1334
- actionType: "upload",
1335
- returnType: err.errorCode,
1336
- returnValue: err.title ?? err.message
1337
- });
1338
- }
685
+ };
686
+ return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-business-details", children: /* @__PURE__ */ jsx("div", { className: "adyen-kyc-form-wrapper", children: renderActiveForm(activeForm) }) });
1339
687
  }
1340
- async function submit({
1341
- data,
1342
- legalEntityResponse,
1343
- associatedLegalArrangement,
1344
- nestedLegalEntity,
1345
- nestedLegalEntityDetails,
1346
- problems,
1347
- taskType,
1348
- accountHolder,
1349
- forms,
1350
- documentUtils,
1351
- t,
1352
- showToast,
1353
- setLoadingStatus,
1354
- setProblems,
1355
- handleUpdateLegalEntity,
1356
- createLegalEntity,
1357
- onExternalSubmit,
1358
- isExperimentEnabled,
1359
- userEvents,
1360
- efpBusinessLines,
1361
- createBusinessLine,
1362
- updateBusinessLine
1363
- }) {
1364
- const logger = createLogger();
1365
- setLoadingStatus("loading");
1366
- let trackingPayload = {
1367
- actionType: "submit",
1368
- companyStructure: data.companyStructure?.entityType,
1369
- countryOfRegistration: data.basicInformation?.country,
1370
- legalEntityName: accountHolder === "theCompanyIWorkFor" ? data.basicInformation?.legalCompanyName : void 0,
1371
- // Only send legalCompanyName for organizations
1372
- usedAdditionalAddress: data.additionalInformation?.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME
688
+ const CompanyStructureValidation = {
689
+ entityType: {
690
+ modes: ["blur"],
691
+ validate: (entityType) => !isEmpty(entityType),
692
+ errorMessage: "fieldIsRequired"
693
+ }
694
+ };
695
+ const mapApiDocumentToBusinessDetailsDocuments = (entityId) => {
696
+ const registrationDocument = getDocument(entityId, "registrationDocument") ?? null;
697
+ const taxDocument = getDocument(entityId, "vatDocument") ?? getDocument(entityId, "proofOfOrganizationTaxInfo") ?? null;
698
+ const proofOfDirector = getDocument(entityId, "proofOfDirector") ?? null;
699
+ const proofOfSignatory = getDocument(entityId, "proofOfSignatory") ?? null;
700
+ const proofOfOwnership = getDocument(entityId, "proofOfOwnership") ?? null;
701
+ const constitutionalDocument = getDocument(entityId, "constitutionalDocument") ?? null;
702
+ return {
703
+ companyRegistrationDocument: registrationDocument ? { registrationDocument: [mapExistingFile(getPageName(registrationDocument))] } : void 0,
704
+ companyTaxDocument: taxDocument ? { taxDocument: [mapExistingFile(getPageName(taxDocument))] } : void 0,
705
+ companyProofOfDirectorDocument: proofOfDirector ? { proofOfDirector: [mapExistingFile(getPageName(proofOfDirector))] } : void 0,
706
+ companyProofOfSignatoryDocument: proofOfSignatory ? { proofOfSignatory: [mapExistingFile(getPageName(proofOfSignatory))] } : void 0,
707
+ companyProofOfOwnershipDocument: proofOfOwnership ? { proofOfOwnership: [mapExistingFile(getPageName(proofOfOwnership))] } : void 0,
708
+ companyConstitutionalDocument: constitutionalDocument ? {
709
+ constitutionalDocument: [mapExistingFile(getPageName(constitutionalDocument))]
710
+ } : void 0
1373
711
  };
1374
- const entityToUpdate = (() => {
1375
- switch (taskType) {
1376
- case TaskTypes.SOLE_PROPRIETOR_COMPANY:
1377
- return associatedLegalArrangement;
1378
- case TaskTypes.TRUST_MEMBER_COMPANY:
1379
- case TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY:
1380
- return nestedLegalEntity;
1381
- case TaskTypes.BUSINESS_DETAILS:
1382
- default:
1383
- return legalEntityResponse;
1384
- }
1385
- })();
1386
- const handleSubmitLegalEntity = async (legalEntity) => {
1387
- if (taskType === TaskTypes.TRUST_MEMBER_COMPANY && !nestedLegalEntity?.id || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY && !nestedLegalEntity?.id || taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && !associatedLegalArrangement?.id) {
1388
- return await createLegalEntity(legalEntity);
1389
- } else {
1390
- return handleUpdateLegalEntity({
1391
- ...drop("type").from(legalEntity),
1392
- id: entityToUpdate?.id ?? legalEntityResponse.id
1393
- });
712
+ };
713
+ const mapBasicInformation = (data) => {
714
+ if (!data) return;
715
+ return !!data.country && COUNTRIES_USING_COMPANY_SEARCH.includes(data.country) ? data : entriesOf(data).reduce((acc, [field]) => {
716
+ if (!FIELDS_NEEDED_FOR_COMPANY_SEARCH.includes(field)) {
717
+ return {
718
+ ...acc,
719
+ [field]: data[field]
720
+ };
1394
721
  }
1395
- };
1396
- const associateLegalEntityWithParent = async ({
1397
- legalEntity,
1398
- associatedLegalArrangement: associatedLegalArrangement2,
1399
- nestedLegalEntityDetails: nestedLegalEntityDetails2
1400
- }) => {
1401
- if (nestedLegalEntityDetails2 && associatedLegalArrangement2) {
1402
- const existingEntityAssociations = getOwnEntityAssociations(associatedLegalArrangement2);
1403
- const existingRoles = existingEntityAssociations.filter((ea) => ea.legalEntityId === associatedLegalArrangement2.id).map(({ type }) => type);
1404
- const newRoles = nestedLegalEntityDetails2?.roles ?? [];
1405
- const rolesChanged = !doArraysMatch(existingRoles, newRoles);
1406
- if (rolesChanged) {
1407
- const updatedAssociations = {
1408
- entityAssociations: [
1409
- ...newRoles.map((role) => ({
1410
- type: role,
1411
- legalEntityId: legalEntity.id
1412
- })) || [],
1413
- ...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
1414
- ]
1415
- };
1416
- await handleUpdateLegalEntity({
1417
- ...updatedAssociations,
1418
- id: associatedLegalArrangement2.id
1419
- });
1420
- }
1421
- return;
722
+ return acc;
723
+ }, {});
724
+ };
725
+ const mapDbaName = (legalEntity) => {
726
+ const entity = legalEntity.type === "organization" ? legalEntity.organization : legalEntity.soleProprietorship;
727
+ const dbaName = {};
728
+ if (typeof entity?.doingBusinessAsAbsent !== "undefined") {
729
+ dbaName.hasDoingBusinessAs = !entity.doingBusinessAsAbsent;
730
+ } else {
731
+ if (entity?.doingBusinessAs) {
732
+ dbaName.hasDoingBusinessAs = entity?.doingBusinessAs !== (legalEntity.type === "organization" ? legalEntity.organization?.legalName : legalEntity.soleProprietorship?.name);
1422
733
  } else {
1423
- const updatedAssociations = {
1424
- entityAssociations: [
1425
- {
1426
- type: LegalEntityTypes.SOLE_PROPRIETORSHIP,
1427
- legalEntityId: legalEntity.id
1428
- }
1429
- ]
1430
- };
1431
- await handleUpdateLegalEntity({ ...updatedAssociations, id: legalEntityResponse.id });
734
+ dbaName.hasDoingBusinessAs = void 0;
1432
735
  }
1433
- };
1434
- const savedLegalEntityData = legalEntityResponse ? mapLegalEntityToBusinessDetailsSchema(legalEntityResponse, void 0, isExperimentEnabled) : null;
1435
- const filteredData = savedLegalEntityData ? setRemovedFieldsOnSchemaToDeletedValue(data, savedLegalEntityData) : data;
1436
- if (filteredData?.additionalInformation && !filteredData?.additionalInformation?.taxInformation) {
1437
- filteredData.additionalInformation.taxInformation = void 0;
1438
736
  }
1439
- const isCountryOfGoverningLawEnabled = isExperimentEnabled(
1440
- "EnableCountryOfGoverningLawForUKCompanies"
737
+ if (legalEntity.organization?.doingBusinessAs) {
738
+ dbaName.doingBusinessAs = legalEntity.organization?.doingBusinessAs;
739
+ }
740
+ return dbaName;
741
+ };
742
+ const mapIsUen = (taxInformation, registrationNumber, country) => {
743
+ const currentCountryTaxInfo = taxInformation?.find((taxInfo) => taxInfo.country === country);
744
+ if (!currentCountryTaxInfo || country !== "SG") return {};
745
+ return {
746
+ registrationNumber: currentCountryTaxInfo.type === "UEN" ? currentCountryTaxInfo.number : registrationNumber,
747
+ isUen: currentCountryTaxInfo.type === "UEN"
748
+ };
749
+ };
750
+ const mapAdditionalInformation = (data, legalEntity) => {
751
+ if (!data) return;
752
+ const entity = legalEntity.type === "organization" ? legalEntity.organization : legalEntity.soleProprietorship;
753
+ const currentCountry = entity?.registeredAddress.country;
754
+ const dbaNameFields = mapDbaName(legalEntity);
755
+ const isUen = mapIsUen(
756
+ data.taxInformation,
757
+ data.registrationNumber,
758
+ currentCountry
1441
759
  );
1442
- const countryOfGoverningLaw = getCountryOfGoverningLaw(
1443
- isCountryOfGoverningLawEnabled,
1444
- filteredData?.basicInformation
760
+ const companyType = legalEntity.type === "organization" ? legalEntity.organization?.type : CompanyTypesValues.SOLE_PROPRIETORSHIP;
761
+ const registrationNumberType = getDefaultRegistrationNumberType(
762
+ entity?.registrationNumber,
763
+ currentCountry,
764
+ companyType
1445
765
  );
1446
- if (filteredData?.basicInformation) {
1447
- if (countryOfGoverningLaw) {
1448
- filteredData.basicInformation.countryOfGoverningLaw = countryOfGoverningLaw;
1449
- } else {
1450
- delete filteredData.basicInformation.countryOfGoverningLaw;
1451
- }
766
+ const vatNumberType = getDefaultVatNumberType(entity?.vatNumber, currentCountry);
767
+ const operationalAddressIsSame = entity?.principalPlaceOfBusiness && !objectsDeepEqual(entity?.principalPlaceOfBusiness, entity?.registeredAddress) ? operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME : operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME;
768
+ if (entity?.registeredAddress?.localization) {
769
+ data.registrationAddress = {
770
+ ...data.registrationAddress,
771
+ ...mapAddressLocalizationToJpAddressSchema(entity.registeredAddress.localization)
772
+ };
1452
773
  }
1453
- const primaryIndustryCode = data.additionalInformation?.industryCodes && data.additionalInformation.industryCodes[0].id;
1454
- if (createBusinessLine && updateBusinessLine && primaryIndustryCode) {
1455
- const bankingBusinessLines = [];
1456
- const issuingBusinessLines = [];
1457
- if (efpBusinessLines) {
1458
- for (const bl of efpBusinessLines) {
1459
- if (bl.service === "banking") bankingBusinessLines.push(bl);
1460
- else issuingBusinessLines.push(bl);
774
+ if (entity?.principalPlaceOfBusiness?.localization) {
775
+ data.operationalAddress = {
776
+ ...data.operationalAddress,
777
+ ...mapAddressLocalizationToJpAddressSchema(entity.principalPlaceOfBusiness.localization)
778
+ };
779
+ }
780
+ const result = entriesOf(data).reduce(
781
+ (acc, [field]) => {
782
+ if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) {
783
+ return {
784
+ ...acc,
785
+ [field]: data[field]
786
+ };
1461
787
  }
1462
- }
1463
- const promises = [];
1464
- const operations = [];
1465
- const updateOrCreateBusinessLinesIfNeeded = (businessLines, requestedCapability, service) => {
1466
- if (businessLines.length) {
1467
- for (const bl of businessLines) {
1468
- if (bl.industryCode === primaryIndustryCode) continue;
1469
- const payload = {
1470
- id: bl.id,
1471
- legalEntityId: legalEntityResponse.id,
1472
- industryCode: primaryIndustryCode,
1473
- service
1474
- };
1475
- promises.push(updateBusinessLine(payload));
1476
- operations.push(payload);
1477
- }
1478
- } else if (requestedCapability) {
1479
- const payload = {
1480
- legalEntityId: legalEntityResponse.id,
1481
- industryCode: primaryIndustryCode,
1482
- service
788
+ if (!FIELDS_NEEDED_FOR_COMPANY_SEARCH.includes(field)) {
789
+ return {
790
+ ...acc,
791
+ [field]: data[field]
1483
792
  };
1484
- promises.push(createBusinessLine(payload));
1485
- operations.push(payload);
1486
793
  }
1487
- };
1488
- updateOrCreateBusinessLinesIfNeeded(
1489
- bankingBusinessLines,
1490
- requestingBanking(legalEntityResponse),
1491
- "banking"
1492
- );
1493
- updateOrCreateBusinessLinesIfNeeded(
1494
- issuingBusinessLines,
1495
- requestingIssuing(legalEntityResponse),
1496
- "issuing"
1497
- );
1498
- let hadRejection = false;
1499
- (await Promise.allSettled(promises)).forEach((result, idx) => {
1500
- if (result.status !== "rejected") return;
1501
- const op = operations[idx];
1502
- logger.log(
1503
- `Failed to ${op.id ? "update" : "create"} business line with payload: ${JSON.stringify(op)}`
1504
- );
1505
- hadRejection = true;
794
+ return acc;
795
+ },
796
+ { operationalAddressIsSame, registrationNumberType, vatNumberType }
797
+ );
798
+ return { ...result, ...dbaNameFields, ...isUen };
799
+ };
800
+ const mapLegalNameLocalization = (data) => {
801
+ const localization = data.organization?.localization;
802
+ if (!localization) return {};
803
+ let result = {};
804
+ for (const { script, fields } of localization) {
805
+ const schemaFieldsFromLocalization = mapApiScriptLocalizationToSchemaFields({
806
+ script,
807
+ fields: {
808
+ // mismatch between API `legalName` and schema `legalCompanyName`
809
+ legalCompanyName: fields.legalName
810
+ }
1506
811
  });
1507
- const eventPayload = {
1508
- actionType: trackingPayload.actionType,
1509
- legalEntityName: trackingPayload.legalEntityName
812
+ result = {
813
+ ...result,
814
+ ...schemaFieldsFromLocalization
1510
815
  };
1511
- if (!hadRejection) {
1512
- userEvents?.addTaskEvent("Success", eventPayload);
1513
- } else {
1514
- userEvents?.addTaskEvent("Encountered error", {
1515
- ...eventPayload,
1516
- returnType: "businessLines",
1517
- returnValue: "couldNotCreateOrUpdateBusinessLine"
1518
- });
1519
- showToast({
1520
- label: t(($) => $["failedToUpdateEfpBusinessLines"], { ns: "business" }),
1521
- variant: "error"
1522
- });
1523
- return setLoadingStatus("success");
1524
- }
1525
816
  }
1526
- try {
1527
- const mappedLegalEntity = {
1528
- ...mapBusinessDetailsSchemaToLegalEntity(filteredData, accountHolder, isExperimentEnabled),
1529
- entityAssociations: filterOutUnwantedAssociationsIfRootLE(
1530
- taskType,
1531
- entityToUpdate,
1532
- accountHolder
1533
- )
1534
- };
1535
- if (mappedLegalEntity.type === LegalEntityTypes.ORGANIZATION && legalEntityResponse.organization?.countryOfGoverningLaw !== mappedLegalEntity.organization?.countryOfGoverningLaw && legalEntityResponse.organization?.support) {
1536
- mappedLegalEntity.organization.support = determineCustomerSupport(
1537
- legalEntityResponse.organization.support,
1538
- mappedLegalEntity.organization?.countryOfGoverningLaw
817
+ return result;
818
+ };
819
+ const mapLegalEntityToBusinessDetailsSchema = (legalEntity, parentEntity) => {
820
+ if (!legalEntity) return {};
821
+ const {
822
+ companyRegistrationDocument,
823
+ companyTaxDocument,
824
+ companyProofOfDirectorDocument,
825
+ companyProofOfSignatoryDocument,
826
+ companyProofOfOwnershipDocument,
827
+ companyConstitutionalDocument
828
+ } = mapApiDocumentToBusinessDetailsDocuments(legalEntity.id);
829
+ const buildSolePropSchema = () => {
830
+ const solePropData = formatObject(
831
+ legalEntity,
832
+ solePropBusinessDetailsKeyMapping
833
+ );
834
+ const country = solePropData?.additionalInformation?.registrationAddress?.country ?? parentEntity?.individual?.residentialAddress.country;
835
+ if (legalEntity?.soleProprietorship?.financialReports && solePropData) {
836
+ solePropData.companyFinancialInformation = mapFinancialReportsToFinancialInformation(
837
+ legalEntity.soleProprietorship.financialReports
1539
838
  );
1540
839
  }
1541
- const legalEntity = await handleSubmitLegalEntity(mappedLegalEntity);
1542
- if (taskType === TaskTypes.TRUST_MEMBER_COMPANY || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY || taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && !associatedLegalArrangement?.id) {
1543
- await associateLegalEntityWithParent({
1544
- legalEntity,
1545
- associatedLegalArrangement,
1546
- nestedLegalEntityDetails
1547
- });
1548
- }
1549
- await submitDocuments({
1550
- data,
1551
- legalEntity,
1552
- documentUtils,
1553
- forms,
1554
- userEvents
1555
- });
1556
- userEvents?.addTaskEvent("Success", trackingPayload);
1557
- showToast({
1558
- label: t(($) => $["successfullyUpdatedDetails"], { ns: "common" }),
1559
- variant: "success"
1560
- });
1561
- onExternalSubmit?.(data);
1562
- } catch (err) {
1563
- if (isValidationError(err)) {
1564
- const getErrors = processValidationErrors(err, TaskTypes.BUSINESS_DETAILS);
1565
- if (getErrors && !Object.keys(getErrors).length) {
1566
- showToast({
1567
- label: t(($) => $["failedToUpdateDetails"], { ns: "common" }),
1568
- variant: "error"
1569
- });
1570
- const unmappedErrorNames = err.invalidFields?.map((field) => field.name).filter(Boolean) ?? [];
1571
- if (unmappedErrorNames.length) {
1572
- trackingPayload = {
1573
- ...trackingPayload,
1574
- additionalData: { unmappedErrorNames }
1575
- };
1576
- }
1577
- } else {
1578
- setProblems({
1579
- ...problems,
1580
- validationErrors: getErrors
1581
- });
840
+ return {
841
+ ...solePropData,
842
+ basicInformation: {
843
+ ...solePropData?.basicInformation,
844
+ country
845
+ },
846
+ companyConstitutionalDocument
847
+ };
848
+ };
849
+ const orgSchema = {
850
+ ...formatObject(legalEntity, businessDetailsComponentsKeyMapping),
851
+ businessSelection: {},
852
+ companyRegistrationDocument,
853
+ companyTaxDocument,
854
+ companyProofOfDirectorDocument,
855
+ companyProofOfSignatoryDocument,
856
+ companyProofOfOwnershipDocument,
857
+ companyFinancialInformation: {}
858
+ };
859
+ const businessDetailsSchema = legalEntity.type === "organization" ? orgSchema : buildSolePropSchema();
860
+ return entriesOf(businessDetailsSchema).reduce((componentData, [key]) => {
861
+ switch (key) {
862
+ case "basicInformation": {
863
+ return {
864
+ ...componentData,
865
+ [key]: {
866
+ ...mapBasicInformation(businessDetailsSchema[key]),
867
+ ...mapLegalNameLocalization(legalEntity)
868
+ }
869
+ };
870
+ }
871
+ case "businessSelection": {
872
+ return {
873
+ ...componentData,
874
+ [key]: {
875
+ hasSelectedBusiness: false
876
+ }
877
+ };
878
+ }
879
+ case "companyStructure": {
880
+ return {
881
+ ...componentData,
882
+ [key]: {
883
+ ...businessDetailsSchema[key]
884
+ }
885
+ };
886
+ }
887
+ case "additionalInformation": {
888
+ return {
889
+ ...componentData,
890
+ [key]: mapAdditionalInformation(businessDetailsSchema[key], legalEntity)
891
+ };
892
+ }
893
+ case "companyRegistrationDocument": {
894
+ return {
895
+ ...componentData,
896
+ [key]: businessDetailsSchema[key]
897
+ };
1582
898
  }
899
+ case "companyTaxDocument": {
900
+ return {
901
+ ...componentData,
902
+ [key]: businessDetailsSchema[key]
903
+ };
904
+ }
905
+ case "companyProofOfDirectorDocument": {
906
+ return {
907
+ ...componentData,
908
+ [key]: businessDetailsSchema[key]
909
+ };
910
+ }
911
+ case "companyProofOfSignatoryDocument": {
912
+ return {
913
+ ...componentData,
914
+ [key]: businessDetailsSchema[key]
915
+ };
916
+ }
917
+ case "companyProofOfOwnershipDocument": {
918
+ return {
919
+ ...componentData,
920
+ [key]: businessDetailsSchema[key]
921
+ };
922
+ }
923
+ case "companyConstitutionalDocument": {
924
+ return {
925
+ ...componentData,
926
+ [key]: businessDetailsSchema[key]
927
+ };
928
+ }
929
+ case "companyFinancialInformation": {
930
+ const financialReports = legalEntity.type === "organization" ? legalEntity?.organization?.financialReports : legalEntity?.soleProprietorship?.financialReports;
931
+ return financialReports?.length ? {
932
+ ...componentData,
933
+ [key]: mapFinancialReportsToFinancialInformation(financialReports)
934
+ } : componentData;
935
+ }
936
+ default:
937
+ return componentData;
1583
938
  }
1584
- if (isMaintenanceModeError(err)) {
1585
- showToast({
1586
- label: t(($) => $["maintenanceModeMessage"], { ns: "common" }),
1587
- variant: "error",
1588
- duration: "indefinite"
1589
- });
1590
- }
1591
- if (!isValidationError(err) && !isMaintenanceModeError(err)) {
1592
- showToast({
1593
- label: t(($) => $["failedToUpdateDetails"], { ns: "common" }),
1594
- variant: "error"
1595
- });
1596
- }
1597
- logger.error(err);
1598
- userEvents?.addTaskEvent("Encountered error", {
1599
- ...trackingPayload,
1600
- returnType: err?.errorCode,
1601
- returnValue: err?.title || "backend"
1602
- });
1603
- } finally {
1604
- setLoadingStatus("success");
1605
- }
1606
- }
1607
- const getCountryOfGoverningLaw = (isCountryOfGoverningLawEnabled, basicData) => {
1608
- if (!isCountryOfGoverningLawEnabled || basicData?.country !== CountryCodes.UnitedKingdom) {
1609
- return void 0;
1610
- }
1611
- if (isCountryOfGoverningLawEnabled && basicData?.country === CountryCodes.UnitedKingdom && !basicData?.countryOfGoverningLaw) {
1612
- return CountryCodes.UnitedKingdom;
1613
- }
1614
- return basicData?.countryOfGoverningLaw;
939
+ }, {});
1615
940
  };
1616
- const determineCustomerSupport = (customerSupport, country) => {
1617
- switch (country) {
1618
- case CountryCodes.Japan:
1619
- return unsetCustomerSupportNumber(customerSupport);
1620
- default:
1621
- return customerSupport;
941
+ const businessDetailsBase = {
942
+ /* Base required fields */
943
+ country: { rule: "REQUIRED" },
944
+ entityType: { rule: "businessRequiresCompanyType" },
945
+ legalCompanyName: { rule: "REQUIRED" },
946
+ jaHaniLegalCompanyName: { rule: "japaneseLegalCompanyName" },
947
+ jaKanaLegalCompanyName: { rule: "japaneseLegalCompanyName" },
948
+ hasDoingBusinessAs: { rule: "REQUIRED" },
949
+ doingBusinessAs: { rule: "requireDoingBusinessAsName" },
950
+ registrationAddress: { rule: "REQUIRED" },
951
+ operationalAddressIsSame: { rule: "REQUIRED" },
952
+ /* Base optional fields */
953
+ operationalAddress: { rule: "OPTIONAL" },
954
+ /* Fields with custom country specific rules */
955
+ hasSelectedBusiness: { rule: "requireBusinessSelection" },
956
+ stockExchangeMIC: { rule: "ifPubliclyTradedCompany" },
957
+ stockISIN: { rule: "ifPubliclyTradedCompany" },
958
+ stockTickerSymbol: { rule: "ifPubliclyTradedCompany" },
959
+ dateOfIncorporation: { rule: "isDateOfIncorporationRequired" },
960
+ stateOrProvince: { rule: "countryUsingCompanySearch" },
961
+ registrationNumber: { rule: "countryRequiresRegistrationNumber" },
962
+ registrationNumberType: { rule: "registrationNumberType" },
963
+ exemptedFromRegistrationNumber: { rule: "companyRegistrationNumberExemptionAllowed" },
964
+ eInvoicingCode: { rule: "isEInvoicingCodeEnabled" },
965
+ countryOfGoverningLaw: { rule: "countryOfGoverningLawRequired" },
966
+ taxDocument: { rule: "ifCountryUsAndTinFailed" },
967
+ /* Fields derived from capabilities */
968
+ industryCodes: { rule: "isIndustryCodeRequired" }
969
+ };
970
+ const taxInformationBase = {
971
+ vatNumber: { rule: "countryUsesVat" },
972
+ vatNumberType: { rule: "vatNumberType" },
973
+ exemptedFromVat: { rule: "isVatExempt" },
974
+ vatAbsenceReason: { rule: "isVatExempt" },
975
+ taxInformation: { rule: "countryUsesTaxId" },
976
+ exemptedFromTax: { rule: "countryHasTaxExemptions" },
977
+ isUen: { rule: "countryUsesUenOrGst" }
978
+ };
979
+ const financialInformationBase = {
980
+ numberOfEmployees: { rule: "countryRequiresFinancialInformation" },
981
+ financialReportingDate: { rule: "isFinancialReportingFieldsRequired" },
982
+ currency: { rule: "isFinancialReportingFieldsRequired" },
983
+ reportedValueOption: { rule: "isFinancialReportingFieldsRequired" },
984
+ annualTurnover: { rule: "annualTurnoverRequired" },
985
+ netAssets: { rule: "netAssetsRequired" },
986
+ balanceSheetTotal: { rule: "balanceSheetTotalRequired" }
987
+ };
988
+ const businessDetailsFieldsPerScenario = {
989
+ L0: {
990
+ country: { rule: "REQUIRED" },
991
+ legalCompanyName: { rule: "REQUIRED" },
992
+ stateOrProvince: { rule: "countryUsingCompanySearch" },
993
+ ...financialInformationBase
994
+ },
995
+ L1: {
996
+ ...businessDetailsBase,
997
+ ...financialInformationBase
998
+ },
999
+ L: {
1000
+ ...businessDetailsBase,
1001
+ ...taxInformationBase,
1002
+ ...financialInformationBase
1003
+ },
1004
+ L_PROOFOFADDRESS: {
1005
+ // TODO this field does not exist
1006
+ // proofOfAddressDocument: { rule: 'REQUIRED' },
1007
+ },
1008
+ L_REGDOC: {
1009
+ registrationDocument: { rule: "REQUIRED" }
1010
+ },
1011
+ L_TAXDOC: {
1012
+ taxDocument: { rule: "REQUIRED" }
1013
+ },
1014
+ L_BAFIN: {
1015
+ legalForm: { rule: "REQUIRED" }
1622
1016
  }
1623
1017
  };
1624
- const unsetCustomerSupportNumber = (customerSupport) => {
1625
- return customerSupport ? {
1626
- email: customerSupport.email,
1627
- phone: { number: "", type: "mobile" }
1628
- } : void 0;
1018
+ const adjustFormData = (oldFormData, newFormData) => {
1019
+ const schema = Array.from((/* @__PURE__ */ new Set([...keysOf(oldFormData), ...keysOf(newFormData)])).keys());
1020
+ return schema.reduce((acc, key) => {
1021
+ const oldValue = oldFormData[key];
1022
+ const newValue = newFormData[key];
1023
+ if (!isUndefinedOrNull(newValue)) return { ...acc, [key]: newValue };
1024
+ if (Array.isArray(oldValue)) return { ...acc, [key]: [] };
1025
+ if (typeof oldValue === "number") return { ...acc, [key]: null };
1026
+ if (typeof oldValue === "string") return { ...acc, [key]: "" };
1027
+ return { ...acc, [key]: "" };
1028
+ }, {});
1629
1029
  };
1630
- function BusinessDetailsDropin({
1631
- country,
1632
- problems,
1633
- legalEntityResponse,
1634
- associatedLegalArrangement,
1635
- // initially undefined when creating entity
1636
- nestedLegalEntity,
1637
- // initially undefined when creating entity
1638
- nestedLegalEntityDetails,
1639
- // has entity roles for association logic
1640
- taskName,
1641
- hideSidebar,
1642
- taskType,
1643
- onChange,
1644
- onSubmit: onExternalSubmit,
1645
- handleHomeClick
1646
- }) {
1647
- const formRef = useRef(null);
1648
- const { accountHolder, setAccountHolder } = useAccountHolder();
1649
- const { showToast } = useToastContext();
1650
- const { t, i18n } = useTranslation(["common", "business"]);
1651
- const userEvents = useAnalyticsContext();
1652
- const { isExperimentEnabled } = useExperimentsContext();
1653
- const { isSettingEnabled } = useSettingsContext();
1654
- const { baseUrl, rootLegalEntityId } = useApiContext();
1655
- const verifiedBusiness$1 = verifiedBusiness.value;
1656
- const queryClient = useQueryClient();
1657
- const {
1658
- state: { currentState }
1659
- } = useStateContext();
1660
- useEffect(() => {
1661
- onChange?.(currentState);
1662
- }, [currentState, onChange]);
1663
- const isSoleProp = accountHolder === "mySoleProprietorName";
1664
- const formWith2Views = "basicInformation";
1665
- const isAssociationTaskType = !taskType ? accountHolder !== "theCompanyIWorkFor" : taskType !== TaskTypes.BUSINESS_DETAILS;
1666
- const legalEntityType = !isSoleProp ? LegalEntityTypes.ORGANIZATION : LegalEntityTypes.SOLE_PROPRIETORSHIP;
1667
- const isUS = country === CountryCodes.UnitedStates;
1668
- const currentCountry = currentState.data.basicInformation?.country ?? country;
1669
- const isSkippingCompanyStructure = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange) && organizationTypesToSkipCompanyStructureForm.includes(
1670
- legalEntityResponse?.organization?.type
1671
- ) && accountHolder !== "aTrust" && accountHolder !== "anUnincorporatedPartnership" || isSoleProp;
1672
- useEffect(() => {
1673
- const isBankAccountRequested = legalEntityResponse?.capabilities?.issueBankAccount?.requested;
1674
- setIsBankAccountRequestedForOrganization(isBankAccountRequested);
1675
- }, [legalEntityResponse]);
1676
- const subjectEntity = !isAssociationTaskType ? legalEntityResponse : isSoleProp ? associatedLegalArrangement : nestedLegalEntity;
1677
- useEffect(() => {
1678
- userEvents.updateBaseTrackingPayload({ task: taskType });
1679
- userEvents.addTaskEvent("Landed on page", {
1680
- actionType: "start"
1681
- });
1682
- }, []);
1683
- const [tinMatched2, setTinMatched] = useState(void 0);
1684
- const [initialData, setInitialData] = useState(() => {
1685
- return mapLegalEntityToBusinessDetailsSchema(
1686
- !isAssociationTaskType ? legalEntityResponse : isSoleProp ? associatedLegalArrangement ?? legalEntityResponse : nestedLegalEntity,
1687
- isSoleProp ? legalEntityResponse : void 0,
1688
- isExperimentEnabled
1689
- );
1690
- });
1691
- const [trustedFields, setTrustedFields] = useState(subjectEntity?.trustedFields ?? void 0);
1692
- const [currentProblems, setCurrentProblems] = useState(problems ?? {});
1693
- const [showCompanyStructure, setShowCompanyStructure] = useState(
1694
- currentCountry !== "US" && !isSoleProp
1695
- );
1696
- const [showBusinessSelection, setShowBusinessSelection] = useState(false);
1697
- const [loadingStatus, setLoadingStatus] = useState("success");
1698
- const [businessMismatchModalOpen2, setBusinessMismatchModalOpen] = useState(false);
1699
- const [companySearchParams, setCompanySearchParams] = useState({
1700
- legalCompanyName: void 0,
1701
- country: void 0,
1702
- stateOrProvince: void 0,
1703
- registrationNumber: void 0
1704
- });
1705
- const [singleCompanyDatasetParams, setSingleCompanyDatasetParams] = useState();
1706
- const documentUtils = documentApiUtils({
1707
- baseUrl: baseUrl.value,
1708
- rootLegalEntityId: rootLegalEntityId.value
1709
- });
1710
- useEffect(() => {
1711
- if (!subjectEntity?.documentDetails?.length) return;
1712
- documentUtils.fetchDocuments(subjectEntity.documentDetails, subjectEntity.id).then(() => {
1713
- setInitialData(
1714
- mapLegalEntityToBusinessDetailsSchema(
1715
- subjectEntity,
1716
- isSoleProp ? legalEntityResponse : void 0
1717
- )
1718
- );
1719
- }).catch(
1720
- () => showToast({
1721
- label: t(($) => $["failedToFetchRelevantDocuments"], { ns: "common" }),
1722
- variant: "error"
1723
- })
1724
- );
1725
- }, []);
1726
- const parseConfiguration = useCallback(
1727
- ({ scenarios }) => composePerScenarioFormConfigurations(scenarios, businessDetailsFieldsPerScenario),
1728
- []
1729
- );
1030
+ const setRemovedFieldsOnSchemaToDeletedValue = (newData, existingData) => {
1031
+ const formIds = Array.from((/* @__PURE__ */ new Set([...keysOf(existingData), ...keysOf(newData)])).keys());
1032
+ return formIds.reduce((adjusted, formId) => {
1033
+ const oldFormData = existingData[formId];
1034
+ const newFormData = newData[formId];
1035
+ if (isUndefinedOrNull(oldFormData)) return { ...adjusted, [formId]: newFormData };
1036
+ if (isUndefinedOrNull(newFormData)) return adjusted;
1037
+ return { ...adjusted, [formId]: adjustFormData(oldFormData, newFormData) };
1038
+ }, {});
1039
+ };
1040
+ const formatFinancialInformationSummary = (data, language, country, dateOfIncorporation) => {
1041
+ let summary;
1042
+ if (!data) return void 0;
1043
+ if (dateOfIncorporation && !isDateOlderThanAYear(dateOfIncorporation)) {
1044
+ if (country === CountryCodes.UnitedKingdom) {
1045
+ summary = { numberOfEmployees: `${data.numberOfEmployees}` };
1046
+ return summary;
1047
+ }
1048
+ return void 0;
1049
+ }
1050
+ summary = {
1051
+ currency: data.currency,
1052
+ financialReportingDate: data.financialReportingDate
1053
+ };
1054
+ if (country === CountryCodes.UnitedKingdom) {
1055
+ summary.numberOfEmployees = `${data.numberOfEmployees}`;
1056
+ }
1057
+ if (data.balanceSheetTotal) {
1058
+ summary.balanceSheetTotal = summaryItem(
1059
+ "balanceSheetTotal",
1060
+ formatCurrency(data.balanceSheetTotal, data.currency, language)
1061
+ );
1062
+ }
1063
+ if (data.annualTurnover) {
1064
+ summary.annualTurnover = formatCurrency(data.annualTurnover, data.currency, language);
1065
+ }
1066
+ return summary;
1067
+ };
1068
+ const mapBusinessDetailsDocumentToApiDocument = async (data, entityId) => {
1730
1069
  const {
1731
- fieldConfigurations
1732
- } = useScenarioConfiguration({
1733
- legalEntityType,
1734
- parseConfiguration,
1735
- setLoadingStatus,
1736
- country: currentCountry
1737
- });
1738
- const customRules = useMemo(
1739
- () => rules({
1740
- data: currentState.data,
1741
- country: currentCountry,
1742
- taskType: taskType ?? TaskTypes.BUSINESS_DETAILS,
1743
- isExperimentEnabled,
1744
- isSettingEnabled,
1745
- accountHolder,
1746
- tinMatched: tinMatched2,
1747
- rootLegalEntity: legalEntityResponse
1070
+ companyRegistrationDocument,
1071
+ companyTaxDocument,
1072
+ companyProofOfDirectorDocument,
1073
+ companyConstitutionalDocument,
1074
+ companyProofOfSignatoryDocument,
1075
+ companyProofOfOwnershipDocument,
1076
+ basicInformation
1077
+ } = data;
1078
+ const taxDocumentType = COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT.includes(
1079
+ basicInformation?.country
1080
+ ) ? "proofOfOrganizationTaxInfo" : "vatDocument";
1081
+ const documents = await Promise.all([
1082
+ createDocumentRequest({
1083
+ entityId,
1084
+ entityType: "legalEntity",
1085
+ documentType: "registrationDocument",
1086
+ page1: companyRegistrationDocument?.registrationDocument?.[0]
1748
1087
  }),
1749
- [
1750
- currentState.data,
1751
- currentCountry,
1752
- taskType,
1753
- isExperimentEnabled,
1754
- isSettingEnabled,
1755
- accountHolder,
1756
- tinMatched2,
1757
- legalEntityResponse
1758
- ]
1759
- );
1760
- const initialForms = useMemo(() => getForms(currentCountry), [currentCountry]);
1761
- const derivedProps = useMemo(
1762
- () => getPropsFromConfigurations({
1763
- scenarioConfiguration: fieldConfigurations,
1764
- forms: initialForms,
1765
- remediationActions: currentProblems?.remediationActions ? Object.values(currentProblems?.remediationActions) : [],
1766
- dataMissingErrors: currentProblems?.missingData ?? [],
1767
- fieldsWithExistingData: subjectEntity ? subjectEntity.type === LegalEntityTypes.SOLE_PROPRIETORSHIP ? getFieldsWithExistingData(
1768
- subjectEntity,
1769
- solePropBusinessDetailsApiKeyMapping,
1770
- solePropBusinessDetailsDocumentMapping
1771
- ) : getFieldsWithExistingData(
1772
- subjectEntity,
1773
- businessDetailsApiKeyMapping,
1774
- businessDetailsDocumentMapping
1775
- ) : [],
1776
- customRules,
1777
- legalEntityType: subjectEntity?.type,
1778
- legalEntityTrustedFields: trustedFields
1088
+ createDocumentRequest({
1089
+ entityId,
1090
+ entityType: "legalEntity",
1091
+ documentType: taxDocumentType,
1092
+ page1: companyTaxDocument?.taxDocument?.[0]
1779
1093
  }),
1780
- [
1781
- fieldConfigurations,
1782
- initialForms,
1783
- currentProblems?.remediationActions,
1784
- currentProblems?.missingData,
1785
- subjectEntity,
1786
- customRules,
1787
- trustedFields
1788
- ]
1094
+ createDocumentRequest({
1095
+ entityId,
1096
+ entityType: "legalEntity",
1097
+ documentType: "proofOfDirector",
1098
+ page1: companyProofOfDirectorDocument?.proofOfDirector?.[0]
1099
+ }),
1100
+ createDocumentRequest({
1101
+ entityId,
1102
+ entityType: "legalEntity",
1103
+ documentType: "constitutionalDocument",
1104
+ page1: companyConstitutionalDocument?.constitutionalDocument?.[0]
1105
+ }),
1106
+ createDocumentRequest({
1107
+ entityId,
1108
+ entityType: "legalEntity",
1109
+ documentType: "proofOfSignatory",
1110
+ page1: companyProofOfSignatoryDocument?.proofOfSignatory?.[0]
1111
+ }),
1112
+ createDocumentRequest({
1113
+ entityId,
1114
+ entityType: "legalEntity",
1115
+ documentType: "proofOfOwnership",
1116
+ page1: companyProofOfOwnershipDocument?.proofOfOwnership?.[0],
1117
+ page2: companyProofOfOwnershipDocument?.proofOfOwnership?.[1]
1118
+ })
1119
+ ]);
1120
+ return documents.filter(Boolean);
1121
+ };
1122
+ const mapBusinessDetailsSchemaToLegalEntity = (data, accountHolder, isExperimentEnabled) => {
1123
+ const requestObj = {
1124
+ ...formatObject(
1125
+ data,
1126
+ accountHolder === "mySoleProprietorName" ? solePropBusinessDetailsApiKeyMapping : businessDetailsApiKeyMapping
1127
+ )
1128
+ };
1129
+ delete requestObj.organization?.legalFormDescription;
1130
+ const canSaveRegNumberAbsentState = isExperimentEnabled("EnableRegistrationAndTaxAbsentStatesV4") && isRegistrationNumberAbsentStateV4Scenario(
1131
+ data.basicInformation?.country,
1132
+ data.companyStructure?.entityType
1789
1133
  );
1790
- const {
1791
- data: companySearchResponse,
1792
- isLoading: searchingCompanies,
1793
- isError: searchingError
1794
- } = useCompanySearch(
1795
- {
1796
- name: companySearchParams.legalCompanyName ?? "",
1797
- country: companySearchParams.country,
1798
- state: companySearchParams.stateOrProvince,
1799
- registrationNumber: companySearchParams.registrationNumber
1800
- },
1801
- {
1802
- enabled: showBusinessSelection
1134
+ const taxData = COUNTRIES_USING_COMPANY_SEARCH.includes(
1135
+ data.basicInformation?.country
1136
+ ) ? data.basicInformation?.taxInformation : data.additionalInformation?.taxInformation;
1137
+ const registrationNumber = COUNTRIES_USING_COMPANY_SEARCH.includes(
1138
+ data.basicInformation?.country
1139
+ ) ? data.basicInformation?.registrationNumber : data.additionalInformation?.registrationNumber;
1140
+ const localization = [
1141
+ mapSchemaFieldsToApiScriptLocalization(data.basicInformation ?? {}, "jaHani"),
1142
+ mapSchemaFieldsToApiScriptLocalization(data.basicInformation ?? {}, "jaKana")
1143
+ ].filter(({ fields }) => !isEmpty$1(fields)).map(({ script, fields }) => ({
1144
+ script,
1145
+ // mismatch between API `legalName` and schema `legalCompanyName`
1146
+ fields: { legalName: fields.legalCompanyName }
1147
+ }));
1148
+ const doingBusinessAs = data.additionalInformation?.doingBusinessAs ?? "";
1149
+ const entityObject = isEmpty$1(data.companyStructure) ? requestObj.soleProprietorship : requestObj.organization;
1150
+ if (entityObject) {
1151
+ if (taxData) {
1152
+ entityObject.taxInformation = taxData;
1803
1153
  }
1804
- );
1805
- const companySearchResults = companySearchResponse?.results;
1806
- const businessName = currentState?.data?.basicInformation?.legalCompanyName || "";
1807
- const taxInformation = currentState?.data?.basicInformation?.taxInformation;
1808
- const tin = taxInformation?.find((taxId) => currentCountry === taxId.country)?.number || "";
1809
- const [prevCompanySearchResults, setPrevCompanySearchResults] = useState(companySearchResults);
1810
- useEffect(() => {
1811
- if (!searchingCompanies && companySearchResults) {
1812
- userEvents.addPageEvent("Success", {
1813
- actionType: "submit",
1814
- returnValue: "companySearch",
1815
- additionalData: {
1816
- numberOfResults: companySearchResults.length
1817
- }
1818
- });
1154
+ if (!!requestObj.soleProprietorship && !requestObj.soleProprietorship?.countryOfGoverningLaw && !!data.basicInformation?.country) {
1155
+ requestObj.soleProprietorship.countryOfGoverningLaw = data.basicInformation.country;
1819
1156
  }
1820
- }, [searchingCompanies, companySearchResults, userEvents, subjectEntity]);
1821
- const {
1822
- data: singleCompanyDatasetAndTinResponse,
1823
- isLoading: fetchingDataset,
1824
- refetch: getCompanySelection
1825
- } = useCompanySelection(singleCompanyDatasetParams, {
1826
- enabled: !!singleCompanyDatasetParams && showBusinessSelection
1827
- });
1828
- const { refetch: fetchTin } = useVerifyTin({ name: businessName, tin }, { enabled: false });
1829
- const forms = useMemo(() => {
1830
- const requiredForms = getRequiredForms(
1831
- initialForms,
1832
- derivedProps?.requiredFields,
1833
- derivedProps?.optionalFields
1834
- );
1835
- const validityAddedForms = addValidityToForms(
1836
- requiredForms,
1837
- currentState.validityByForm,
1838
- currentProblems
1839
- );
1840
- return removeConditionalForms(
1841
- validityAddedForms,
1842
- currentCountry !== "US" || accountHolder !== "theCompanyIWorkFor" ? isSkippingCompanyStructure : !showCompanyStructure
1843
- );
1844
- }, [
1845
- initialForms,
1846
- derivedProps?.requiredFields,
1847
- derivedProps?.optionalFields,
1848
- currentState.validityByForm,
1849
- currentProblems,
1850
- currentCountry,
1851
- isSkippingCompanyStructure,
1852
- showCompanyStructure
1853
- ]);
1854
- const summaryData = useMemo(
1855
- () => ({
1856
- data: formatDataForSummary(currentState.data, forms, t, i18n.language, isExperimentEnabled),
1857
- omitted: {
1858
- keys: ["operationalAddressIsSame"]
1859
- }
1860
- }),
1861
- [currentState.data, forms, t, i18n.language, isExperimentEnabled]
1862
- );
1863
- const canSubmitForm = useMemo(
1864
- () => canSubmit(currentState.data) && hasDataChanged(initialData, currentState.data),
1865
- [initialData, currentState.data]
1866
- );
1867
- const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
1868
- const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
1869
- const { mutateAsync: clearCompanyData, isPending: resettingTrustedData } = useClearCompanyData();
1870
- const { data: businessLines } = useBusinessLines(ALLOWED_SOF_SERVICES, {
1871
- enabled: isSettingEnabled("allowBusinessLines")
1872
- });
1873
- const efpBusinessLines = businessLines?.filter((bl) => bl.service !== "paymentProcessing");
1874
- const { mutateAsync: createBusinessLine } = useCreateBusinessLine();
1875
- const { mutateAsync: updateBusinessLine } = useUpdateBusinessLine();
1876
- const submitTask = useCallback(() => {
1877
- setAccountHolder(accountHolder);
1878
- return submit({
1879
- data: currentState.data,
1880
- legalEntityResponse,
1881
- associatedLegalArrangement,
1882
- nestedLegalEntity,
1883
- nestedLegalEntityDetails,
1884
- problems: currentProblems,
1885
- taskType: taskType ?? TaskTypes.BUSINESS_DETAILS,
1886
- accountHolder: accountHolder ?? "theCompanyIWorkFor",
1887
- forms,
1888
- documentUtils,
1889
- t,
1890
- showToast,
1891
- setLoadingStatus,
1892
- setProblems: setCurrentProblems,
1893
- handleUpdateLegalEntity: updateLegalEntity,
1894
- createLegalEntity,
1895
- onExternalSubmit,
1896
- isExperimentEnabled,
1897
- userEvents,
1898
- efpBusinessLines,
1899
- createBusinessLine,
1900
- updateBusinessLine
1901
- });
1902
- }, [
1903
- setAccountHolder,
1904
- accountHolder,
1905
- currentState.data,
1906
- legalEntityResponse,
1907
- associatedLegalArrangement,
1908
- nestedLegalEntity,
1909
- nestedLegalEntityDetails,
1910
- currentProblems,
1911
- taskType,
1912
- forms,
1913
- documentUtils,
1914
- t,
1915
- showToast,
1916
- updateLegalEntity,
1917
- createLegalEntity,
1918
- onExternalSubmit,
1919
- isExperimentEnabled,
1920
- userEvents,
1921
- efpBusinessLines,
1922
- createBusinessLine,
1923
- updateBusinessLine
1924
- ]);
1925
- const {
1926
- handleNextClick,
1927
- handleBackClick,
1928
- activeForm,
1929
- shouldValidate,
1930
- setShouldValidate,
1931
- gotoFormByFormIndex,
1932
- steps
1933
- } = useFormComposer({
1934
- problems: currentProblems,
1935
- forms,
1936
- onSubmit: submitTask
1937
- });
1938
- const loading = fetchingDataset || searchingCompanies || resettingTrustedData;
1939
- const proceedToManualDataEntry = useCallback(async () => {
1940
- await clearCompanyData().then(async () => {
1941
- if (!isUS) {
1942
- setShowCompanyStructure(true);
1943
- return;
1944
- }
1945
- if (!businessName || !tin) {
1946
- setShowCompanyStructure(true);
1947
- return;
1948
- }
1949
- const { data: refetchedTinResponse } = await fetchTin();
1950
- if (refetchedTinResponse?.matched === true) {
1951
- setShowCompanyStructure(true);
1952
- setBusinessMismatchModalOpen(false);
1953
- } else {
1954
- setBusinessMismatchModalOpen(true);
1955
- setTinMatched(false);
1956
- if (subjectEntity?.id && subjectEntity?.type) {
1957
- userEvents.addPageEvent("Encountered error", {
1958
- actionType: "submit",
1959
- returnValue: "tinVerificationFailure"
1960
- });
1961
- }
1157
+ if (registrationNumber) {
1158
+ entityObject.registrationNumber = registrationNumber;
1159
+ if (canSaveRegNumberAbsentState && requestObj.organization) {
1160
+ requestObj.organization.registrationNumberAbsent = false;
1962
1161
  }
1963
- });
1964
- }, [
1965
- clearCompanyData,
1966
- isUS,
1967
- businessName,
1968
- tin,
1969
- getCompanySelection,
1970
- subjectEntity?.id,
1971
- subjectEntity?.type,
1972
- userEvents
1973
- ]);
1974
- if (prevCompanySearchResults !== companySearchResults) {
1975
- if (companySearchResults?.length === 1 && isNormalizedStringMatch(businessName, companySearchResults[0].name)) {
1976
- setSingleCompanyDatasetParams({
1977
- company: companySearchResults[0],
1978
- state: currentState.data.basicInformation?.stateOrProvince,
1979
- name: businessName,
1980
- tin
1981
- });
1982
- } else if (companySearchResults?.length === 0 && !searchingCompanies && showBusinessSelection) {
1983
- proceedToManualDataEntry();
1984
1162
  }
1985
- setPrevCompanySearchResults(companySearchResults);
1986
- }
1987
- const [prevSingleCompanyDatasetResponse, setPrevSingleCompanyDatasetResponse] = useState(
1988
- singleCompanyDatasetAndTinResponse
1989
- );
1990
- if (prevSingleCompanyDatasetResponse !== singleCompanyDatasetAndTinResponse) {
1991
- if (singleCompanyDatasetAndTinResponse?.tinMatched === true) {
1992
- setVerifiedBusiness(singleCompanyDatasetAndTinResponse);
1993
- handleNextClick();
1994
- } else {
1995
- setBusinessMismatchModalOpen(true);
1996
- setTinMatched(false);
1163
+ if (requestObj.organization && entityObject && localization.length > 0) {
1164
+ entityObject.localization = localization;
1997
1165
  }
1998
- setPrevSingleCompanyDatasetResponse(singleCompanyDatasetAndTinResponse);
1999
- }
2000
- useEffect(() => {
2001
- if (searchingError) {
2002
- proceedToManualDataEntry();
1166
+ if (data.additionalInformation?.exemptedFromRegistrationNumber && canSaveRegNumberAbsentState && requestObj.organization) {
1167
+ requestObj.organization.registrationNumberAbsent = data.additionalInformation?.exemptedFromRegistrationNumber;
2003
1168
  }
2004
- }, [searchingError]);
2005
- const isBusinessSelection = showBusinessSelection && activeForm.formId === formWith2Views;
2006
- const hideFooter = isBusinessSelection === true && loading;
2007
- const hideNextButton = activeForm.formId === formWith2Views ? isBusinessSelection : false;
2008
- const showBackButton = !COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry) ? false : isBusinessSelection ? loading : false;
2009
- const goToForm = useCallback(
2010
- (index) => {
2011
- if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) {
2012
- return gotoFormByFormIndex(index);
2013
- }
2014
- const selectedFormId = forms[index].formId;
2015
- if (selectedFormId === formWith2Views) {
2016
- if (verifiedBusiness$1) setShowBusinessSelection(false);
2017
- if (activeForm.formId === "companyStructure" && companySearchResults?.length) {
2018
- setShowCompanyStructure(false);
2019
- }
2020
- return gotoFormByFormIndex(index);
2021
- } else {
2022
- if (verifiedBusiness$1) return gotoFormByFormIndex(index);
2023
- if (activeForm.formId !== formWith2Views) return gotoFormByFormIndex(index);
2024
- if (activeForm.formId === formWith2Views && !isBusinessSelection) {
2025
- setShowBusinessSelection(true);
2026
- }
1169
+ if (data.additionalInformation?.vatAbsenceReason) {
1170
+ entityObject.vatNumber = "";
1171
+ }
1172
+ if (isExperimentEnabled("EnableDoingBusinessAsNameV4")) {
1173
+ if (typeof data.additionalInformation?.hasDoingBusinessAs !== "undefined") {
1174
+ entityObject.doingBusinessAsAbsent = !data.additionalInformation?.hasDoingBusinessAs;
2027
1175
  }
2028
- },
2029
- [
2030
- currentCountry,
2031
- forms,
2032
- gotoFormByFormIndex,
2033
- verifiedBusiness$1,
2034
- activeForm.formId,
2035
- companySearchResults?.length,
2036
- isBusinessSelection
2037
- ]
2038
- );
2039
- const nextClick = useCallback(() => {
2040
- if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry) || accountHolder !== "theCompanyIWorkFor")
2041
- return handleNextClick();
2042
- if (activeForm.formId === formWith2Views && currentState.validityByForm?.basicInformation && !isBusinessSelection && !verifiedBusiness$1) {
2043
- setCompanySearchParams({
2044
- legalCompanyName: currentState?.data?.basicInformation?.legalCompanyName ?? "",
2045
- country: currentState?.data.basicInformation?.country ?? country,
2046
- stateOrProvince: currentState?.data.basicInformation?.stateOrProvince,
2047
- registrationNumber: currentState?.data.basicInformation?.registrationNumber
2048
- });
2049
- setShowBusinessSelection(true);
2050
1176
  } else {
2051
- handleNextClick();
1177
+ entityObject.doingBusinessAs = doingBusinessAs || data.basicInformation?.legalCompanyName;
1178
+ delete entityObject.doingBusinessAsAbsent;
2052
1179
  }
2053
- }, [
2054
- currentCountry,
2055
- isSoleProp,
2056
- handleNextClick,
2057
- activeForm.formId,
2058
- currentState.validityByForm?.basicInformation,
2059
- currentState?.data.basicInformation?.legalCompanyName,
2060
- currentState?.data.basicInformation?.country,
2061
- currentState?.data.basicInformation?.stateOrProvince,
2062
- currentState?.data.basicInformation?.registrationNumber,
2063
- isBusinessSelection,
2064
- verifiedBusiness$1,
2065
- country
2066
- ]);
2067
- const backClick = useCallback(() => {
2068
- if (!COUNTRIES_USING_COMPANY_SEARCH.includes(currentCountry)) handleBackClick?.();
2069
- else {
2070
- switch (activeForm.formId) {
2071
- case formWith2Views: {
2072
- if (showBusinessSelection) setShowBusinessSelection(false);
2073
- break;
2074
- }
2075
- case "companyStructure": {
2076
- if (searchingError) {
2077
- setShowBusinessSelection(false);
2078
- setShowCompanyStructure(false);
2079
- handleBackClick?.();
2080
- break;
2081
- }
2082
- if (!searchingCompanies && companySearchResults && !companySearchResults.length) {
2083
- setShowBusinessSelection(false);
2084
- } else if (!verifiedBusiness$1) setShowCompanyStructure(false);
2085
- handleBackClick?.();
2086
- break;
2087
- }
2088
- case "additionalInformation": {
2089
- if (verifiedBusiness$1) setShowBusinessSelection(false);
2090
- handleBackClick?.();
2091
- break;
2092
- }
2093
- default:
2094
- handleBackClick?.();
2095
- break;
2096
- }
1180
+ if (data.additionalInformation?.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME && entityObject.principalPlaceOfBusiness) {
1181
+ entityObject.principalPlaceOfBusiness = entityObject.registeredAddress;
2097
1182
  }
2098
- }, [
2099
- currentCountry,
2100
- handleBackClick,
2101
- activeForm.formId,
2102
- showBusinessSelection,
2103
- searchingError,
2104
- searchingCompanies,
2105
- companySearchResults,
2106
- verifiedBusiness$1
2107
- ]);
2108
- const homeClick = () => {
2109
- handleHomeClick?.();
2110
- };
2111
- const handleBusinessMismatchContinue = useCallback(() => {
2112
- setShowCompanyStructure(true);
2113
- setTrustedFields([]);
2114
- setBusinessMismatchModalOpen(false);
2115
- }, [setShowCompanyStructure, setTrustedFields, setBusinessMismatchModalOpen]);
2116
- const handleBusinessMismatchCancel = useCallback(() => {
2117
- backClick?.();
2118
- setBusinessMismatchModalOpen(false);
2119
- setTinMatched(void 0);
2120
- }, [backClick, setTinMatched, setBusinessMismatchModalOpen]);
2121
- const resetBusinessData = useCallback(() => {
2122
- queryClient.resetQueries({
2123
- queryKey: [
2124
- "companySearch",
2125
- {
2126
- name: companySearchParams.legalCompanyName ?? "",
2127
- country: companySearchParams.country,
2128
- state: companySearchParams.stateOrProvince,
2129
- registrationNumber: companySearchParams.registrationNumber
2130
- }
2131
- ]
2132
- });
2133
- setVerifiedBusiness(void 0);
2134
- }, [
2135
- companySearchParams.country,
2136
- companySearchParams.legalCompanyName,
2137
- companySearchParams.registrationNumber,
2138
- companySearchParams.stateOrProvince,
2139
- queryClient
2140
- ]);
2141
- useEffect(() => {
2142
- if (verifiedBusiness$1?.name && currentState.data.basicInformation?.legalCompanyName !== verifiedBusiness$1?.name && (currentState.data.basicInformation?.legalCompanyName !== companySearchParams.legalCompanyName || currentState.data.basicInformation?.stateOrProvince !== companySearchParams.stateOrProvince)) {
2143
- setShowCompanyStructure(false);
2144
- resetBusinessData();
1183
+ if (entityObject.registeredAddress) {
1184
+ const addressLocalizations = mapJpAddressSchemaToAddressLocalizations(
1185
+ data.additionalInformation?.registrationAddress
1186
+ );
1187
+ if (addressLocalizations.length > 0)
1188
+ entityObject.registeredAddress.localization = addressLocalizations;
2145
1189
  }
2146
- }, [
2147
- companySearchParams,
2148
- currentState.data.basicInformation,
2149
- currentState.data.basicInformation?.legalCompanyName,
2150
- resetBusinessData,
2151
- verifiedBusiness$1
2152
- ]);
2153
- const [prevCurrentCountry, setPrevCurrentCountry] = useState(currentCountry);
2154
- if (prevCurrentCountry !== currentCountry && trustedFields?.length && legalEntityResponse.organization?.registeredAddress.country !== currentCountry) {
2155
- setTrustedFields(void 0);
2156
- setPrevCurrentCountry(currentCountry);
2157
- }
2158
- return /* @__PURE__ */ jsxs(
2159
- FormWrapper,
2160
- {
2161
- taskName: taskName ?? "businessDetails",
2162
- gotoFormByFormIndex: goToForm,
2163
- hideSidebar,
2164
- hideFooter,
2165
- loadingStatus,
2166
- forms,
2167
- activeForm,
2168
- validateForm: () => setShouldValidate(true),
2169
- onSubmit: submitTask,
2170
- problems: currentProblems,
2171
- canSubmit: canSubmitForm,
2172
- summary: summaryData,
2173
- handleNextClick: nextClick,
2174
- handleBackClick: backClick,
2175
- handleHomeClick: homeClick,
2176
- steps,
2177
- showBackButton,
2178
- hideNextButton,
2179
- children: [
2180
- /* @__PURE__ */ jsx(
2181
- BusinessDetails,
2182
- {
2183
- ...derivedProps,
2184
- ref: formRef,
2185
- data: initialData,
2186
- country: currentCountry,
2187
- problems: currentProblems,
2188
- activeForm,
2189
- shouldValidate,
2190
- isTopLevelEntity: taskType === TaskTypes.BUSINESS_DETAILS,
2191
- showBusinessSelection,
2192
- setShowBusinessSelection,
2193
- showCompanyStructure,
2194
- setShowCompanyStructure,
2195
- searchResults: companySearchResults,
2196
- loading,
2197
- proceedToManualDataEntry,
2198
- handleNextClick: nextClick,
2199
- taskType
2200
- }
2201
- ),
2202
- businessMismatchModalOpen2 && /* @__PURE__ */ jsx(
2203
- Confirm,
2204
- {
2205
- title: t(($) => $["businessSelection__tinVerificationFailureModalHeader"], {
2206
- ns: "business"
2207
- }),
2208
- description: t(($) => $["businessSelection__tinVerificationFailureModalContent"], {
2209
- ns: "business"
2210
- }),
2211
- cancelText: t(($) => $["businessSelection__tinVerificationFailureModalSecondaryButton"], {
2212
- ns: "business"
2213
- }),
2214
- confirmText: t(($) => $["businessSelection__tinVerificationFailureModalPrimaryButton"], {
2215
- ns: "business"
2216
- }),
2217
- onCancel: handleBusinessMismatchCancel,
2218
- onConfirm: handleBusinessMismatchContinue
2219
- }
1190
+ if (!isEmpty$1(data.companyFinancialInformation)) {
1191
+ const isIncorporationDateDependencyEnabled = isExperimentEnabled(
1192
+ "EnableIncorporationDateBasedFinancialValidationForHO"
1193
+ );
1194
+ entityObject.financialReports = [
1195
+ mapFinancialInformationToFinancialReport(
1196
+ data.companyFinancialInformation,
1197
+ isIncorporationDateDependencyEnabled ? data?.additionalInformation?.dateOfIncorporation : void 0
2220
1198
  )
2221
- ]
1199
+ ];
2222
1200
  }
2223
- );
2224
- }
2225
- const LazyJpAddress = lazy(
2226
- async () => (await import("./JpAddress-CN0KeBU3.js")).JpAddress
2227
- );
2228
- function AdditionalInformationMultiform({
2229
- id,
2230
- country,
2231
- companyType,
2232
- shouldValidate,
2233
- validationErrors = {},
2234
- verificationErrors = {}
2235
- }) {
2236
- const { t, i18n } = useTranslation(["common", "business"]);
2237
- const { form } = useFormContext();
2238
- const { isExperimentEnabled } = useExperimentsContext();
2239
- const { data: rootLegalEntity } = useLegalEntity(ROOT_LE);
2240
- const verifiedBusiness$1 = verifiedBusiness.value;
2241
- const showVerified = !!verifiedBusiness$1;
2242
- const showStockData = companyType === CompanyTypesValues.PUBLIC_COMPANY;
2243
- const addressSchema = getAddressSchemaForCountry(country).filter(
2244
- (field) => !COUNTRIES_WITH_STATES_DATASET.includes(country) ? field !== "stateOrProvince" : true
2245
- );
2246
- const currentCountryTaxInformation = form.data?.additionalInformation?.taxInformation?.find(
2247
- (taxId) => taxId.country === country
2248
- );
2249
- const businessLineTypes = [];
2250
- if (requestingBanking(rootLegalEntity)) {
2251
- businessLineTypes.push("banking");
2252
1201
  }
2253
- if (requestingIssuing(rootLegalEntity)) {
2254
- businessLineTypes.push("issuing");
1202
+ requestObj.type = requestObj.organization ? LegalEntityTypes.ORGANIZATION : LegalEntityTypes.SOLE_PROPRIETORSHIP;
1203
+ if (entityObject?.registeredAddress.country === "US") {
1204
+ delete entityObject.registrationNumber;
2255
1205
  }
2256
- const [addressToCheck, setAddressToCheck] = useDebouncedState(500);
2257
- const { data: cleansedRegistrationAddress } = useAddressCleanse(
2258
- {
2259
- text: addressToCheck,
2260
- country
2261
- },
2262
- { enabled: Boolean(addressToCheck) }
2263
- );
2264
- const mustProvideOperationalAddress = cleansedRegistrationAddress?.poBox ?? false;
2265
- useEffect(
2266
- () => setAddressToCheck(
2267
- formatAddressForCleanse(form.data?.additionalInformation?.registrationAddress ?? {})
2268
- ),
2269
- [form.data?.additionalInformation?.registrationAddress, setAddressToCheck]
2270
- );
2271
- const verifiedAddress = useMemo(() => {
2272
- if (!verifiedBusiness$1) return void 0;
2273
- return verifiedBusiness$1.isPrincipalAddress || verifiedBusiness$1.state && form.data?.basicInformation?.stateOrProvince !== verifiedBusiness$1.state ? { operationalAddress: { ...mapAddressData(verifiedBusiness$1), country } } : {
2274
- registrationAddress: {
2275
- ...mapAddressData(verifiedBusiness$1),
2276
- country,
2277
- stateOrProvince: form.data?.basicInformation?.stateOrProvince
2278
- }
2279
- };
2280
- }, [verifiedBusiness$1, form.data?.basicInformation?.stateOrProvince, country]);
2281
- const handleChangeFor = useCallback(
2282
- (fieldName, mode) => form.handleChangeFor(fieldName, "additionalInformation", mode),
2283
- [form]
2284
- );
2285
- const handleRegistrationAddressChange = (state) => {
2286
- handleChangeFor("registrationAddress")(state.data);
2287
- form.setValid("registrationAddress", Boolean(state.isValid), "additionalInformation");
2288
- };
2289
- const handleOperationalAddressChange = (state) => {
2290
- handleChangeFor("operationalAddress")(state.data);
2291
- form.setValid("operationalAddress", Boolean(state.isValid), "additionalInformation");
2292
- };
2293
- const handleOperationalAddressIsSameChange = useCallback(
2294
- (isChecked) => {
2295
- if (isChecked) {
2296
- handleChangeFor("operationalAddressIsSame")(
2297
- operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME
2298
- );
2299
- form.setValid("operationalAddress", true, "additionalInformation");
2300
- } else {
2301
- handleChangeFor("operationalAddressIsSame")(
2302
- operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME
2303
- );
2304
- }
2305
- },
2306
- [form, handleChangeFor]
2307
- );
2308
- if (form.data?.additionalInformation?.operationalAddressIsSame === null) {
2309
- handleOperationalAddressIsSameChange(true);
1206
+ if (!canSaveRegNumberAbsentState) {
1207
+ delete requestObj.organization?.registrationNumberAbsent;
2310
1208
  }
2311
- useEffect(() => {
2312
- if (mustProvideOperationalAddress && form.data?.additionalInformation?.operationalAddressIsSame !== operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME) {
2313
- handleOperationalAddressIsSameChange(false);
2314
- }
2315
- }, [
2316
- handleOperationalAddressIsSameChange,
2317
- mustProvideOperationalAddress,
2318
- form.data?.additionalInformation?.operationalAddressIsSame
2319
- ]);
2320
- const formUtils = useMemo(() => {
2321
- const initialProps = {
2322
- data: form.data?.additionalInformation ?? {},
2323
- fieldValidationErrors: validationErrors,
2324
- formVerificationErrors: verificationErrors,
2325
- allFields: form.allFields?.additionalInformation ?? [],
2326
- requiredFields: form.requiredFields?.additionalInformation ?? [],
2327
- optionalFields: form.optionalFields?.additionalInformation ?? [],
2328
- trustedFields: form.trustedFields?.additionalInformation ?? [],
2329
- obscuredFields: form.obscuredFields?.additionalInformation ?? [],
2330
- errors: form.errors?.additionalInformation ?? {},
2331
- valid: form.valid?.additionalInformation ?? {},
2332
- handleFieldChange: handleChangeFor
2333
- };
2334
- const formUtilProps = initialProps.allFields?.reduce((acc, field) => {
2335
- switch (field) {
2336
- case "hasDoingBusinessAs":
2337
- return mergeFieldMetadataIntoProps(
2338
- "hasDoingBusinessAs",
2339
- doingBusinessAsAbsentFieldMetadata,
2340
- acc
2341
- );
2342
- case "doingBusinessAs":
2343
- return mergeFieldMetadataIntoProps("doingBusinessAs", doingBusinessAsFieldMetadata, acc);
2344
- case "registrationNumber":
2345
- return mergeFieldMetadataIntoProps(
2346
- field,
2347
- resolveFieldMetadata(
2348
- registrationNumberDefaultFieldConfig[country],
2349
- {
2350
- companyType,
2351
- registrationNumberType: form.data?.additionalInformation?.registrationNumberType,
2352
- isExperimentEnabled
2353
- },
2354
- registrationNumberDefaultFieldMetadata
2355
- ),
2356
- acc
2357
- );
2358
- case "taxInformation":
2359
- return mergeFieldMetadataIntoProps(
2360
- field,
2361
- resolveFieldMetadata(
2362
- taxInformationDefaultFieldConfig[country],
2363
- {
2364
- taxIdNumberType: currentCountryTaxInformation?.type,
2365
- companyType
2366
- },
2367
- taxInformationDefaultFieldMetadata
2368
- ),
2369
- acc
2370
- );
2371
- case "vatNumber":
2372
- return mergeFieldMetadataIntoProps(
2373
- field,
2374
- resolveFieldMetadata(
2375
- defaultFieldConfig[country],
2376
- { vatNumberType: form.data?.additionalInformation?.vatNumberType },
2377
- defaultFieldMetadata
2378
- ),
2379
- acc
2380
- );
2381
- case "vatAbsenceReason":
2382
- return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
2383
- case "eInvoicingCode":
2384
- return mergeFieldMetadataIntoProps("eInvoicingCode", eInvoicingCodeFieldMetadata, acc);
2385
- case "industryCodes":
2386
- return mergeFieldMetadataIntoProps("industryCodes", industryCodeFieldMetadata, acc);
2387
- case "dateOfIncorporation":
2388
- return mergeFieldMetadataIntoProps(
2389
- "dateOfIncorporation",
2390
- dateOfIncorporationFieldMetadata,
2391
- acc
2392
- );
2393
- case "stockExchangeMIC":
2394
- return mergeFieldMetadataIntoProps(
2395
- "stockExchangeMIC",
2396
- stockExchangeMICFieldMetadata,
2397
- acc
2398
- );
2399
- case "stockISIN":
2400
- return mergeFieldMetadataIntoProps("stockISIN", stockISINFieldMetadata, acc);
2401
- case "stockTickerSymbol":
2402
- return mergeFieldMetadataIntoProps(
2403
- "stockTickerSymbol",
2404
- stockTickerSymbolFieldMetadata,
2405
- acc
2406
- );
2407
- case "legalForm":
2408
- return mergeFieldMetadataIntoProps("legalForm", legalFormFieldMetadata, acc);
2409
- default:
2410
- return acc;
2411
- }
2412
- }, initialProps);
2413
- return createFormUtils(formUtilProps ?? initialProps, t);
2414
- }, [
2415
- companyType,
2416
- country,
2417
- currentCountryTaxInformation?.type,
2418
- form.allFields?.additionalInformation,
2419
- form.data?.additionalInformation,
2420
- form.errors?.additionalInformation,
2421
- form.obscuredFields?.additionalInformation,
2422
- form.optionalFields?.additionalInformation,
2423
- form.requiredFields?.additionalInformation,
2424
- form.trustedFields?.additionalInformation,
2425
- form.valid?.additionalInformation,
2426
- handleChangeFor,
2427
- t,
2428
- isExperimentEnabled,
2429
- validationErrors,
2430
- verificationErrors
2431
- ]);
2432
- const showField = (fieldKeys) => fieldKeys.some((field) => formUtils.isRequiredField(field) || formUtils.isOptionalField(field));
2433
- const { data: industryCodes } = useIndustryCodes(businessLineTypes, i18n.language, {
2434
- enabled: showField(INDUSTRY_CODE_FIELD)
2435
- });
2436
- const datasetUtils = datasetUtilities(i18n.language);
2437
- const registrationAddressDescription = useMemo(() => {
2438
- if (country) {
2439
- return ["US", "NL", "CZ"].includes(country) ? t(($) => $["youBusinessOfficalAddressInTheCounty"], {
2440
- ns: "business",
2441
- country: datasetUtils.getCountryName(country)
2442
- }) : t(($) => $["youBusinessOfficalAddressInCounty"], {
2443
- ns: "business",
2444
- country: datasetUtils.getCountryName(country)
2445
- });
2446
- }
2447
- return t(($) => $["youBusinessOfficalAddress"], { ns: "business" });
2448
- }, [country, datasetUtils, t]);
2449
- return /* @__PURE__ */ jsxs("form", { id, className: "adyen-kyc-additional-information", children: [
2450
- /* @__PURE__ */ jsx(Header, { title: t(($) => $["additionalInformationFormHeading"], { ns: "business" }) }),
2451
- /* @__PURE__ */ jsx(
2452
- ErrorPanel,
2453
- {
2454
- id: "ariaErrorField",
2455
- verificationErrors,
2456
- validationErrors,
2457
- formUtils
2458
- }
2459
- ),
2460
- /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-additional-information__content", children: [
2461
- showVerified && /* @__PURE__ */ jsxs("section", { children: [
2462
- /* @__PURE__ */ jsx("div", { className: "adyen-kyc-additional-information__section-heading", children: /* @__PURE__ */ jsx(Typography, { el: "h3", variant: "title", children: t(($) => $["verifiedInformation"], { ns: "business" }) }) }),
2463
- /* @__PURE__ */ jsx(
2464
- VerifiedBusinessCard,
2465
- {
2466
- verifiedBusiness: verifiedBusiness$1,
2467
- verifiedAddress: verifiedAddress?.registrationAddress ?? verifiedAddress?.operationalAddress
2468
- }
2469
- )
2470
- ] }),
2471
- /* @__PURE__ */ jsxs("section", { children: [
2472
- showVerified && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-additional-information__section-heading", children: /* @__PURE__ */ jsx(Typography, { el: "h3", variant: "title", children: t(($) => $["otherBusinessInformation"], { ns: "business" }) }) }),
2473
- /* @__PURE__ */ jsxs("fieldset", { children: [
2474
- showField(LEGAL_FORM_FIELDS) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2475
- LegalFormField,
2476
- {
2477
- name: "legalForm",
2478
- countryCode: country,
2479
- data: {
2480
- legalForm: formUtils.getFieldData(
2481
- form.data?.additionalInformation ?? {},
2482
- LEGAL_FORM_FIELDS
2483
- )?.legalForm
2484
- },
2485
- valid: formUtils.getFieldValid(
2486
- form.valid?.additionalInformation ?? {},
2487
- LEGAL_FORM_FIELDS
2488
- ),
2489
- errorMessage: form.errors.additionalInformation?.legalForm?.errorMessage,
2490
- handleChangeFor,
2491
- readonly: false,
2492
- label: formUtils.getLabel("legalForm", "businessStructure")
2493
- }
2494
- ) }),
2495
- showField(DBA_NAME_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2496
- DBANameField,
2497
- {
2498
- data: formUtils.getFieldData(
2499
- form.data?.additionalInformation ?? {},
2500
- DBA_NAME_FIELD
2501
- ),
2502
- valid: formUtils.getFieldValid(
2503
- form.valid?.additionalInformation ?? {},
2504
- DBA_NAME_FIELD
2505
- ),
2506
- errors: formUtils.getFieldErrors(
2507
- form.errors?.additionalInformation ?? {},
2508
- validationErrors,
2509
- DBA_NAME_FIELD
2510
- ),
2511
- labels: formUtils.getFieldLabels(DBA_NAME_FIELD, {
2512
- hasDoingBusinessAs: "hasDba"
2513
- }),
2514
- readonly: formUtils.isReadOnly("doingBusinessAs"),
2515
- handleChangeFor
2516
- }
2517
- ) }),
2518
- showField(BUSINESS_REGISTRATION_NUMBER_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2519
- BusinessRegistrationNumberField,
2520
- {
2521
- data: formUtils.getFieldData(
2522
- form.data?.additionalInformation ?? {},
2523
- BUSINESS_REGISTRATION_NUMBER_FIELD
2524
- ),
2525
- valid: formUtils.getFieldValid(
2526
- form.valid?.additionalInformation ?? {},
2527
- BUSINESS_REGISTRATION_NUMBER_FIELD
2528
- ),
2529
- errors: formUtils.getFieldErrors(
2530
- form.errors?.additionalInformation ?? {},
2531
- validationErrors,
2532
- BUSINESS_REGISTRATION_NUMBER_FIELD
2533
- ),
2534
- labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD, {
2535
- exemptedFromRegistrationNumber: "iDontHaveARegistrationNumber"
2536
- }),
2537
- mask: formUtils.getMask("registrationNumber"),
2538
- guidanceText: formUtils.getFieldGuidanceText(BUSINESS_REGISTRATION_NUMBER_FIELD),
2539
- placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
2540
- helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
2541
- readonly: formUtils.isReadOnly("registrationNumber"),
2542
- optional: formUtils.isOptionalField("registrationNumber"),
2543
- shouldValidate,
2544
- handleChangeFor,
2545
- country,
2546
- canExempt: showField(["exemptedFromRegistrationNumber"]),
2547
- companyType
2548
- }
2549
- ) }),
2550
- showField(TAX_INFORMATION_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2551
- TaxInformationField,
2552
- {
2553
- data: formUtils.getFieldData(
2554
- form.data?.additionalInformation ?? {},
2555
- TAX_INFORMATION_FIELD
2556
- ),
2557
- valid: formUtils.getFieldValid(
2558
- form.valid?.additionalInformation ?? {},
2559
- TAX_INFORMATION_FIELD
2560
- ),
2561
- errors: formUtils.getFieldErrors(
2562
- form.errors?.additionalInformation ?? {},
2563
- validationErrors,
2564
- TAX_INFORMATION_FIELD
2565
- ),
2566
- labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD, {
2567
- exemptedFromTax: "iDontHaveATaxId"
2568
- }),
2569
- mask: formUtils.getMask("taxInformation"),
2570
- guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
2571
- readonly: formUtils.isReadOnly("taxInformation"),
2572
- shouldValidate,
2573
- handleChangeFor,
2574
- canExempt: showField(["exemptedFromTax"]),
2575
- country,
2576
- entityType: companyType,
2577
- defaultData: form.defaultData?.additionalInformation?.taxInformation,
2578
- registrationNumber: form.data?.additionalInformation?.registrationNumber
2579
- }
2580
- ) }),
2581
- showField(VAT_NUMBER_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2582
- VatNumberField,
2583
- {
2584
- data: formUtils.getFieldData(
2585
- form.data?.additionalInformation ?? {},
2586
- VAT_NUMBER_FIELD
2587
- ),
2588
- valid: formUtils.getFieldValid(
2589
- form.valid?.additionalInformation ?? {},
2590
- VAT_NUMBER_FIELD
2591
- ),
2592
- errors: formUtils.getFieldErrors(
2593
- form.errors?.additionalInformation ?? {},
2594
- validationErrors,
2595
- VAT_NUMBER_FIELD
2596
- ),
2597
- labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD, {
2598
- exemptedFromVat: "iDontHaveAVatNumber"
2599
- }),
2600
- mask: formUtils.getMask("vatNumber"),
2601
- guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
2602
- placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
2603
- readonly: formUtils.isReadOnly("vatNumber"),
2604
- handleChangeFor,
2605
- country,
2606
- canExempt: showField(["exemptedFromVat"]),
2607
- shouldValidate
2608
- }
2609
- ) }),
2610
- formUtils.isRequiredField("eInvoicingCode", false) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2611
- EInvoicingCodeField,
2612
- {
2613
- data: formUtils.getFieldData(
2614
- form.data?.additionalInformation ?? {},
2615
- EINVOICING_CODE_FIELD
2616
- ),
2617
- valid: formUtils.getFieldValid(
2618
- form.valid?.additionalInformation ?? {},
2619
- EINVOICING_CODE_FIELD
2620
- ),
2621
- errors: formUtils.getFieldErrors(
2622
- form.errors?.additionalInformation ?? {},
2623
- validationErrors,
2624
- EINVOICING_CODE_FIELD
2625
- ),
2626
- labels: formUtils.getFieldLabels(EINVOICING_CODE_FIELD),
2627
- placeholders: formUtils.getFieldPlaceholders(EINVOICING_CODE_FIELD),
2628
- mask: formUtils.getMask("eInvoicingCode"),
2629
- guidanceText: formUtils.getFieldGuidanceText(EINVOICING_CODE_FIELD),
2630
- readonly: formUtils.isReadOnly("eInvoicingCode"),
2631
- handleChangeFor
2632
- }
2633
- ) }),
2634
- showField(INDUSTRY_CODE_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", "data-testid": "industryCode", children: /* @__PURE__ */ jsx(
2635
- IndustryCodeField,
2636
- {
2637
- data: formUtils.getFieldData(
2638
- form.data?.additionalInformation ?? {},
2639
- INDUSTRY_CODE_FIELD
2640
- ),
2641
- valid: formUtils.getFieldValid(
2642
- form.valid?.additionalInformation ?? {},
2643
- INDUSTRY_CODE_FIELD
2644
- ),
2645
- errors: formUtils.getFieldErrors(
2646
- form.errors?.additionalInformation ?? {},
2647
- validationErrors,
2648
- INDUSTRY_CODE_FIELD
2649
- ),
2650
- labels: {
2651
- industryCodes: t(($) => $["industry"], {
2652
- ns: "business"
2653
- })
2654
- },
2655
- guidanceText: {
2656
- industryCodes: t(($) => $["primaryIndustryCodeGuidance"], {
2657
- ns: "business"
2658
- })
2659
- },
2660
- readonly: formUtils.isReadOnly("industryCodes"),
2661
- handleChangeFor,
2662
- businessLineTypes,
2663
- single: true,
2664
- industryCodes: industryCodes ?? []
2665
- }
2666
- ) }),
2667
- showField(DATE_OF_INCORPORATION_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2668
- DateOfIncorporationField,
2669
- {
2670
- data: formUtils.getFieldData(
2671
- form.data?.additionalInformation ?? {},
2672
- DATE_OF_INCORPORATION_FIELD
2673
- ),
2674
- valid: formUtils.getFieldValid(
2675
- form.valid?.additionalInformation ?? {},
2676
- DATE_OF_INCORPORATION_FIELD
2677
- ),
2678
- errors: formUtils.getFieldErrors(
2679
- form.errors?.additionalInformation ?? {},
2680
- validationErrors,
2681
- DATE_OF_INCORPORATION_FIELD
2682
- ),
2683
- labels: formUtils.getFieldLabels(DATE_OF_INCORPORATION_FIELD),
2684
- placeholders: formUtils.getFieldPlaceholders(DATE_OF_INCORPORATION_FIELD, {
2685
- dateOfIncorporation: "datePlaceholder"
2686
- }),
2687
- readonly: formUtils.isReadOnly("dateOfIncorporation"),
2688
- handleChangeFor
2689
- }
2690
- ) })
2691
- ] })
2692
- ] }),
2693
- showStockData && /* @__PURE__ */ jsxs("section", { children: [
2694
- /* @__PURE__ */ jsx("div", { className: "adyen-kyc-additional-information__section-heading", children: /* @__PURE__ */ jsx(Typography, { el: "h3", variant: "title", children: t(($) => $["stockExchangeInformation"], { ns: "business" }) }) }),
2695
- /* @__PURE__ */ jsxs("fieldset", { children: [
2696
- showField(STOCK_EXCHANGE_MIC_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2697
- StockExchangeMICField,
2698
- {
2699
- data: formUtils.getFieldData(
2700
- form.data?.additionalInformation ?? {},
2701
- STOCK_EXCHANGE_MIC_FIELD
2702
- ),
2703
- valid: formUtils.getFieldValid(
2704
- form.valid?.additionalInformation ?? {},
2705
- STOCK_EXCHANGE_MIC_FIELD
2706
- ),
2707
- errors: formUtils.getFieldErrors(
2708
- form.errors?.additionalInformation ?? {},
2709
- validationErrors,
2710
- STOCK_EXCHANGE_MIC_FIELD
2711
- ),
2712
- labels: formUtils.getFieldLabels(STOCK_EXCHANGE_MIC_FIELD),
2713
- placeholders: formUtils.getFieldPlaceholders(STOCK_EXCHANGE_MIC_FIELD),
2714
- mask: formUtils.getMask("stockExchangeMIC"),
2715
- guidanceText: formUtils.getFieldGuidanceText(STOCK_EXCHANGE_MIC_FIELD),
2716
- readonly: formUtils.isReadOnly("stockExchangeMIC"),
2717
- shouldValidate,
2718
- handleChangeFor
2719
- }
2720
- ) }),
2721
- showField(STOCK_ISIN_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2722
- StockISINField,
2723
- {
2724
- data: formUtils.getFieldData(
2725
- form.data?.additionalInformation ?? {},
2726
- STOCK_ISIN_FIELD
2727
- ),
2728
- valid: formUtils.getFieldValid(
2729
- form.valid?.additionalInformation ?? {},
2730
- STOCK_ISIN_FIELD
2731
- ),
2732
- errors: formUtils.getFieldErrors(
2733
- form.errors?.additionalInformation ?? {},
2734
- validationErrors,
2735
- STOCK_ISIN_FIELD
2736
- ),
2737
- labels: formUtils.getFieldLabels(STOCK_ISIN_FIELD),
2738
- placeholders: formUtils.getFieldPlaceholders(STOCK_ISIN_FIELD),
2739
- mask: formUtils.getMask("stockISIN"),
2740
- guidanceText: formUtils.getFieldGuidanceText(STOCK_ISIN_FIELD),
2741
- readonly: formUtils.isReadOnly("stockISIN"),
2742
- shouldValidate,
2743
- handleChangeFor
2744
- }
2745
- ) }),
2746
- showField(STOCK_TICKER_SYMBOL_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
2747
- StockTickerSymbolField,
2748
- {
2749
- data: formUtils.getFieldData(
2750
- form.data?.additionalInformation ?? {},
2751
- STOCK_TICKER_SYMBOL_FIELD
2752
- ),
2753
- valid: formUtils.getFieldValid(
2754
- form.valid?.additionalInformation ?? {},
2755
- STOCK_TICKER_SYMBOL_FIELD
2756
- ),
2757
- errors: formUtils.getFieldErrors(
2758
- form.errors?.additionalInformation ?? {},
2759
- validationErrors,
2760
- STOCK_TICKER_SYMBOL_FIELD
2761
- ),
2762
- labels: formUtils.getFieldLabels(STOCK_TICKER_SYMBOL_FIELD),
2763
- placeholders: formUtils.getFieldPlaceholders(STOCK_TICKER_SYMBOL_FIELD),
2764
- mask: formUtils.getMask("stockTickerSymbol"),
2765
- guidanceText: formUtils.getFieldGuidanceText(STOCK_TICKER_SYMBOL_FIELD),
2766
- readonly: formUtils.isReadOnly("stockTickerSymbol"),
2767
- shouldValidate,
2768
- handleChangeFor
2769
- }
2770
- ) })
2771
- ] })
2772
- ] }),
2773
- /* @__PURE__ */ jsxs("section", { "data-testid": "registeredBusinessAddress", children: [
2774
- /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-additional-information__section-heading", children: [
2775
- /* @__PURE__ */ jsx(Typography, { el: "h3", variant: "title", children: t(($) => $["registeredBusinessAddress"], { ns: "business" }) }),
2776
- /* @__PURE__ */ jsx(Typography, { el: "p", variant: "body", children: registrationAddressDescription })
2777
- ] }),
2778
- country === CountryCodes.Japan ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Loader, {}), children: /* @__PURE__ */ jsx(
2779
- LazyJpAddress,
2780
- {
2781
- id: ADDITIONAL_INFORMATION_FORM_ID,
2782
- addressType: "registrationAddress",
2783
- data: { ...form.data.additionalInformation?.registrationAddress, country },
2784
- shouldValidate,
2785
- onChange: handleRegistrationAddressChange
2786
- }
2787
- ) }) : /* @__PURE__ */ jsx(
2788
- Address,
2789
- {
2790
- id: ADDITIONAL_INFORMATION_FORM_ID,
2791
- addressType: "registrationAddress",
2792
- data: {
2793
- ...form.data.additionalInformation?.registrationAddress,
2794
- country
2795
- },
2796
- labels: getAddressSchemaLabelsByCountry(country),
2797
- requiredFields: addressSchema,
2798
- shouldValidate,
2799
- hideCountry: true,
2800
- optionalFields: ["otherAddressInformation"],
2801
- readOnlyFields: verifiedBusiness$1?.state && verifiedBusiness$1?.state === form.data.basicInformation?.stateOrProvince ? ["stateOrProvince"] : [],
2802
- trustedFields: getNestedTrustedFields(
2803
- "registrationAddress",
2804
- form.data.additionalInformation,
2805
- form.trustedFields?.additionalInformation
2806
- ),
2807
- onChange: handleRegistrationAddressChange,
2808
- verifiedBusiness: verifiedBusiness$1,
2809
- verifiedAddress: verifiedAddress?.registrationAddress,
2810
- condensed: true
2811
- }
2812
- )
2813
- ] }),
2814
- /* @__PURE__ */ jsxs("section", { "data-testid": "principalPlaceOfBusiness", children: [
2815
- /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-additional-information__section-heading", children: [
2816
- /* @__PURE__ */ jsx(Typography, { el: "h3", variant: "title", children: t(($) => $["principalPlaceOfBusiness"], { ns: "business" }) }),
2817
- /* @__PURE__ */ jsx(Typography, { el: "p", variant: "body", children: t(($) => $["thePhysicalLocationWhereABusiness"], { ns: "business" }) })
2818
- ] }),
2819
- !mustProvideOperationalAddress && /* @__PURE__ */ jsx(
2820
- Field,
2821
- {
2822
- el: "fieldset",
2823
- name: "operationalAddressIsSame",
2824
- errorMessage: form.errors?.additionalInformation?.operationalAddressIsSame?.errorMessage,
2825
- isValid: form.valid?.additionalInformation?.operationalAddressIsSame,
2826
- children: (childProps) => /* @__PURE__ */ jsx(
2827
- Checkbox,
2828
- {
2829
- ...childProps,
2830
- "aria-required": formUtils.isRequiredField("operationalAddressIsSame"),
2831
- "aria-invalid": !form.valid?.additionalInformation?.operationalAddressIsSame,
2832
- name: "operationalAddressIsSame",
2833
- label: formUtils.getLabel("sameAsRegisteredAddress"),
2834
- checked: form.data?.additionalInformation?.operationalAddressIsSame ? form.data?.additionalInformation?.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME : true,
2835
- onChange: handleOperationalAddressIsSameChange
2836
- }
2837
- )
2838
- }
2839
- ),
2840
- form.data?.additionalInformation?.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME && (country === CountryCodes.Japan ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Loader, {}), children: /* @__PURE__ */ jsx(
2841
- LazyJpAddress,
2842
- {
2843
- id: ADDITIONAL_INFORMATION_FORM_ID,
2844
- addressType: "operationalAddress",
2845
- data: { ...form.data.additionalInformation.operationalAddress, country },
2846
- shouldValidate,
2847
- onChange: handleOperationalAddressChange
2848
- }
2849
- ) }) : /* @__PURE__ */ jsx(
2850
- Address,
2851
- {
2852
- id: ADDITIONAL_INFORMATION_FORM_ID,
2853
- addressType: "operationalAddress",
2854
- data: {
2855
- ...form.defaultData?.additionalInformation?.operationalAddress,
2856
- country
2857
- },
2858
- labels: getAddressSchemaLabelsByCountry(country),
2859
- requiredFields: addressSchema,
2860
- shouldValidate,
2861
- hideCountry: true,
2862
- optionalFields: ["otherAddressInformation"],
2863
- trustedFields: getNestedTrustedFields(
2864
- "operationalAddress",
2865
- form.data?.additionalInformation,
2866
- form.trustedFields?.additionalInformation
2867
- ),
2868
- onChange: handleOperationalAddressChange,
2869
- verifiedBusiness: verifiedBusiness$1,
2870
- verifiedAddress: verifiedAddress?.operationalAddress,
2871
- condensed: true
2872
- }
2873
- ))
2874
- ] })
2875
- ] })
2876
- ] });
2877
- }
2878
- [
2879
- ...COUNTRY_FIELD,
2880
- ...LEGAL_COMPANY_NAME_FIELD,
2881
- "jaHaniLegalCompanyName",
2882
- "jaKanaLegalCompanyName",
2883
- ...TAX_INFORMATION_FIELD,
2884
- ...STATE_FIELD,
2885
- ...BUSINESS_REGISTRATION_NUMBER_FIELD,
2886
- ...COUNTRY_OF_GOVERNING_LAW_FIELD
2887
- ];
2888
- const FormDescription = ({
2889
- description,
2890
- t
2891
- }) => {
2892
- return /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-form-header__description", children: [
2893
- description,
2894
- " ",
2895
- /* @__PURE__ */ jsx(Link, { href: "https://www.adyen.com/privacy-policy", external: true, children: t(($) => $["privacyStatement"]) })
2896
- ] });
1209
+ return requestObj;
2897
1210
  };
2898
- function BasicInformationMultiform({
2899
- id,
2900
- country,
2901
- shouldValidate,
2902
- validationErrors = {},
2903
- verificationErrors = {},
2904
- isTopLevelEntity,
2905
- disableCountry,
2906
- companyType
1211
+ function buildRequiredForms({
1212
+ config: {
1213
+ forms,
1214
+ requiredFields,
1215
+ optionalFields,
1216
+ isValid,
1217
+ problems,
1218
+ isSettingEnabled,
1219
+ accountHolder,
1220
+ legalEntityResponse
1221
+ },
1222
+ options
2907
1223
  }) {
2908
- const { t } = useTranslation(["common", "business"]);
2909
- const { isSettingEnabled } = useSettingsContext();
2910
- const { isExperimentEnabled } = useExperimentsContext();
2911
- const { form } = useFormContext();
2912
- const allowedCountries = useAllowedCountries();
2913
- const isAllowedEditPrefilledCountry = isSettingEnabled(SettingNames.AllowPrefilledCountryEdit);
2914
- const state = form.data?.basicInformation?.stateOrProvince;
2915
- const currentCountryTaxInformation = form.data?.basicInformation?.taxInformation?.find(
2916
- (tax) => tax.country === country
2917
- );
2918
- const handleChangeFor = useCallback(
2919
- (fieldName, mode) => form.handleChangeFor(fieldName, "basicInformation", mode),
2920
- [form]
2921
- );
2922
- const formUtils = useMemo(() => {
2923
- const initialProps = {
2924
- data: form.data?.basicInformation ?? {},
2925
- fieldValidationErrors: validationErrors,
2926
- formVerificationErrors: verificationErrors,
2927
- allFields: form.allFields?.basicInformation ?? [],
2928
- requiredFields: form.requiredFields?.basicInformation ?? [],
2929
- optionalFields: form.optionalFields?.basicInformation ?? [],
2930
- trustedFields: form.trustedFields?.basicInformation ?? [],
2931
- obscuredFields: form.obscuredFields?.basicInformation ?? [],
2932
- errors: form.errors?.basicInformation ?? {},
2933
- valid: form.valid?.basicInformation ?? {},
2934
- handleFieldChange: handleChangeFor
2935
- };
2936
- const formUtilProps = initialProps.allFields?.reduce((acc, field) => {
2937
- switch (field) {
2938
- case "country":
2939
- return acc;
2940
- case "legalCompanyName":
2941
- return mergeFieldMetadataIntoProps(
2942
- field,
2943
- resolveFieldMetadata(
2944
- isExperimentEnabled("StrictNameAndAddressValidationV4") ? defaultFieldConfigV4[country] : defaultFieldConfig$2[country],
2945
- { isBusiness: true },
2946
- isExperimentEnabled("StrictNameAndAddressValidationV4") ? defaultFieldMetadataV4 : defaultFieldMetadata$2
2947
- ),
2948
- acc
2949
- );
2950
- case "countryOfGoverningLaw":
2951
- return acc;
2952
- case "stateOrProvince":
2953
- return mergeFieldMetadataIntoProps(
2954
- field,
2955
- resolveFieldMetadata(
2956
- defaultFieldConfig$1[country],
2957
- { isBusiness: true },
2958
- defaultFieldMetadata$1
2959
- ),
2960
- acc
2961
- );
2962
- case "taxInformation":
2963
- return mergeFieldMetadataIntoProps(
2964
- field,
2965
- resolveFieldMetadata(
2966
- taxInformationDefaultFieldConfig[country],
2967
- {
2968
- taxIdNumberType: currentCountryTaxInformation?.type,
2969
- companyType
2970
- },
2971
- taxInformationDefaultFieldMetadata
2972
- ),
2973
- acc
2974
- );
2975
- case "registrationNumber":
2976
- return mergeFieldMetadataIntoProps(
2977
- field,
2978
- resolveFieldMetadata(
2979
- registrationNumberDefaultFieldConfig[country],
2980
- {
2981
- companyType,
2982
- registrationNumberType: form.data?.additionalInformation?.registrationNumberType,
2983
- state,
2984
- isExperimentEnabled
2985
- },
2986
- registrationNumberDefaultFieldMetadata
2987
- ),
2988
- acc
2989
- );
2990
- case "jaHaniLegalCompanyName":
2991
- return mergeFieldMetadataIntoProps(
2992
- field,
2993
- resolveFieldMetadata(
2994
- localizedLegalCompanyNameFieldConfig.jaHaniLegalCompanyName.config,
2995
- {},
2996
- localizedLegalCompanyNameFieldConfig.jaHaniLegalCompanyName.metadata
2997
- ),
2998
- acc
2999
- );
3000
- case "jaKanaLegalCompanyName":
3001
- return mergeFieldMetadataIntoProps(
3002
- field,
3003
- resolveFieldMetadata(
3004
- localizedLegalCompanyNameFieldConfig.jaKanaLegalCompanyName.config,
3005
- {},
3006
- localizedLegalCompanyNameFieldConfig.jaKanaLegalCompanyName.metadata
3007
- ),
3008
- acc
3009
- );
3010
- default:
3011
- return acc;
3012
- }
3013
- }, initialProps);
3014
- return createFormUtils(formUtilProps ?? initialProps, t);
3015
- }, [
3016
- companyType,
3017
- country,
3018
- currentCountryTaxInformation?.type,
3019
- form.allFields?.basicInformation,
3020
- form.data?.additionalInformation?.registrationNumberType,
3021
- form.data?.basicInformation,
3022
- form.errors?.basicInformation,
3023
- form.obscuredFields?.basicInformation,
3024
- form.optionalFields?.basicInformation,
3025
- form.requiredFields?.basicInformation,
3026
- form.trustedFields?.basicInformation,
3027
- form.valid?.basicInformation,
3028
- handleChangeFor,
3029
- isExperimentEnabled,
3030
- state,
3031
- t,
3032
- validationErrors,
3033
- verificationErrors
3034
- ]);
3035
- const showField = (fieldKeys) => fieldKeys.some((field) => {
3036
- switch (field) {
3037
- case "registrationNumberType":
3038
- case "registrationNumber": {
3039
- return (formUtils.isRequiredField(field) || formUtils.isOptionalField(field)) && form.data.basicInformation?.stateOrProvince;
3040
- }
3041
- default:
3042
- return formUtils.isRequiredField(field) || formUtils.isOptionalField(field);
3043
- }
3044
- });
3045
- const legalCompanyNameFields = useLegalCompanyNameField({
3046
- data: form.data.basicInformation ?? {},
3047
- valid: form.valid.basicInformation ?? {},
3048
- errors: form.errors.basicInformation ?? {},
3049
- fieldProblems: form.fieldProblems.basicInformation ?? {},
3050
- country,
3051
- formUtils,
3052
- handleChange: handleChangeFor
3053
- });
3054
- return /* @__PURE__ */ jsxs("form", { id, className: "adyen-kyc-basic-information", children: [
3055
- /* @__PURE__ */ jsx(Header, { title: t(($) => $["basicInformationFormHeading"], { ns: "business" }), children: /* @__PURE__ */ jsx(
3056
- FormDescription,
3057
- {
3058
- description: t(($) => $["basicInformationFormDescription"], { ns: "business" }),
3059
- t
3060
- }
3061
- ) }),
3062
- /* @__PURE__ */ jsx(
3063
- ErrorPanel,
3064
- {
3065
- id: "ariaErrorField",
3066
- verificationErrors,
3067
- validationErrors,
3068
- formUtils
3069
- }
3070
- ),
3071
- /* @__PURE__ */ jsx("fieldset", { children: /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
3072
- CountryField,
3073
- {
3074
- data: formUtils.getFieldData(form.data?.basicInformation ?? {}, COUNTRY_FIELD),
3075
- valid: formUtils.getFieldValid(form.valid?.basicInformation ?? {}, COUNTRY_FIELD),
3076
- errors: formUtils.getFieldErrors(
3077
- form.errors?.basicInformation ?? {},
3078
- validationErrors,
3079
- COUNTRY_FIELD
3080
- ),
3081
- labels: formUtils.getFieldLabels(COUNTRY_FIELD, {
3082
- country: "countryRegionOfEstablishment"
3083
- }),
3084
- readonly: formUtils.isReadOnly("country") || !isAllowedEditPrefilledCountry || Boolean(disableCountry),
3085
- handleChangeFor,
3086
- allowedCountries: isTopLevelEntity ? allowedCountries : void 0
3087
- }
3088
- ) }) }),
3089
- /* @__PURE__ */ jsxs("fieldset", { children: [
3090
- COUNTRY_OF_GOVERNING_LAW_POSSIBLE.includes(country) && showField(COUNTRY_OF_GOVERNING_LAW_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
3091
- CountryOfGoverningLawField,
3092
- {
3093
- data: formUtils.getFieldData(
3094
- form.data?.basicInformation ?? {},
3095
- COUNTRY_OF_GOVERNING_LAW_FIELD
3096
- ),
3097
- country,
3098
- valid: formUtils.getFieldValid(
3099
- form.valid?.basicInformation ?? {},
3100
- COUNTRY_OF_GOVERNING_LAW_FIELD
3101
- ),
3102
- errors: formUtils.getFieldErrors(
3103
- form.errors?.basicInformation ?? {},
3104
- validationErrors,
3105
- COUNTRY_OF_GOVERNING_LAW_FIELD
3106
- ),
3107
- labels: formUtils.getFieldLabels(COUNTRY_OF_GOVERNING_LAW_FIELD),
3108
- readonly: false,
3109
- allowedCountries: isTopLevelEntity ? allowedCountries : void 0,
3110
- handleChangeFor
3111
- }
3112
- ) }),
3113
- // fields shown here are abstracted by useLegalCompanyNameField
3114
- legalCompanyNameFields.map((field) => /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
3115
- Field,
3116
- {
3117
- name: field?.name ?? "",
3118
- label: field?.label,
3119
- helper: field?.helper,
3120
- errorMessage: field?.errorMessage,
3121
- isValid: Boolean(field?.isValid),
3122
- children: (childProps) => /* @__PURE__ */ jsx(
3123
- InputText,
3124
- {
3125
- ...childProps,
3126
- "aria-required": true,
3127
- "aria-invalid": !field?.isValid,
3128
- name: field?.name,
3129
- value: field?.value,
3130
- readonly: field?.readonly,
3131
- onInput: field ? field.onInput : () => {
3132
- },
3133
- transformInput: field?.transformInput,
3134
- transformMode: field?.transformMode,
3135
- onBlur: field?.onBlur,
3136
- onKeyDown: field?.onKeyDown
3137
- }
3138
- )
3139
- },
3140
- field?.name
3141
- ) }, field?.name)),
3142
- showField(TAX_INFORMATION_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
3143
- TaxInformationField,
3144
- {
3145
- data: formUtils.getFieldData(
3146
- form.data?.basicInformation ?? {},
3147
- TAX_INFORMATION_FIELD
3148
- ),
3149
- valid: formUtils.getFieldValid(
3150
- form.valid?.basicInformation ?? {},
3151
- TAX_INFORMATION_FIELD
3152
- ),
3153
- errors: formUtils.getFieldErrors(
3154
- form.errors?.basicInformation ?? {},
3155
- validationErrors,
3156
- TAX_INFORMATION_FIELD
3157
- ),
3158
- labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD, {
3159
- exemptedFromTax: "iDontHaveATaxId"
3160
- }),
3161
- mask: formUtils.getMask("taxInformation"),
3162
- placeholders: formUtils.getFieldPlaceholders(TAX_INFORMATION_FIELD),
3163
- guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
3164
- readonly: formUtils.isReadOnly("taxInformation"),
3165
- shouldValidate,
3166
- handleChangeFor,
3167
- canExempt: showField(["exemptedFromTax"]),
3168
- registrationNumber: form.data.additionalInformation?.registrationNumber,
3169
- country,
3170
- entityType: companyType,
3171
- defaultData: form.defaultData?.basicInformation?.taxInformation
3172
- }
3173
- ) }),
3174
- showField(STATE_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
3175
- StateField,
3176
- {
3177
- data: formUtils.getFieldData(form.data?.basicInformation ?? {}, STATE_FIELD),
3178
- valid: formUtils.getFieldValid(form.valid?.basicInformation ?? {}, STATE_FIELD),
3179
- errors: formUtils.getFieldErrors(
3180
- form.errors?.basicInformation ?? {},
3181
- validationErrors,
3182
- STATE_FIELD
3183
- ),
3184
- labels: formUtils.getFieldLabels(STATE_FIELD),
3185
- placeholders: formUtils.getFieldPlaceholders(STATE_FIELD),
3186
- readonly: formUtils.isReadOnly("stateOrProvince"),
3187
- handleChangeFor,
3188
- selectedCountry: country
3189
- }
3190
- ) }),
3191
- showField(BUSINESS_REGISTRATION_NUMBER_FIELD) && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-field-wrapper", children: /* @__PURE__ */ jsx(
3192
- BusinessRegistrationNumberField,
3193
- {
3194
- data: formUtils.getFieldData(
3195
- form.data?.basicInformation ?? {},
3196
- BUSINESS_REGISTRATION_NUMBER_FIELD
3197
- ),
3198
- valid: formUtils.getFieldValid(
3199
- form.valid?.basicInformation ?? {},
3200
- BUSINESS_REGISTRATION_NUMBER_FIELD
3201
- ),
3202
- errors: formUtils.getFieldErrors(
3203
- form.errors?.basicInformation ?? {},
3204
- validationErrors,
3205
- BUSINESS_REGISTRATION_NUMBER_FIELD
3206
- ),
3207
- labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD, {
3208
- exemptedFromRegistrationNumber: "iDontHaveARegistrationNumber"
3209
- }),
3210
- mask: formUtils.getMask("registrationNumber"),
3211
- guidanceText: formUtils.getFieldGuidanceText(BUSINESS_REGISTRATION_NUMBER_FIELD),
3212
- placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
3213
- helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
3214
- readonly: formUtils.isReadOnly("registrationNumber"),
3215
- optional: formUtils.isOptionalField("registrationNumber"),
3216
- shouldValidate,
3217
- handleChangeFor,
3218
- country,
3219
- canExempt: showField(["exemptedFromRegistrationNumber"]),
3220
- companyType
3221
- }
3222
- ) })
3223
- ] })
3224
- ] });
1224
+ const skipCompanyStructure = !!verifiedBusiness.value?.legalForm || isSettingEnabled(SettingNames.AllowLegalEntityTypeChange) && organizationTypesToSkipCompanyStructureForm.includes(
1225
+ legalEntityResponse?.organization?.type ?? ""
1226
+ ) && accountHolder !== "aTrust" && accountHolder !== "anUnincorporatedPartnership";
1227
+ const filteredForms = Object.values(forms).filter(({ formId }) => {
1228
+ if (formId === "businessSelection") {
1229
+ if (options?.hasNoSearchResults || isVerifiedSingleCompanySearchResult.value) return false;
1230
+ }
1231
+ if (formId === "companyStructure") {
1232
+ if (skipCompanyStructure) return false;
1233
+ }
1234
+ if (requiredFields || optionalFields) {
1235
+ return Boolean(requiredFields?.[formId]) || Boolean(optionalFields?.[formId]);
1236
+ }
1237
+ return true;
1238
+ });
1239
+ const requiredForms = options?.skipSummary ? filteredForms : [...filteredForms, summaryStep];
1240
+ return addValidityToForms(requiredForms, isValid, problems);
3225
1241
  }
3226
- function CompanyStructureMultiform({
3227
- id,
3228
- country,
3229
- validationErrors = {},
3230
- verificationErrors = {}
3231
- }) {
3232
- const { t } = useTranslation(["common", "business"]);
3233
- const { form } = useFormContext();
3234
- const { accountHolder } = useAccountHolder();
3235
- const { isSettingEnabled } = useSettingsContext();
3236
- const canChangeEntityType = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange);
3237
- const formUtils = createFormUtils(
3238
- { requiredFields: form.requiredFields?.companyStructure ?? [] },
3239
- t
3240
- );
3241
- const excludedTypes = [
3242
- CompanyTypesValues.INCORPORATED_PARTNERSHIP,
3243
- CompanyTypesValues.INCORPORATED_ASSOCIATION
3244
- ];
3245
- if (isBankAccountRequestedForOrganization.value) {
3246
- excludedTypes.push(CompanyTypesValues.GOVERNMENTAL_ORGANIZATION);
3247
- }
3248
- const companyTypeRadioOptions = canChangeEntityType && accountHolder !== "aTrust" && accountHolder !== "anUnincorporatedPartnership" ? companyTypeOptions.filter((companyType) => !excludedTypes.includes(companyType)) : companyTypeOptions;
3249
- const companyTypeExamples = useCompanyTypeExamples(country);
3250
- return /* @__PURE__ */ jsxs("form", { id, className: "adyen-kyc-company-structure", children: [
3251
- /* @__PURE__ */ jsx(
3252
- Header,
3253
- {
3254
- title: t(($) => $["companyStructureFormName"], { ns: "business" }),
3255
- description: t(($) => $["companyStructureFormDescription"], { ns: "business" })
3256
- }
3257
- ),
3258
- /* @__PURE__ */ jsx(
3259
- ErrorPanel,
3260
- {
3261
- id: "ariaErrorField",
3262
- verificationErrors,
3263
- validationErrors,
3264
- formUtils
3265
- }
1242
+ const isDocumentsRequired = (forms) => forms.some((form) => documentFormsIds.includes(form.formId));
1243
+ const formatBasicInformation = (data, datasetUtils, companyType, isCountryOfGoverningLawEnabled) => {
1244
+ const country = data?.country;
1245
+ const registrationNumberLabel = resolveFieldMetadata(
1246
+ registrationNumberDefaultFieldConfig[country],
1247
+ {
1248
+ companyType,
1249
+ registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data?.registrationNumber, country, companyType) : getCompanyRegistrationNumberOptions(country, companyType)?.[0]?.id
1250
+ },
1251
+ registrationNumberDefaultFieldMetadata
1252
+ ).label;
1253
+ const taxIdLabel = resolveFieldMetadata(
1254
+ taxInformationDefaultFieldConfig[country],
1255
+ {
1256
+ taxIdNumberType: countryToTaxInfoTypeMap[country] ?? void 0,
1257
+ // TODO use type selector
1258
+ companyType: void 0
1259
+ },
1260
+ taxInformationDefaultFieldMetadata
1261
+ ).label;
1262
+ const countryOfGoverningLaw = getCountryOfGoverningLaw(isCountryOfGoverningLawEnabled, data);
1263
+ return {
1264
+ ["legalCompanyName"]: data.legalCompanyName,
1265
+ country: datasetUtils.getCountryName(data.country),
1266
+ [getKeyForField("stateOrProvince", data.country)]: datasetUtils.getStateName(
1267
+ data.stateOrProvince,
1268
+ data.country
3266
1269
  ),
3267
- /* @__PURE__ */ jsx(
3268
- Field,
3269
- {
3270
- el: "fieldset",
3271
- name: "entityType",
3272
- errorMessage: formUtils.getErrorMessage(
3273
- "entityType",
3274
- form.errors?.companyStructure,
3275
- validationErrors
3276
- ),
3277
- isValid: form.valid?.companyStructure?.entityType,
3278
- children: (childProps) => /* @__PURE__ */ jsx(
3279
- EntityTypeRadioGroupCard,
3280
- {
3281
- ...childProps,
3282
- name: "entityType",
3283
- options: companyTypeRadioOptions,
3284
- optionId: (option) => companyTypeMetadata[option].id,
3285
- optionName: (option) => t(($) => $[companyTypeMetadata[option].name], { ns: "business" }),
3286
- optionDescription: (option) => t(($) => $[companyTypeMetadata[option].description], { ns: "business" }),
3287
- selected: form.data?.companyStructure?.entityType,
3288
- onSelect: form.handleChangeFor("entityType", "companyStructure"),
3289
- examples: companyTypeExamples,
3290
- "aria-required": true,
3291
- "aria-invalid": !form.valid?.companyStructure?.entityType
3292
- }
3293
- )
3294
- }
3295
- )
3296
- ] });
3297
- }
3298
- function BusinessDetailsMultiform({
3299
- taskType,
3300
- country,
3301
- activeForm,
3302
- shouldValidate,
3303
- problems = {},
3304
- handleNextClick,
3305
- handleBackClick,
3306
- setLoadingStatus,
3307
- isTopLevelEntity
3308
- }) {
3309
- const { t } = useTranslation(["common", "business"]);
3310
- const { form } = useFormContext();
3311
- const companyType = taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY ? CompanyTypesValues.SOLE_PROPRIETORSHIP : form.data.companyStructure?.entityType;
3312
- function handleChange(formName, fieldName, mode) {
3313
- return form.handleChangeFor(fieldName, formName, mode);
3314
- }
3315
- const renderActiveForm = (activeForm2) => {
3316
- switch (activeForm2.formId) {
1270
+ [taxIdLabel]: data.taxInformation?.find((taxId) => data.country === taxId.country)?.number,
1271
+ [registrationNumberLabel]: data.registrationNumber,
1272
+ countryOfGoverningLaw: datasetUtils.getCountryName(countryOfGoverningLaw)
1273
+ };
1274
+ };
1275
+ const formatAdditionalInformation = (data, country, companyType, t) => {
1276
+ const registrationNumberLabel = resolveFieldMetadata(
1277
+ registrationNumberDefaultFieldConfig[country],
1278
+ {
1279
+ companyType,
1280
+ registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data?.registrationNumber, country, companyType) : getCompanyRegistrationNumberOptions(country, companyType)?.[0]?.id
1281
+ },
1282
+ registrationNumberDefaultFieldMetadata
1283
+ ).label;
1284
+ const taxIdLabel = resolveFieldMetadata(
1285
+ taxInformationDefaultFieldConfig[country],
1286
+ {
1287
+ taxIdNumberType: countryToTaxInfoTypeMap[country] ?? void 0,
1288
+ // TODO use type selector
1289
+ companyType: void 0
1290
+ },
1291
+ taxInformationDefaultFieldMetadata
1292
+ ).label;
1293
+ return {
1294
+ ["businessStructure"]: data.legalFormLabel,
1295
+ ["doingBusinessAs"]: data.doingBusinessAs,
1296
+ ["industry"]: data.industryCodes?.[0].name,
1297
+ [registrationNumberLabel]: data.registrationNumber,
1298
+ [taxIdLabel]: data.isUen ? void 0 : data.taxInformation?.find((taxId) => country === taxId.country)?.number,
1299
+ ["vatNumber"]: data.vatNumber,
1300
+ ["vatAbsenceReason"]: data.vatAbsenceReason ? t(($) => $[data.vatAbsenceReason], { ns: "common" }) : void 0,
1301
+ ["dateOfIncorporation"]: data.dateOfIncorporation,
1302
+ ["stockExchangeMIC"]: data.stockExchangeMIC,
1303
+ ["stockISIN"]: data.stockISIN,
1304
+ ["stockTickerSymbol"]: data.stockTickerSymbol,
1305
+ ["eInvoicingCode"]: data.eInvoicingCode
1306
+ };
1307
+ };
1308
+ const formatDataForSummary = (data, forms, t, language, isExperimentEnabled) => {
1309
+ const datasetUtils = datasetUtilities(language);
1310
+ return entriesOf(data).reduce((summaryData, [form]) => {
1311
+ if (!form || !data[form]) return summaryData;
1312
+ const isCountryOfGoverningLawEnabled = isExperimentEnabled(
1313
+ "EnableCountryOfGoverningLawForUKCompanies"
1314
+ );
1315
+ switch (form) {
3317
1316
  case "basicInformation":
3318
- return /* @__PURE__ */ jsx(
3319
- BasicInformationMultiform,
3320
- {
3321
- id: activeForm2.formId,
3322
- country,
3323
- shouldValidate,
3324
- validationErrors: problems.validationErrors?.[activeForm2.formId],
3325
- verificationErrors: problems.verificationErrors?.[activeForm2.formId],
3326
- companyType,
3327
- isTopLevelEntity,
3328
- disableCountry: taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY
3329
- }
3330
- );
3331
- case "businessSelection":
3332
- return /* @__PURE__ */ jsx(
3333
- BusinessSelectionMultiform,
3334
- {
3335
- id: activeForm2.formId,
3336
- country,
3337
- shouldValidate,
3338
- validationErrors: problems.validationErrors?.[activeForm2.formId],
3339
- verificationErrors: problems.verificationErrors?.[activeForm2.formId],
3340
- handleNextClick,
3341
- handleBackClick,
3342
- setLoadingStatus
3343
- }
3344
- );
1317
+ return {
1318
+ ...summaryData,
1319
+ [form]: formatBasicInformation(
1320
+ data[form],
1321
+ datasetUtils,
1322
+ data.companyStructure?.entityType,
1323
+ isCountryOfGoverningLawEnabled
1324
+ )
1325
+ };
3345
1326
  case "companyStructure":
3346
- return /* @__PURE__ */ jsx(
3347
- CompanyStructureMultiform,
3348
- {
3349
- id: activeForm2.formId,
3350
- country,
3351
- shouldValidate,
3352
- validationErrors: problems.validationErrors?.[activeForm2.formId],
3353
- verificationErrors: problems.verificationErrors?.[activeForm2.formId]
1327
+ return {
1328
+ ...summaryData,
1329
+ [form]: {
1330
+ entityType: t(
1331
+ ($) => $[companyTypeMetadata[data["companyStructure"]?.entityType]?.name],
1332
+ {
1333
+ ns: "business"
1334
+ }
1335
+ )
3354
1336
  }
3355
- );
1337
+ };
3356
1338
  case "additionalInformation":
3357
- return /* @__PURE__ */ jsx(
3358
- AdditionalInformationMultiform,
3359
- {
3360
- id: activeForm2.formId,
3361
- country,
3362
- companyType,
3363
- shouldValidate,
3364
- validationErrors: problems.validationErrors?.[activeForm2.formId],
3365
- verificationErrors: problems.verificationErrors?.[activeForm2.formId]
3366
- }
3367
- );
3368
- case "companyTaxDocument":
3369
- return country === "US" ? /* @__PURE__ */ jsx(
3370
- TaxDocument,
3371
- {
3372
- id: activeForm2.formId,
3373
- country,
3374
- companyType,
3375
- shouldValidate,
3376
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3377
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {},
3378
- data: form.data.companyTaxDocument,
3379
- errors: form.errors.companyTaxDocument,
3380
- valid: form.valid.companyTaxDocument,
3381
- allFields: form.allFields?.companyTaxDocument,
3382
- requiredFields: form.requiredFields?.companyTaxDocument,
3383
- optionalFields: form.optionalFields?.companyTaxDocument,
3384
- trustedFields: form.trustedFields?.companyTaxDocument,
3385
- handleFieldChange: () => handleChange("companyTaxDocument", "taxDocument")
1339
+ return {
1340
+ ...summaryData,
1341
+ [form]: {
1342
+ hasInnerForms: true,
1343
+ additionalInformationFormName: formatAdditionalInformation(
1344
+ data[form],
1345
+ data.basicInformation?.country,
1346
+ data.companyStructure?.entityType,
1347
+ t
1348
+ ),
1349
+ registrationAddress: data.basicInformation?.country === CountryCodes.Japan ? mapJpAddressSummary(data[form].registrationAddress, datasetUtils) : mapAddressLabels(data[form].registrationAddress, datasetUtils),
1350
+ operationalAddress: data[form].operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME ? data.basicInformation?.country === CountryCodes.Japan ? mapJpAddressSummary(data[form].operationalAddress, datasetUtils) : mapAddressLabels(data[form].operationalAddress, datasetUtils) : void 0
3386
1351
  }
3387
- ) : /* @__PURE__ */ jsx(
3388
- MemoizedDocumentUpload,
3389
- {
3390
- id: activeForm2.formId,
3391
- country,
3392
- companyType,
3393
- shouldValidate,
3394
- heading: t(($) => $["companyTaxDocumentFormHeading"], { ns: "business" }),
3395
- description: t(($) => $["companyTaxDocumentFormDescription"], { ns: "business" }),
3396
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3397
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {},
3398
- data: form.data.companyTaxDocument,
3399
- errors: form.errors.companyTaxDocument,
3400
- valid: form.valid.companyTaxDocument,
3401
- allFields: form.allFields?.companyTaxDocument,
3402
- requiredFields: form.requiredFields?.companyTaxDocument,
3403
- optionalFields: form.optionalFields?.companyTaxDocument,
3404
- trustedFields: form.trustedFields?.companyTaxDocument,
3405
- handleFieldChange: () => handleChange("companyTaxDocument", "taxDocument"),
3406
- documentField: "taxDocument",
3407
- documentType: "vatDocument",
3408
- hidePageCount: true,
3409
- guidanceContent: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-u-margin-bottom-24", children: [
3410
- /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-upload-field__subtitle", children: [
3411
- " ",
3412
- t(($) => $["requirements"], { ns: "common" })
3413
- ] }),
3414
- /* @__PURE__ */ jsxs("ul", { children: [
3415
- /* @__PURE__ */ jsx("li", { children: t(($) => $["containsNameOfCompany"], { ns: "business" }) }),
3416
- /* @__PURE__ */ jsx("li", { children: t(($) => $["documentShowsTaxIdOfCompany"], { ns: "business" }) }),
3417
- /* @__PURE__ */ jsx("li", { children: t(($) => $["issuedByTheTaxAuthority"], { ns: "business" }) })
3418
- ] })
3419
- ] })
1352
+ };
1353
+ case "companyRegistrationDocument":
1354
+ if (!isDocumentsRequired(forms)) return summaryData;
1355
+ return {
1356
+ ...summaryData,
1357
+ [form]: {
1358
+ companyRegistrationDocument: {
1359
+ fileName: data[form].registrationDocument?.[0]?.name
1360
+ }
3420
1361
  }
3421
- );
3422
- case "companyRegistrationDocument":
3423
- return /* @__PURE__ */ jsx(
3424
- RegistrationDocument,
3425
- {
3426
- id: activeForm2.formId,
3427
- country,
3428
- companyType,
3429
- data: form.data.companyRegistrationDocument,
3430
- errors: form.errors.companyRegistrationDocument,
3431
- valid: form.valid.companyRegistrationDocument,
3432
- allFields: form.allFields?.companyRegistrationDocument,
3433
- requiredFields: form.requiredFields?.companyRegistrationDocument,
3434
- optionalFields: form.optionalFields?.companyRegistrationDocument,
3435
- trustedFields: form.trustedFields?.companyRegistrationDocument,
3436
- handleFieldChange: () => handleChange("companyRegistrationDocument", "registrationDocument"),
3437
- shouldValidate,
3438
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3439
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
1362
+ };
1363
+ case "companyTaxDocument":
1364
+ if (!isDocumentsRequired(forms)) return summaryData;
1365
+ return {
1366
+ ...summaryData,
1367
+ [form]: {
1368
+ companyTaxDocument: {
1369
+ fileName: data[form].taxDocument?.[0]?.name
1370
+ }
3440
1371
  }
3441
- );
1372
+ };
3442
1373
  case "companyProofOfDirectorDocument":
3443
- return /* @__PURE__ */ jsx(
3444
- ProofOfDirectorDocument,
3445
- {
3446
- id: activeForm2.formId,
3447
- country,
3448
- data: form.data?.companyProofOfDirectorDocument,
3449
- errors: form.errors.companyProofOfDirectorDocument,
3450
- valid: form.valid.companyProofOfDirectorDocument,
3451
- allFields: form.allFields?.companyProofOfDirectorDocument,
3452
- requiredFields: form.requiredFields?.companyProofOfDirectorDocument,
3453
- optionalFields: form.optionalFields?.companyProofOfDirectorDocument,
3454
- trustedFields: form.trustedFields?.companyProofOfDirectorDocument,
3455
- handleFieldChange: () => handleChange("companyProofOfDirectorDocument", "proofOfDirector"),
3456
- shouldValidate,
3457
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3458
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
1374
+ if (!isDocumentsRequired(forms)) return summaryData;
1375
+ return {
1376
+ ...summaryData,
1377
+ [form]: {
1378
+ companyProofOfDirectorDocument: {
1379
+ fileName: data[form].proofOfDirector?.[0]?.name
1380
+ }
3459
1381
  }
3460
- );
1382
+ };
3461
1383
  case "companyProofOfSignatoryDocument":
3462
- return /* @__PURE__ */ jsx(
3463
- ProofOfSignatoryDocument,
3464
- {
3465
- id: activeForm2.formId,
3466
- country,
3467
- data: form.data?.companyProofOfSignatoryDocument,
3468
- errors: form.errors.companyProofOfSignatoryDocument,
3469
- valid: form.valid.companyProofOfSignatoryDocument,
3470
- allFields: form.allFields?.companyProofOfSignatoryDocument,
3471
- requiredFields: form.requiredFields?.companyProofOfSignatoryDocument,
3472
- optionalFields: form.optionalFields?.companyProofOfSignatoryDocument,
3473
- trustedFields: form.trustedFields?.companyProofOfSignatoryDocument,
3474
- handleFieldChange: () => handleChange("companyProofOfSignatoryDocument", "proofOfSignatory"),
3475
- shouldValidate,
3476
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3477
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
1384
+ if (!isDocumentsRequired(forms)) return summaryData;
1385
+ return {
1386
+ ...summaryData,
1387
+ [form]: {
1388
+ companyProofOfSignatoryDocument: {
1389
+ fileName: data[form].proofOfSignatory?.[0]?.name
1390
+ }
3478
1391
  }
3479
- );
1392
+ };
3480
1393
  case "companyProofOfOwnershipDocument":
3481
- return /* @__PURE__ */ jsx(
3482
- ProofOfOwnershipDocument,
3483
- {
3484
- id: activeForm2.formId,
3485
- country,
3486
- data: form.data?.companyProofOfOwnershipDocument,
3487
- errors: form.errors.companyProofOfOwnershipDocument,
3488
- valid: form.valid.companyProofOfOwnershipDocument,
3489
- allFields: form.allFields?.companyProofOfOwnershipDocument,
3490
- requiredFields: form.requiredFields?.companyProofOfOwnershipDocument,
3491
- optionalFields: form.optionalFields?.companyProofOfOwnershipDocument,
3492
- trustedFields: form.trustedFields?.companyProofOfOwnershipDocument,
3493
- handleFieldChange: () => handleChange("companyProofOfOwnershipDocument", "proofOfOwnership"),
3494
- shouldValidate,
3495
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3496
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
3497
- }
3498
- );
3499
- case "companyConstitutionalDocument":
3500
- return /* @__PURE__ */ jsx(
3501
- MemoizedConstitutionalDocument,
3502
- {
3503
- id: activeForm2.formId,
3504
- legalEntityType: LegalEntityTypes.SOLE_PROPRIETORSHIP,
3505
- country,
3506
- data: form.data?.companyConstitutionalDocument,
3507
- errors: form.errors.companyConstitutionalDocument,
3508
- valid: form.valid.companyConstitutionalDocument,
3509
- allFields: form.allFields?.companyConstitutionalDocument,
3510
- requiredFields: form.requiredFields?.companyConstitutionalDocument,
3511
- optionalFields: form.optionalFields?.companyConstitutionalDocument,
3512
- trustedFields: form.trustedFields?.companyConstitutionalDocument,
3513
- handleFieldChange: () => handleChange("companyConstitutionalDocument", "constitutionalDocument"),
3514
- shouldValidate,
3515
- fieldValidationErrors: problems.validationErrors?.[activeForm2.formId] ?? {},
3516
- formVerificationErrors: problems.verificationErrors?.[activeForm2.formId] ?? {}
1394
+ if (!isDocumentsRequired(forms)) return summaryData;
1395
+ return {
1396
+ ...summaryData,
1397
+ [form]: {
1398
+ companyProofOfOwnershipDocument: {
1399
+ fileName: data[form].proofOfOwnership?.map((doc) => doc.name).join("\n")
1400
+ }
3517
1401
  }
1402
+ };
1403
+ case "companyFinancialInformation": {
1404
+ const isIncorporationDateDependencyEnabled = isExperimentEnabled(
1405
+ "EnableIncorporationDateBasedFinancialValidationForHO"
3518
1406
  );
3519
- case "companyFinancialInformation":
3520
- return /* @__PURE__ */ jsx(
3521
- FinancialInformation,
1407
+ return {
1408
+ ...summaryData,
1409
+ [form]: formatFinancialInformationSummary(
1410
+ data[form],
1411
+ language,
1412
+ data?.basicInformation?.country,
1413
+ isIncorporationDateDependencyEnabled ? data?.additionalInformation?.dateOfIncorporation : void 0
1414
+ )
1415
+ };
1416
+ }
1417
+ default:
1418
+ return summaryData;
1419
+ }
1420
+ }, {});
1421
+ };
1422
+ async function submitDocuments({
1423
+ data,
1424
+ legalEntity,
1425
+ forms,
1426
+ documentUtils,
1427
+ userEvents
1428
+ }) {
1429
+ if (!isDocumentsRequired(forms)) return;
1430
+ const logger = createLogger();
1431
+ const formattedDocument = await mapBusinessDetailsDocumentToApiDocument(data, legalEntity.id);
1432
+ try {
1433
+ if (formattedDocument) {
1434
+ await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
1435
+ formattedDocument.forEach((doc) => {
1436
+ userEvents?.addTaskEvent("Success", {
1437
+ actionType: "upload",
1438
+ documentType: doc.type,
1439
+ fileExtention: doc.attachments?.map((item) => getFileExtention(item.pageName)).filter((item) => item !== void 0) ?? []
1440
+ });
1441
+ });
1442
+ }
1443
+ } catch (err) {
1444
+ logger.error(err);
1445
+ userEvents.addTaskEvent("Encountered error", {
1446
+ actionType: "upload",
1447
+ returnType: err.errorCode,
1448
+ returnValue: err.title ?? err.message
1449
+ });
1450
+ }
1451
+ }
1452
+ async function submit({
1453
+ data,
1454
+ legalEntityResponse,
1455
+ associatedLegalArrangement,
1456
+ nestedLegalEntity,
1457
+ nestedLegalEntityDetails,
1458
+ problems,
1459
+ taskType,
1460
+ accountHolder,
1461
+ forms,
1462
+ documentUtils,
1463
+ t,
1464
+ showToast,
1465
+ setLoadingStatus,
1466
+ setProblems,
1467
+ handleUpdateLegalEntity,
1468
+ createLegalEntity,
1469
+ onExternalSubmit,
1470
+ isExperimentEnabled,
1471
+ userEvents,
1472
+ efpBusinessLines,
1473
+ createBusinessLine,
1474
+ updateBusinessLine
1475
+ }) {
1476
+ const logger = createLogger();
1477
+ setLoadingStatus("loading");
1478
+ let trackingPayload = {
1479
+ actionType: "submit",
1480
+ companyStructure: data.companyStructure?.entityType,
1481
+ countryOfRegistration: data.basicInformation?.country,
1482
+ legalEntityName: accountHolder === "theCompanyIWorkFor" ? data.basicInformation?.legalCompanyName : void 0,
1483
+ // Only send legalCompanyName for organizations
1484
+ usedAdditionalAddress: data.additionalInformation?.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME
1485
+ };
1486
+ const entityToUpdate = (() => {
1487
+ switch (taskType) {
1488
+ case TaskTypes.SOLE_PROPRIETOR_COMPANY:
1489
+ return associatedLegalArrangement;
1490
+ case TaskTypes.TRUST_MEMBER_COMPANY:
1491
+ case TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY:
1492
+ return nestedLegalEntity;
1493
+ case TaskTypes.BUSINESS_DETAILS:
1494
+ default:
1495
+ return legalEntityResponse;
1496
+ }
1497
+ })();
1498
+ const handleSubmitLegalEntity = async (legalEntity) => {
1499
+ if (taskType === TaskTypes.TRUST_MEMBER_COMPANY && !nestedLegalEntity?.id || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY && !nestedLegalEntity?.id || taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && !associatedLegalArrangement?.id) {
1500
+ return await createLegalEntity(legalEntity);
1501
+ } else {
1502
+ return handleUpdateLegalEntity({
1503
+ ...drop("type").from(legalEntity),
1504
+ id: entityToUpdate?.id ?? legalEntityResponse.id
1505
+ });
1506
+ }
1507
+ };
1508
+ const associateLegalEntityWithParent = async ({
1509
+ legalEntity,
1510
+ associatedLegalArrangement: associatedLegalArrangement2,
1511
+ nestedLegalEntityDetails: nestedLegalEntityDetails2
1512
+ }) => {
1513
+ if (nestedLegalEntityDetails2 && associatedLegalArrangement2) {
1514
+ const existingEntityAssociations = getOwnEntityAssociations(associatedLegalArrangement2);
1515
+ const existingRoles = existingEntityAssociations.filter((ea) => ea.legalEntityId === associatedLegalArrangement2.id).map(({ type }) => type);
1516
+ const newRoles = nestedLegalEntityDetails2?.roles ?? [];
1517
+ const rolesChanged = !doArraysMatch(existingRoles, newRoles);
1518
+ if (rolesChanged) {
1519
+ const updatedAssociations = {
1520
+ entityAssociations: [
1521
+ ...newRoles.map((role) => ({
1522
+ type: role,
1523
+ legalEntityId: legalEntity.id
1524
+ })) || [],
1525
+ ...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
1526
+ ]
1527
+ };
1528
+ await handleUpdateLegalEntity({
1529
+ ...updatedAssociations,
1530
+ id: associatedLegalArrangement2.id
1531
+ });
1532
+ }
1533
+ return;
1534
+ } else {
1535
+ const updatedAssociations = {
1536
+ entityAssociations: [
3522
1537
  {
3523
- multiForm: form,
3524
- id: activeForm2.formId,
3525
- country,
3526
- data: form.data?.companyFinancialInformation,
3527
- allFields: form.allFields?.companyFinancialInformation,
3528
- requiredFields: form.requiredFields?.companyFinancialInformation,
3529
- optionalFields: form.optionalFields?.companyFinancialInformation,
3530
- trustedFields: form.trustedFields?.companyFinancialInformation,
3531
- shouldValidate
1538
+ type: LegalEntityTypes.SOLE_PROPRIETORSHIP,
1539
+ legalEntityId: legalEntity.id
3532
1540
  }
3533
- );
3534
- default:
3535
- return null;
1541
+ ]
1542
+ };
1543
+ await handleUpdateLegalEntity({ ...updatedAssociations, id: legalEntityResponse.id });
3536
1544
  }
3537
1545
  };
3538
- return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-business-details", children: /* @__PURE__ */ jsx("div", { className: "adyen-kyc-form-wrapper", children: renderActiveForm(activeForm) }) });
3539
- }
3540
- function buildRequiredForms({
3541
- config: {
3542
- forms,
3543
- requiredFields,
3544
- optionalFields,
3545
- isValid,
3546
- problems,
3547
- isSettingEnabled,
3548
- accountHolder,
3549
- legalEntityResponse
3550
- },
3551
- options
3552
- }) {
3553
- const skipCompanyStructure = !!verifiedBusiness.value?.legalForm || isSettingEnabled(SettingNames.AllowLegalEntityTypeChange) && organizationTypesToSkipCompanyStructureForm.includes(
3554
- legalEntityResponse?.organization?.type ?? ""
3555
- ) && accountHolder !== "aTrust" && accountHolder !== "anUnincorporatedPartnership";
3556
- const filteredForms = Object.values(forms).filter(({ formId }) => {
3557
- if (formId === "businessSelection") {
3558
- if (options?.hasNoSearchResults || isVerifiedSingleCompanySearchResult.value) return false;
1546
+ const savedLegalEntityData = legalEntityResponse ? mapLegalEntityToBusinessDetailsSchema(legalEntityResponse, void 0) : null;
1547
+ const filteredData = savedLegalEntityData ? setRemovedFieldsOnSchemaToDeletedValue(data, savedLegalEntityData) : data;
1548
+ if (filteredData?.additionalInformation && !filteredData?.additionalInformation?.taxInformation) {
1549
+ filteredData.additionalInformation.taxInformation = void 0;
1550
+ }
1551
+ const isCountryOfGoverningLawEnabled = isExperimentEnabled(
1552
+ "EnableCountryOfGoverningLawForUKCompanies"
1553
+ );
1554
+ const countryOfGoverningLaw = getCountryOfGoverningLaw(
1555
+ isCountryOfGoverningLawEnabled,
1556
+ filteredData?.basicInformation
1557
+ );
1558
+ if (filteredData?.basicInformation) {
1559
+ if (countryOfGoverningLaw) {
1560
+ filteredData.basicInformation.countryOfGoverningLaw = countryOfGoverningLaw;
1561
+ } else {
1562
+ delete filteredData.basicInformation.countryOfGoverningLaw;
3559
1563
  }
3560
- if (formId === "companyStructure") {
3561
- if (skipCompanyStructure) return false;
1564
+ }
1565
+ const primaryIndustryCode = data.additionalInformation?.industryCodes && data.additionalInformation.industryCodes[0].id;
1566
+ if (createBusinessLine && updateBusinessLine && primaryIndustryCode) {
1567
+ const bankingBusinessLines = [];
1568
+ const issuingBusinessLines = [];
1569
+ if (efpBusinessLines) {
1570
+ for (const bl of efpBusinessLines) {
1571
+ if (bl.service === "banking") bankingBusinessLines.push(bl);
1572
+ else issuingBusinessLines.push(bl);
1573
+ }
3562
1574
  }
3563
- if (requiredFields || optionalFields) {
3564
- return Boolean(requiredFields?.[formId]) || Boolean(optionalFields?.[formId]);
1575
+ const promises = [];
1576
+ const operations = [];
1577
+ const updateOrCreateBusinessLinesIfNeeded = (businessLines, requestedCapability, service) => {
1578
+ if (businessLines.length) {
1579
+ for (const bl of businessLines) {
1580
+ if (bl.industryCode === primaryIndustryCode) continue;
1581
+ const payload = {
1582
+ id: bl.id,
1583
+ legalEntityId: legalEntityResponse.id,
1584
+ industryCode: primaryIndustryCode,
1585
+ service
1586
+ };
1587
+ promises.push(updateBusinessLine(payload));
1588
+ operations.push(payload);
1589
+ }
1590
+ } else if (requestedCapability) {
1591
+ const payload = {
1592
+ legalEntityId: legalEntityResponse.id,
1593
+ industryCode: primaryIndustryCode,
1594
+ service
1595
+ };
1596
+ promises.push(createBusinessLine(payload));
1597
+ operations.push(payload);
1598
+ }
1599
+ };
1600
+ updateOrCreateBusinessLinesIfNeeded(
1601
+ bankingBusinessLines,
1602
+ requestingBanking(legalEntityResponse),
1603
+ "banking"
1604
+ );
1605
+ updateOrCreateBusinessLinesIfNeeded(
1606
+ issuingBusinessLines,
1607
+ requestingIssuing(legalEntityResponse),
1608
+ "issuing"
1609
+ );
1610
+ let hadRejection = false;
1611
+ (await Promise.allSettled(promises)).forEach((result, idx) => {
1612
+ if (result.status !== "rejected") return;
1613
+ const op = operations[idx];
1614
+ logger.log(
1615
+ `Failed to ${op.id ? "update" : "create"} business line with payload: ${JSON.stringify(op)}`
1616
+ );
1617
+ hadRejection = true;
1618
+ });
1619
+ const eventPayload = {
1620
+ actionType: trackingPayload.actionType,
1621
+ legalEntityName: trackingPayload.legalEntityName
1622
+ };
1623
+ if (!hadRejection) {
1624
+ userEvents?.addTaskEvent("Success", eventPayload);
1625
+ } else {
1626
+ userEvents?.addTaskEvent("Encountered error", {
1627
+ ...eventPayload,
1628
+ returnType: "businessLines",
1629
+ returnValue: "couldNotCreateOrUpdateBusinessLine"
1630
+ });
1631
+ showToast({
1632
+ label: t(($) => $["failedToUpdateEfpBusinessLines"], { ns: "business" }),
1633
+ variant: "error"
1634
+ });
1635
+ return setLoadingStatus("success");
3565
1636
  }
3566
- return true;
3567
- });
3568
- const requiredForms = options?.skipSummary ? filteredForms : [...filteredForms, summaryStep];
3569
- return addValidityToForms(requiredForms, isValid, problems);
1637
+ }
1638
+ try {
1639
+ const mappedLegalEntity = {
1640
+ ...mapBusinessDetailsSchemaToLegalEntity(filteredData, accountHolder, isExperimentEnabled),
1641
+ entityAssociations: filterOutUnwantedAssociationsIfRootLE(
1642
+ taskType,
1643
+ entityToUpdate,
1644
+ accountHolder
1645
+ )
1646
+ };
1647
+ if (mappedLegalEntity.type === LegalEntityTypes.ORGANIZATION && legalEntityResponse.organization?.countryOfGoverningLaw !== mappedLegalEntity.organization?.countryOfGoverningLaw && legalEntityResponse.organization?.support) {
1648
+ mappedLegalEntity.organization.support = determineCustomerSupport(
1649
+ legalEntityResponse.organization.support,
1650
+ mappedLegalEntity.organization?.countryOfGoverningLaw
1651
+ );
1652
+ }
1653
+ const legalEntity = await handleSubmitLegalEntity(mappedLegalEntity);
1654
+ if (taskType === TaskTypes.TRUST_MEMBER_COMPANY || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY || taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && !associatedLegalArrangement?.id) {
1655
+ await associateLegalEntityWithParent({
1656
+ legalEntity,
1657
+ associatedLegalArrangement,
1658
+ nestedLegalEntityDetails
1659
+ });
1660
+ }
1661
+ await submitDocuments({
1662
+ data,
1663
+ legalEntity,
1664
+ documentUtils,
1665
+ forms,
1666
+ userEvents
1667
+ });
1668
+ userEvents?.addTaskEvent("Success", trackingPayload);
1669
+ showToast({
1670
+ label: t(($) => $["successfullyUpdatedDetails"], { ns: "common" }),
1671
+ variant: "success"
1672
+ });
1673
+ onExternalSubmit?.(data);
1674
+ } catch (err) {
1675
+ if (isValidationError(err)) {
1676
+ const getErrors = processValidationErrors(err, TaskTypes.BUSINESS_DETAILS);
1677
+ if (getErrors && !Object.keys(getErrors).length) {
1678
+ showToast({
1679
+ label: t(($) => $["failedToUpdateDetails"], { ns: "common" }),
1680
+ variant: "error"
1681
+ });
1682
+ const unmappedErrorNames = err.invalidFields?.map((field) => field.name).filter(Boolean) ?? [];
1683
+ if (unmappedErrorNames.length) {
1684
+ trackingPayload = {
1685
+ ...trackingPayload,
1686
+ additionalData: { unmappedErrorNames }
1687
+ };
1688
+ }
1689
+ } else {
1690
+ setProblems({
1691
+ ...problems,
1692
+ validationErrors: getErrors
1693
+ });
1694
+ }
1695
+ }
1696
+ if (isMaintenanceModeError(err)) {
1697
+ showToast({
1698
+ label: t(($) => $["maintenanceModeMessage"], { ns: "common" }),
1699
+ variant: "error",
1700
+ duration: "indefinite"
1701
+ });
1702
+ }
1703
+ if (!isValidationError(err) && !isMaintenanceModeError(err)) {
1704
+ showToast({
1705
+ label: t(($) => $["failedToUpdateDetails"], { ns: "common" }),
1706
+ variant: "error"
1707
+ });
1708
+ }
1709
+ logger.error(err);
1710
+ userEvents?.addTaskEvent("Encountered error", {
1711
+ ...trackingPayload,
1712
+ returnType: err?.errorCode,
1713
+ returnValue: err?.title || "backend"
1714
+ });
1715
+ } finally {
1716
+ setLoadingStatus("success");
1717
+ }
3570
1718
  }
1719
+ const getCountryOfGoverningLaw = (isCountryOfGoverningLawEnabled, basicData) => {
1720
+ if (!isCountryOfGoverningLawEnabled || basicData?.country !== CountryCodes.UnitedKingdom) {
1721
+ return void 0;
1722
+ }
1723
+ if (isCountryOfGoverningLawEnabled && basicData?.country === CountryCodes.UnitedKingdom && !basicData?.countryOfGoverningLaw) {
1724
+ return CountryCodes.UnitedKingdom;
1725
+ }
1726
+ return basicData?.countryOfGoverningLaw;
1727
+ };
1728
+ const determineCustomerSupport = (customerSupport, country) => {
1729
+ switch (country) {
1730
+ case CountryCodes.Japan:
1731
+ return unsetCustomerSupportNumber(customerSupport);
1732
+ default:
1733
+ return customerSupport;
1734
+ }
1735
+ };
1736
+ const unsetCustomerSupportNumber = (customerSupport) => {
1737
+ return customerSupport ? {
1738
+ email: customerSupport.email,
1739
+ phone: { number: "", type: "mobile" }
1740
+ } : void 0;
1741
+ };
1742
+ const CountryFieldValidation = () => ({
1743
+ country: {
1744
+ modes: ["blur"],
1745
+ validate: (country) => !isEmpty(country),
1746
+ errorMessage: "fieldIsRequired"
1747
+ }
1748
+ });
1749
+ const CountryOfGoverningLawFieldValidation = () => ({
1750
+ countryOfGoverningLaw: {
1751
+ modes: ["blur"],
1752
+ validate: (countryOfGoverningLaw) => !isEmpty(countryOfGoverningLaw),
1753
+ errorMessage: "fieldIsRequired"
1754
+ }
1755
+ });
3571
1756
  function basicInformationValidators({
3572
1757
  country,
3573
1758
  taxIdNumberType,
@@ -3662,7 +1847,7 @@ function additionalInformationValidators({
3662
1847
  stockTickerSymbol: stockTickerSymbolFieldMetadata.validators
3663
1848
  };
3664
1849
  }
3665
- function BusinessDetailsMultiformDropin({
1850
+ function BusinessDetailsDropin({
3666
1851
  taskType = TaskTypes.BUSINESS_DETAILS,
3667
1852
  country: propCountry,
3668
1853
  problems: propProblems,
@@ -3736,8 +1921,7 @@ function BusinessDetailsMultiformDropin({
3736
1921
  const defaultData = useMemo(() => {
3737
1922
  const mapped = mapLegalEntityToBusinessDetailsSchema(
3738
1923
  !isAssociationTaskType ? legalEntityResponse : isSoleProp ? associatedLegalArrangement ?? legalEntityResponse : nestedLegalEntity,
3739
- isSoleProp ? legalEntityResponse : void 0,
3740
- isExperimentEnabled
1924
+ isSoleProp ? legalEntityResponse : void 0
3741
1925
  );
3742
1926
  const initialEfpBusinessLineData = isSettingEnabled("allowBusinessLines") && efpBusinessLines && efpBusinessLines.length > 0 ? {
3743
1927
  additionalInformation: {
@@ -3761,7 +1945,6 @@ function BusinessDetailsMultiformDropin({
3761
1945
  isSoleProp,
3762
1946
  associatedLegalArrangement,
3763
1947
  nestedLegalEntity,
3764
- isExperimentEnabled,
3765
1948
  documents,
3766
1949
  efpBusinessLines,
3767
1950
  isSettingEnabled
@@ -4026,9 +2209,6 @@ function BusinessDetailsMultiformDropin({
4026
2209
  tin: multiForm.data?.basicInformation?.taxInformation?.find((taxId) => taxId.country === country)?.number ?? ""
4027
2210
  };
4028
2211
  useVerifyTin(verifyTinQueryInput, { enabled: false });
4029
- useCompanySelection(companySelectionInput, {
4030
- enabled: false
4031
- });
4032
2212
  const attemptBusinessSearch = async () => {
4033
2213
  if (customRules.countryUsingCompanySearch() !== "REQUIRED") {
4034
2214
  const currentForms = updateForms({ searchResults: [] });
@@ -4056,12 +2236,11 @@ function BusinessDetailsMultiformDropin({
4056
2236
  multiForm.data?.basicInformation?.legalCompanyName ?? "",
4057
2237
  searchResponse.results[0].name
4058
2238
  )) {
4059
- const companySelectionResponse = await queryClient.fetchQuery({
4060
- queryKey: [
4061
- "companySelection",
4062
- { ...companySelectionInput, company: searchResponse.results[0] }
4063
- ]
4064
- });
2239
+ const companySelectionResponse = await handleCompanySelection(
2240
+ rootLegalEntityId.value,
2241
+ baseUrl.value,
2242
+ { ...companySelectionInput, company: searchResponse.results[0] }
2243
+ );
4065
2244
  if (handleTinResponse(!!companySelectionResponse.tinMatched)) {
4066
2245
  verifiedBusiness.value = companySelectionResponse;
4067
2246
  isVerifiedSingleCompanySearchResult.value = true;
@@ -4176,6 +2355,5 @@ function BusinessDetailsMultiformDropin({
4176
2355
  ) });
4177
2356
  }
4178
2357
  export {
4179
- BusinessDetailsMultiformDropin as B,
4180
- BusinessDetailsDropin as a
2358
+ BusinessDetailsDropin as B
4181
2359
  };