Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import OwnershipPercentage from './BeneficialOwnerDetailsFormSubSteps/OwnershipP

const {PAGE_NAME, BENEFICIAL_OWNER_INFO_STEP} = CONST.NON_USD_BANK_ACCOUNT;
const SUB_PAGE_NAMES = BENEFICIAL_OWNER_INFO_STEP.SUB_PAGE_NAMES;
const {OWNERSHIP_PERCENTAGE, NATIONALITY, PREFIX} = BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA;
const {OWNERSHIP_PERCENTAGE, NATIONALITY, COUNTRY, PREFIX} = BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA;

type BeneficialOwnerSubPageProps = SubPageProps & {
ownerBeingModifiedID: string;
Expand Down Expand Up @@ -67,6 +67,8 @@ function BeneficialOwnerDetailsFormPages({stepNames, policyID, onFinished, backT

const beneficialOwnerNationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const;
const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]);
const beneficialOwnerCountryInputID = `${PREFIX}_${ownerBeingModifiedID}_${COUNTRY}` as const;
const beneficialOwnerResidentialCountry = SafeString(reimbursementAccountDraft?.[beneficialOwnerCountryInputID]);
const countryStepCountryValue = reimbursementAccountDraft?.[INPUT_IDS.ADDITIONAL_DATA.COUNTRY] ?? '';

const totalOwnedPercentage = Object.fromEntries(
Expand All @@ -81,11 +83,11 @@ function BeneficialOwnerDetailsFormPages({stepNames, policyID, onFinished, backT
if (beneficialOwnerNationality !== CONST.COUNTRY.US) {
pagesToSkip.push(SUB_PAGE_NAMES.LAST_4_SSN);
}
if (countryStepCountryValue === CONST.COUNTRY.GB && beneficialOwnerNationality === CONST.COUNTRY.GB) {
if (countryStepCountryValue === CONST.COUNTRY.GB && beneficialOwnerResidentialCountry === CONST.COUNTRY.GB) {
pagesToSkip.push(SUB_PAGE_NAMES.DOCUMENTS);
}
return pagesToSkip;
}, [beneficialOwnerNationality, countryStepCountryValue]);
}, [beneficialOwnerNationality, beneficialOwnerResidentialCountry, countryStepCountryValue]);

const buildRoute = useCallback(
(pageName: string, action?: 'edit') => ROUTES.BANK_ACCOUNT_NON_USD_SETUP.getRoute({policyID, page: PAGE_NAME.BENEFICIAL_OWNER_INFO, subPage: pageName, action, backTo}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SafeString from '@src/utils/SafeString';

type ConfirmationProps = SubPageProps & {ownerBeingModifiedID: string};

const {PREFIX, NATIONALITY} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA;
const {PREFIX, NATIONALITY, COUNTRY} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA;

function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: ConfirmationProps) {
const {translate} = useLocalize();
Expand All @@ -21,10 +21,12 @@ function Confirmation({onNext, onMove, isEditing, ownerBeingModifiedID}: Confirm
const values = useMemo(() => getValuesForBeneficialOwner(ownerBeingModifiedID, reimbursementAccountDraft), [ownerBeingModifiedID, reimbursementAccountDraft]);
const beneficialOwnerNationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const;
const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]);
const beneficialOwnerCountryInputID = `${PREFIX}_${ownerBeingModifiedID}_${COUNTRY}` as const;
const beneficialOwnerResidentialCountry = SafeString(reimbursementAccountDraft?.[beneficialOwnerCountryInputID]);
const policyID = reimbursementAccount?.achData?.policyID;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
const {country, currency} = getCurrencyForNonUSDBankAccount(policy, reimbursementAccountDraft, reimbursementAccount);
const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, country, beneficialOwnerNationality);
const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, country, beneficialOwnerNationality, beneficialOwnerResidentialCountry);

const summaryItems = useMemo(
() => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import SafeString from '@src/utils/SafeString';

type DocumentsProps = SubPageProps & {ownerBeingModifiedID: string};

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;
const {PROOF_OF_OWNERSHIP, ADDRESS_PROOF, COPY_OF_ID, CODICE_FISCALE, NATIONALITY, COUNTRY, PREFIX} = CONST.NON_USD_BANK_ACCOUNT.BENEFICIAL_OWNER_INFO_STEP.BENEFICIAL_OWNER_DATA;

function Documents({onNext, isEditing, ownerBeingModifiedID}: DocumentsProps) {
const {translate} = useLocalize();
Expand All @@ -37,7 +37,9 @@ function Documents({onNext, isEditing, ownerBeingModifiedID}: DocumentsProps) {
const codiceFiscaleInputID = `${PREFIX}_${ownerBeingModifiedID}_${CODICE_FISCALE}` as const;
const beneficialOwnerNationalityInputID = `${PREFIX}_${ownerBeingModifiedID}_${NATIONALITY}` as const;
const beneficialOwnerNationality = SafeString(reimbursementAccountDraft?.[beneficialOwnerNationalityInputID]);
const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, country, beneficialOwnerNationality);
const beneficialOwnerCountryInputID = `${PREFIX}_${ownerBeingModifiedID}_${COUNTRY}` as const;
const beneficialOwnerResidentialCountry = SafeString(reimbursementAccountDraft?.[beneficialOwnerCountryInputID]);
const isDocumentNeededStatus = getNeededDocumentsStatusForBeneficialOwner(currency, country, beneficialOwnerNationality, beneficialOwnerResidentialCountry);
const defaultValues: Record<string, FileObject[]> = {
[proofOfOwnershipInputID]: Array.isArray(reimbursementAccountDraft?.[proofOfOwnershipInputID]) ? (reimbursementAccountDraft?.[proofOfOwnershipInputID] ?? []) : [],
[copyOfIDInputID]: Array.isArray(reimbursementAccountDraft?.[copyOfIDInputID]) ? (reimbursementAccountDraft?.[copyOfIDInputID] ?? []) : [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ type NeededDocumentsStatusForBeneficialOwner = {
isCodiceFiscaleNeeded: boolean;
};

function getNeededDocumentsStatusForBeneficialOwner(workspaceCurrency: string, accountCountry: string, beneficialOwnerNationality: string): NeededDocumentsStatusForBeneficialOwner {
const isCopyOfIDNeeded = workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerNationality !== CONST.COUNTRY.GB;
function getNeededDocumentsStatusForBeneficialOwner(
workspaceCurrency: string,
accountCountry: string,
beneficialOwnerNationality: string,
beneficialOwnerResidentialCountry: string,
): NeededDocumentsStatusForBeneficialOwner {
const isNonGBResidentOnGBAccount = workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerResidentialCountry !== CONST.COUNTRY.GB;
const isCopyOfIDNeeded = isNonGBResidentOnGBAccount;

return {
isProofOfOwnershipNeeded:
workspaceCurrency === CONST.CURRENCY.EUR ||
workspaceCurrency === CONST.CURRENCY.AUD ||
workspaceCurrency === CONST.CURRENCY.CAD ||
(workspaceCurrency === CONST.CURRENCY.GBP && beneficialOwnerNationality !== CONST.COUNTRY.GB),
workspaceCurrency === CONST.CURRENCY.EUR || workspaceCurrency === CONST.CURRENCY.AUD || workspaceCurrency === CONST.CURRENCY.CAD || isNonGBResidentOnGBAccount,
isCopyOfIDNeeded,
isProofOfAddressNeeded: workspaceCurrency === CONST.CURRENCY.EUR || isCopyOfIDNeeded,
isCodiceFiscaleNeeded: accountCountry === CONST.COUNTRY.IT,
Expand Down
Loading