diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 40b2fa1e6dca..8502564b1dff 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -620,6 +620,7 @@ const CONST = { PREFIX: 'beneficialOwner', FIRST_NAME: 'firstName', LAST_NAME: 'lastName', + NATIONALITY: 'nationality', OWNERSHIP_PERCENTAGE: 'ownershipPercentage', DOB: 'dob', SSN_LAST_4: 'ssnLast4', @@ -627,7 +628,7 @@ const CONST = { CITY: 'city', STATE: 'state', ZIP_CODE: 'zipCode', - COUNTRY: 'nationality', + COUNTRY: 'country', PROOF_OF_OWNERSHIP: 'proofOfBeneficialOwner', COPY_OF_ID: 'copyOfIDForBeneficialOwner', ADDRESS_PROOF: 'addressProofForBeneficialOwner', diff --git a/src/languages/de.ts b/src/languages/de.ts index 84447ba0e7d8..83ef59ae80e1 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -3307,6 +3307,9 @@ ${ whatsYourAddress: 'Wie lautet Ihre Adresse?', whatAreTheLast: 'Was sind die letzten 4 Ziffern der Sozialversicherungsnummer des Eigentümers?', whatsYourLast: 'Was sind die letzten 4 Ziffern Ihrer Sozialversicherungsnummer?', + whatsYourNationality: 'Was ist Ihr Staatsangehörigkeitsland?', + whatsTheOwnersNationality: 'Was ist das Staatsangehörigkeitsland des Eigentümers?', + countryOfCitizenship: 'Staatsangehörigkeitsland', dontWorry: 'Keine Sorge, wir führen keine persönlichen Bonitätsprüfungen durch!', last4: 'Letzte 4 der SSN', whyDoWeAsk: 'Warum fragen wir danach?', diff --git a/src/languages/en.ts b/src/languages/en.ts index d09026e9b213..3976922b8284 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3400,6 +3400,9 @@ const translations = { whatsYourAddress: "What's your address?", whatAreTheLast: "What are the last 4 digits of the owner's Social Security Number?", whatsYourLast: 'What are the last 4 digits of your Social Security Number?', + whatsYourNationality: 'What is your country of citizenship?', + whatsTheOwnersNationality: "What's the owner's country of citizenship?", + countryOfCitizenship: 'Country of citizenship', dontWorry: "Don't worry, we don't do any personal credit checks!", last4: 'Last 4 of SSN', whyDoWeAsk: 'Why do we ask for this?', diff --git a/src/languages/es.ts b/src/languages/es.ts index 148560e4093e..2f3b0e334bdb 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3052,6 +3052,9 @@ ${amount} para ${merchant} - ${date}`, whatsYourAddress: '¿Cuál es su dirección?', whatAreTheLast: '¿Cuáles son los últimos 4 dígitos del número de seguro social del propietario?', whatsYourLast: '¿Cuáles son los últimos 4 dígitos de su número de seguro social?', + whatsYourNationality: '¿Cuál es tu país de ciudadanía?', + whatsTheOwnersNationality: '¿Cuál es el país de ciudadanía del propietario?', + countryOfCitizenship: 'País de ciudadanía', dontWorry: 'No se preocupe, ¡no realizamos ninguna verificación de crédito personal!', last4: 'Últimos 4 del SSN', whyDoWeAsk: '¿Por qué solicitamos esto?', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index fbb0da052c97..deeab0786952 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -3310,6 +3310,9 @@ ${ whatsYourAddress: 'Quelle est votre adresse ?', whatAreTheLast: 'Quels sont les 4 derniers chiffres du numéro de sécurité sociale du propriétaire ?', whatsYourLast: 'Quels sont les 4 derniers chiffres de votre numéro de sécurité sociale ?', + whatsYourNationality: 'Quel est votre pays de citoyenneté ?', + whatsTheOwnersNationality: 'Quel est le pays de citoyenneté du propriétaire ?', + countryOfCitizenship: 'Pays de citoyenneté', dontWorry: 'Ne vous inquiétez pas, nous ne faisons aucune vérification de crédit personnel !', last4: 'Derniers 4 du SSN', whyDoWeAsk: 'Pourquoi demandons-nous cela ?', diff --git a/src/languages/it.ts b/src/languages/it.ts index a7d602ce3c3b..87d11e1a2f54 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -3292,6 +3292,9 @@ ${ whatsYourAddress: 'Qual è il tuo indirizzo?', whatAreTheLast: 'Quali sono le ultime 4 cifre del numero di previdenza sociale del proprietario?', whatsYourLast: 'Quali sono le ultime 4 cifre del tuo numero di previdenza sociale?', + whatsYourNationality: 'Qual è il tuo paese di cittadinanza?', + whatsTheOwnersNationality: 'Qual è il paese di cittadinanza del proprietario?', + countryOfCitizenship: 'Paese di cittadinanza', dontWorry: 'Non preoccuparti, non facciamo alcun controllo del credito personale!', last4: 'Ultime 4 cifre del SSN', whyDoWeAsk: 'Perché lo chiediamo?', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 1bf15e057fb5..2d2497fc0e0c 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -3278,6 +3278,9 @@ ${ whatsYourAddress: '住所は何ですか?', whatAreTheLast: '所有者の社会保障番号の下4桁は何ですか?', whatsYourLast: 'あなたの社会保障番号の最後の4桁は何ですか?', + whatsYourNationality: 'あなたの市民権の国はどこですか?', + whatsTheOwnersNationality: '所有者の市民権の国はどこですか?', + countryOfCitizenship: '市民権の国', dontWorry: 'ご安心ください、私たちは個人の信用調査を行いません!', last4: 'SSNの下4桁', whyDoWeAsk: 'なぜこれを尋ねるのですか?', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index cfc6553d2bdb..b1652b922fe4 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -3292,6 +3292,9 @@ ${ whatsYourAddress: 'Wat is jouw adres?', whatAreTheLast: 'Wat zijn de laatste 4 cijfers van het burgerservicenummer van de eigenaar?', whatsYourLast: 'Wat zijn de laatste 4 cijfers van uw burgerservicenummer?', + whatsYourNationality: 'Wat is uw nationaliteitsland?', + whatsTheOwnersNationality: 'Wat is het nationaliteitsland van de eigenaar?', + countryOfCitizenship: 'Nationaliteitsland', dontWorry: 'Maak je geen zorgen, we doen geen persoonlijke kredietcontroles!', last4: 'Laatste 4 van SSN', whyDoWeAsk: 'Waarom vragen we hierom?', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index a337c49511f9..db77ea211391 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -3286,6 +3286,9 @@ ${ whatsYourAddress: 'Jaki jest Twój adres?', whatAreTheLast: 'Jakie są ostatnie 4 cyfry numeru Social Security właściciela?', whatsYourLast: 'Jakie są ostatnie 4 cyfry Twojego numeru Social Security?', + whatsYourNationality: 'Jaki jest Twój kraj obywatelstwa?', + whatsTheOwnersNationality: 'Jaki jest kraj obywatelstwa właściciela?', + countryOfCitizenship: 'Kraj obywatelstwa', dontWorry: 'Nie martw się, nie przeprowadzamy żadnych osobistych sprawdzeń kredytowych!', last4: 'Ostatnie 4 cyfry numeru SSN', whyDoWeAsk: 'Dlaczego o to prosimy?', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 57baf60d9848..4af441404230 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -3288,6 +3288,9 @@ ${ whatsYourAddress: 'Qual é o seu endereço?', whatAreTheLast: 'Quais são os últimos 4 dígitos do Número de Seguro Social do proprietário?', whatsYourLast: 'Quais são os últimos 4 dígitos do seu Número de Seguro Social?', + whatsYourNationality: 'Qual é o seu país de cidadania?', + whatsTheOwnersNationality: 'Qual é o país de cidadania do proprietário?', + countryOfCitizenship: 'País de cidadania', dontWorry: 'Não se preocupe, não fazemos nenhuma verificação de crédito pessoal!', last4: 'Últimos 4 do SSN', whyDoWeAsk: 'Por que pedimos isso?', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 0f2e314c5161..bcc0bcbc3eb7 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -3244,6 +3244,9 @@ ${ whatsYourAddress: '你的地址是什么?', whatAreTheLast: '业主社会安全号码的最后四位数字是什么?', whatsYourLast: '您的社会安全号码的最后四位数字是什么?', + whatsYourNationality: '您的公民身份所属国家是?', + whatsTheOwnersNationality: '业主的公民身份所属国家是?', + countryOfCitizenship: '公民身份国家', dontWorry: '别担心,我们不会进行任何个人信用检查!', last4: 'SSN的后四位', whyDoWeAsk: '我们为什么要求这个?', diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Address.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Address.tsx index 484f8ba1e9ad..14ad08dd1bee 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Address.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Address.tsx @@ -12,14 +12,17 @@ import SafeString from '@src/utils/SafeString'; type NameProps = SubStepProps & {isUserEnteringHisOwnData: boolean; ownerBeingModifiedID: string}; -const {STREET, CITY, STATE, ZIP_CODE, COUNTRY, PREFIX} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; +const {STREET, CITY, STATE, ZIP_CODE, COUNTRY, NATIONALITY, PREFIX} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; function Address({onNext, isEditing, onMove, isUserEnteringHisOwnData, ownerBeingModifiedID}: NameProps) { const {translate} = useLocalize(); - const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: true}); const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; + const nationalityInputKey = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const; + const nationality = reimbursementAccountDraft?.[nationalityInputKey] ?? ''; const countryInputKey = `${PREFIX}_${ownerBeingModifiedID}_${COUNTRY}` as const; + const inputKeys = { street: `${PREFIX}_${ownerBeingModifiedID}_${STREET}`, city: `${PREFIX}_${ownerBeingModifiedID}_${CITY}`, @@ -62,15 +65,15 @@ function Address({onNext, isEditing, onMove, isUserEnteringHisOwnData, ownerBein }; const handleNextStep = () => { - // owner is US based we need to gather last four digits of his SSN - if (reimbursementAccountDraft?.[inputKeys.country] === CONST.COUNTRY.US) { + // owner is US citizen so we need to gather last four digits of his SSN + if (nationality === CONST.COUNTRY.US) { onNext(); - // currency is set to GBP and owner is UK based, so we skip SSN and Documents step - } else if (countryStepCountryValue === CONST.COUNTRY.GB && reimbursementAccountDraft?.[inputKeys.country] === CONST.COUNTRY.GB) { - onMove(6, false); - // owner is not US based so we skip SSN step + // currency is set to GBP and owner is UK citizen, so we skip SSN and Documents step + } else if (countryStepCountryValue === CONST.COUNTRY.GB && nationality === CONST.COUNTRY.GB) { + onMove(7, false); + // owner is not US citizen so we skip SSN step } else { - onMove(5, false); + onMove(6, false); } }; diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Confirmation.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Confirmation.tsx index e7044e738152..6c9e5af28627 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Confirmation.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Confirmation.tsx @@ -12,20 +12,20 @@ import SafeString from '@src/utils/SafeString'; type ConfirmationProps = SubStepProps & {ownerBeingModifiedID: string}; -const {PREFIX, COUNTRY} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; +const {PREFIX, NATIONALITY} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: ConfirmationProps) { const {translate} = useLocalize(); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); - const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: false}); + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: true}); const values = useMemo(() => getValuesForBeneficialOwner(ownerBeingModifiedID, reimbursementAccountDraft), [ownerBeingModifiedID, reimbursementAccountDraft]); - const beneficialOwnerCountryInputID = `${PREFIX}_${ownerBeingModifiedID}_${COUNTRY}` as const; - const beneficialOwnerCountry = SafeString(reimbursementAccountDraft?.[beneficialOwnerCountryInputID]); + const beneficialOwnerNationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const; + const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]); const policyID = reimbursementAccount?.achData?.policyID; - const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true}); const currency = policy?.outputCurrency ?? ''; const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? ''; - const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, countryStepCountryValue, beneficialOwnerCountry); + const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, countryStepCountryValue, beneficialOwnerNationality); const summaryItems = useMemo( () => [ @@ -37,12 +37,20 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm onMove(0); }, }, + { + title: CONST.ALL_COUNTRIES[values.nationality as keyof typeof CONST.ALL_COUNTRIES], + description: translate('ownershipInfoStep.countryOfCitizenship'), + shouldShowRightIcon: true, + onPress: () => { + onMove(1); + }, + }, { title: values.ownershipPercentage, description: translate('ownershipInfoStep.ownershipPercentage'), shouldShowRightIcon: true, onPress: () => { - onMove(1); + onMove(2); }, }, { @@ -50,17 +58,17 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm description: translate('common.dob'), shouldShowRightIcon: true, onPress: () => { - onMove(2); + onMove(3); }, }, - ...(beneficialOwnerCountry === CONST.COUNTRY.US + ...(beneficialOwnerNationality === CONST.COUNTRY.US ? [ { title: values.ssnLast4, description: translate('ownershipInfoStep.last4'), shouldShowRightIcon: true, onPress: () => { - onMove(4); + onMove(5); }, }, ] @@ -70,7 +78,7 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm description: translate('ownershipInfoStep.address'), shouldShowRightIcon: true, onPress: () => { - onMove(3); + onMove(4); }, }, ...(isDocumentNeededStatus.isProofOfOwnershipNeeded @@ -80,7 +88,7 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm description: translate('ownershipInfoStep.proofOfBeneficialOwner'), shouldShowRightIcon: true, onPress: () => { - onMove(5); + onMove(6); }, }, ] @@ -92,7 +100,7 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm description: translate('ownershipInfoStep.copyOfID'), shouldShowRightIcon: true, onPress: () => { - onMove(5); + onMove(6); }, }, ] @@ -104,7 +112,7 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm description: translate('ownershipInfoStep.proofOfAddress'), shouldShowRightIcon: true, onPress: () => { - onMove(5); + onMove(6); }, }, ] @@ -116,14 +124,14 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm description: translate('ownershipInfoStep.codiceFiscale'), shouldShowRightIcon: true, onPress: () => { - onMove(5); + onMove(6); }, }, ] : []), ], [ - beneficialOwnerCountry, + beneficialOwnerNationality, isDocumentNeededStatus.isCodiceFiscaleNeeded, isDocumentNeededStatus.isCopyOfIDNeeded, isDocumentNeededStatus.isProofOfAddressNeeded, @@ -137,6 +145,7 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm values.dob, values.firstName, values.lastName, + values.nationality, values.ownershipPercentage, values.proofOfOwnership, values.ssnLast4, diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Documents.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Documents.tsx index a7ee9e266020..15be745d6b3d 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Documents.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Documents.tsx @@ -21,7 +21,7 @@ import SafeString from '@src/utils/SafeString'; type DocumentsProps = SubStepProps & {ownerBeingModifiedID: string}; -const {PROOF_OF_OWNERSHIP, ADDRESS_PROOF, COPY_OF_ID, CODICE_FISCALE, COUNTRY, PREFIX} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; +const {PROOF_OF_OWNERSHIP, ADDRESS_PROOF, COPY_OF_ID, CODICE_FISCALE, NATIONALITY, PREFIX} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; function Documents({onNext, isEditing, ownerBeingModifiedID}: DocumentsProps) { const {translate} = useLocalize(); @@ -36,9 +36,9 @@ function Documents({onNext, isEditing, ownerBeingModifiedID}: DocumentsProps) { const copyOfIDInputID = `${PREFIX}_${ownerBeingModifiedID}_${COPY_OF_ID}` as const; const addressProofInputID = `${PREFIX}_${ownerBeingModifiedID}_${ADDRESS_PROOF}` as const; const codiceFiscaleInputID = `${PREFIX}_${ownerBeingModifiedID}_${CODICE_FISCALE}` as const; - const beneficialOwnerCountryInputID = `${PREFIX}_${ownerBeingModifiedID}_${COUNTRY}` as const; - const beneficialOwnerCountry = SafeString(reimbursementAccountDraft?.[beneficialOwnerCountryInputID]); - const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, countryStepCountryValue, beneficialOwnerCountry); + const beneficialOwnerNationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const; + const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]); + const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, countryStepCountryValue, beneficialOwnerNationality); const defaultValues: Record = { [proofOfOwnershipInputID]: Array.isArray(reimbursementAccountDraft?.[proofOfOwnershipInputID]) ? (reimbursementAccountDraft?.[proofOfOwnershipInputID] ?? []) : [], [copyOfIDInputID]: Array.isArray(reimbursementAccountDraft?.[copyOfIDInputID]) ? (reimbursementAccountDraft?.[copyOfIDInputID] ?? []) : [], diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Nationality.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Nationality.tsx new file mode 100644 index 000000000000..6c3351aaa10a --- /dev/null +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerDetailsFormSubSteps/Nationality.tsx @@ -0,0 +1,71 @@ +import React, {useCallback, useState} from 'react'; +import FormProvider from '@components/Form/FormProvider'; +import InputWrapper from '@components/Form/InputWrapper'; +import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; +import PushRowWithModal from '@components/PushRowWithModal'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useOnyx from '@hooks/useOnyx'; +import type {SubStepProps} from '@hooks/useSubStep/types'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {getFieldRequiredErrors} from '@libs/ValidationUtils'; +import {setDraftValues} from '@userActions/FormActions'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import SafeString from '@src/utils/SafeString'; + +type NationalityProps = SubStepProps & {isUserEnteringHisOwnData: boolean; ownerBeingModifiedID: string}; + +const {NATIONALITY, PREFIX} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; + +function Nationality({onNext, isEditing, isUserEnteringHisOwnData, ownerBeingModifiedID}: NationalityProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + + const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {canBeMissing: true}); + const nationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const; + const countryDefaultValue = SafeString(reimbursementAccountDraft?.[nationalityInputID]); + const [selectedCountry, setSelectedCountry] = useState(countryDefaultValue); + + const handleSubmit = () => { + setDraftValues(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM, {[nationalityInputID]: selectedCountry}); + onNext(); + }; + + const validate = useCallback( + (values: FormOnyxValues): FormInputErrors => { + return getFieldRequiredErrors(values, [nationalityInputID]); + }, + [nationalityInputID], + ); + + return ( + + + {translate(isUserEnteringHisOwnData ? 'ownershipInfoStep.whatsYourNationality' : 'ownershipInfoStep.whatsTheOwnersNationality')} + + setSelectedCountry(value as string)} + description={translate('common.country')} + modalHeaderTitle={translate('countryStep.selectCountry')} + searchInputTitle={translate('countryStep.findCountry')} + value={selectedCountry} + inputID={nationalityInputID} + shouldSaveDraft={false} + /> + + ); +} + +Nationality.displayName = 'Nationality'; + +export default Nationality; diff --git a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx index 5b44b12bbc04..479a1d6e78cd 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BeneficialOwnerInfo/BeneficialOwnerInfo.tsx @@ -20,6 +20,7 @@ import DateOfBirth from './BeneficialOwnerDetailsFormSubSteps/DateOfBirth'; import Documents from './BeneficialOwnerDetailsFormSubSteps/Documents'; import Last4SSN from './BeneficialOwnerDetailsFormSubSteps/Last4SSN'; import Name from './BeneficialOwnerDetailsFormSubSteps/Name'; +import Nationality from './BeneficialOwnerDetailsFormSubSteps/Nationality'; import OwnershipPercentage from './BeneficialOwnerDetailsFormSubSteps/OwnershipPercentage'; import BeneficialOwnersList from './BeneficialOwnersList'; @@ -46,7 +47,7 @@ type BeneficialOwnerDetailsFormProps = SubStepProps & { setTotalOwnedPercentage: (ownedPercentage: Record) => void; }; -const bodyContent: Array> = [Name, OwnershipPercentage, DateOfBirth, Address, Last4SSN, Documents, Confirmation]; +const bodyContent: Array> = [Name, Nationality, OwnershipPercentage, DateOfBirth, Address, Last4SSN, Documents, Confirmation]; function BeneficialOwnerInfo({onBackButtonPress, onSubmit, stepNames}: BeneficialOwnerInfoProps) { const {translate} = useLocalize(); @@ -172,18 +173,18 @@ function BeneficialOwnerInfo({onBackButtonPress, onSubmit, stepNames}: Beneficia } else if (currentSubStep === SUBSTEP.IS_ANYONE_ELSE_BENEFICIAL_OWNER) { setCurrentSubStep(SUBSTEP.IS_USER_BENEFICIAL_OWNER); } else if (currentSubStep === SUBSTEP.BENEFICIAL_OWNER_DETAILS_FORM && screenIndex > 0) { - if (screenIndex === 5) { + if (screenIndex === 6) { // User is on documents sub step and is not from US (no SSN needed) if (beneficialOwnerAddressCountryValue !== CONST.COUNTRY.US) { - moveTo(3, false); + moveTo(4, false); return; } } - if (screenIndex === 6) { + if (screenIndex === 7) { // User is on confirmation screen and is GB (no SSN or documents needed) if (countryStepCountryValue === CONST.COUNTRY.GB && beneficialOwnerAddressCountryValue === CONST.COUNTRY.GB) { - moveTo(3, false); + moveTo(4, false); return; } } diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForBeneficialOwner.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForBeneficialOwner.ts index 99aa8dd161dc..1e5aabd13c41 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForBeneficialOwner.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getNeededDocumentsStatusForBeneficialOwner.ts @@ -7,15 +7,15 @@ type NeededDocumentsStatusForBeneficialOwner = { isCodiceFiscaleNeeded: boolean; }; -function getNeededDocumentsStatusForBeneficialOwner(workspaceCurrency: string, accountCountry: string, beneficialOwnerCountry: string): NeededDocumentsStatusForBeneficialOwner { - const isCopyOfIDNeeded = workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerCountry !== CONST.COUNTRY.GB; +function getNeededDocumentsStatusForBeneficialOwner(workspaceCurrency: string, accountCountry: string, beneficialOwnerNationality: string): NeededDocumentsStatusForBeneficialOwner { + const isCopyOfIDNeeded = workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerNationality !== CONST.COUNTRY.GB; return { isProofOfOwnershipNeeded: workspaceCurrency === CONST.CURRENCY.EUR || workspaceCurrency === CONST.CURRENCY.AUD || workspaceCurrency === CONST.CURRENCY.CAD || - (workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerCountry !== CONST.COUNTRY.GB), + (workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerNationality !== CONST.COUNTRY.GB), isCopyOfIDNeeded, isProofOfAddressNeeded: workspaceCurrency === CONST.CURRENCY.EUR || isCopyOfIDNeeded, isCodiceFiscaleNeeded: accountCountry === CONST.COUNTRY.IT, diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getOwnerDetailsAndOwnerFilesForBeneficialOwners.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getOwnerDetailsAndOwnerFilesForBeneficialOwners.ts index 21b0ad096b5f..3ffee08ac178 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getOwnerDetailsAndOwnerFilesForBeneficialOwners.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getOwnerDetailsAndOwnerFilesForBeneficialOwners.ts @@ -21,10 +21,11 @@ const { CODICE_FISCALE, RESIDENTIAL_ADDRESS, FULL_NAME, + NATIONALITY, PREFIX, } = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA; -const ownerDetailsFields = [FIRST_NAME, LAST_NAME, OWNERSHIP_PERCENTAGE, DOB, SSN_LAST_4, STREET, CITY, STATE, ZIP_CODE, COUNTRY]; +const ownerDetailsFields = [FIRST_NAME, LAST_NAME, OWNERSHIP_PERCENTAGE, DOB, SSN_LAST_4, STREET, CITY, STATE, ZIP_CODE, COUNTRY, NATIONALITY]; const ownerFilesFields = [PROOF_OF_OWNERSHIP, COPY_OF_ID, ADDRESS_PROOF, CODICE_FISCALE]; function getOwnerDetailsAndOwnerFilesForBeneficialOwners(ownerKeys: string[], reimbursementAccountDraft: OnyxEntry) { @@ -34,7 +35,7 @@ function getOwnerDetailsAndOwnerFilesForBeneficialOwners(ownerKeys: string[], re for (const ownerKey of ownerKeys) { const ownerDetailsFullNameKey = `${PREFIX}_${ownerKey}_${FULL_NAME}` as const; const ownerDetailsResidentialAddressKey = `${PREFIX}_${ownerKey}_${RESIDENTIAL_ADDRESS}` as const; - const ownerDetailsNationalityKey = `${PREFIX}_${ownerKey}_${COUNTRY}` as const; + const ownerDetailsNationalityKey = `${PREFIX}_${ownerKey}_${NATIONALITY}` as const; for (const fieldName of ownerDetailsFields) { const ownerDetailsKey = `${PREFIX}_${ownerKey}_${fieldName}` as const; @@ -59,7 +60,7 @@ function getOwnerDetailsAndOwnerFilesForBeneficialOwners(ownerKeys: string[], re continue; } - if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { + if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE || fieldName === COUNTRY) { ownerDetails[ownerDetailsResidentialAddressKey] = ownerDetails[ownerDetailsResidentialAddressKey] ? `${SafeString(ownerDetails[ownerDetailsResidentialAddressKey])}, ${SafeString(reimbursementAccountDraft[ownerDetailsKey])}` : reimbursementAccountDraft[ownerDetailsKey]; diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForBeneficialOwner.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForBeneficialOwner.ts index 7982ea5a0f98..12ce05d4a005 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForBeneficialOwner.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getValuesForBeneficialOwner.ts @@ -6,6 +6,7 @@ import type {FileObject} from '@src/types/utils/Attachment'; type BeneficialOwnerValues = { firstName: string; lastName: string; + nationality: string; ownershipPercentage: string; dob: string; ssnLast4: string; @@ -25,6 +26,7 @@ function getValuesForOwner(beneficialOwnerBeingModifiedID: string, reimbursement return { firstName: '', lastName: '', + nationality: '', ownershipPercentage: '', dob: '', ssnLast4: '', @@ -45,6 +47,7 @@ function getValuesForOwner(beneficialOwnerBeingModifiedID: string, reimbursement const INPUT_KEYS = { firstName: `${beneficialOwnerPrefix}_${beneficialOwnerBeingModifiedID}_${beneficialOwnerInfoKey.FIRST_NAME}`, lastName: `${beneficialOwnerPrefix}_${beneficialOwnerBeingModifiedID}_${beneficialOwnerInfoKey.LAST_NAME}`, + nationality: `${beneficialOwnerPrefix}_${beneficialOwnerBeingModifiedID}_${beneficialOwnerInfoKey.NATIONALITY}`, ownershipPercentage: `${beneficialOwnerPrefix}_${beneficialOwnerBeingModifiedID}_${beneficialOwnerInfoKey.OWNERSHIP_PERCENTAGE}`, dob: `${beneficialOwnerPrefix}_${beneficialOwnerBeingModifiedID}_${beneficialOwnerInfoKey.DOB}`, ssnLast4: `${beneficialOwnerPrefix}_${beneficialOwnerBeingModifiedID}_${beneficialOwnerInfoKey.SSN_LAST_4}`, @@ -62,6 +65,7 @@ function getValuesForOwner(beneficialOwnerBeingModifiedID: string, reimbursement return { firstName: reimbursementAccountDraft[INPUT_KEYS.firstName] ?? '', lastName: reimbursementAccountDraft[INPUT_KEYS.lastName] ?? '', + nationality: reimbursementAccountDraft[INPUT_KEYS.nationality] ?? '', ownershipPercentage: reimbursementAccountDraft[INPUT_KEYS.ownershipPercentage] ?? '', dob: reimbursementAccountDraft[INPUT_KEYS.dob] ?? '', ssnLast4: reimbursementAccountDraft[INPUT_KEYS.ssnLast4] ?? '',