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
14 changes: 9 additions & 5 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ const CONST = {
// The back-end is always returning account number with 4 last digits and mask the rest with X
MASKED_US_ACCOUNT_NUMBER: /^[X]{0,13}[0-9]{4}$/,
SWIFT_BIC: /^[A-Za-z0-9]{8,11}$/,
IBAN: /^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$/,
INTERNATIONAL_SWIFT_CODE: /^.{1,12}$/,
},
STATE: {
VERIFYING: 'VERIFYING',
Expand Down Expand Up @@ -7972,6 +7974,7 @@ const CONST = {
PAGE_NAME: {
COUNTRY: 'country',
ACCOUNT_DETAILS: 'account-details',
INTERNATIONAL_BANK_ACCOUNT_DETAILS: 'international-bank-account-details',
ACCOUNT_TYPE: 'account-type',
BANK_INFORMATION: 'bank-information',
ACCOUNT_HOLDER_DETAILS: 'account-holder-details',
Expand All @@ -7982,11 +7985,12 @@ const CONST = {
MAPPING: {
COUNTRY_SELECTOR: 0,
BANK_ACCOUNT_DETAILS: 1,
ACCOUNT_TYPE: 2,
BANK_INFORMATION: 3,
ACCOUNT_HOLDER_INFORMATION: 4,
CONFIRMATION: 5,
SUCCESS: 6,
INTERNATIONAL_BANK_ACCOUNT_DETAILS: 2,
ACCOUNT_TYPE: 3,
BANK_INFORMATION: 4,
ACCOUNT_HOLDER_INFORMATION: 5,
CONFIRMATION: 6,
SUCCESS: 7,
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,9 @@ ${amount} für ${merchant} – ${date}`,
thisBankAccount: 'Dieses Bankkonto wird für Geschäftszahlungen in deinem Workspace verwendet',
accountNumber: 'Kontonummer',
routingNumber: 'Routing-Nummer',
internationalBankAccountDetails: 'Internationale Bankkontodaten',
iban: 'IBAN',
swiftBicCode: 'SWIFT/BIC-Code',
chooseAnAccountBelow: 'Wähle unten ein Konto aus',
addBankAccount: 'Bankkonto hinzufügen',
chooseAnAccount: 'Konto auswählen',
Expand Down Expand Up @@ -3686,6 +3689,7 @@ ${amount} für ${merchant} – ${date}`,
restrictedBusiness: 'Bitte bestätigen Sie, dass das Unternehmen nicht auf der Liste der eingeschränkten Unternehmen steht.',
routingNumber: 'Bitte geben Sie eine gültige Bankleitzahl ein',
accountNumber: 'Bitte eine gültige Kontonummer eingeben',
swiftCodeOrIban: 'Bitte gib einen gültigen Swift-Code/IBAN ein',
routingAndAccountNumberCannotBeSame: 'Bankleitzahl und Kontonummer dürfen nicht identisch sein',
companyType: 'Bitte wähle einen gültigen Unternehmenstyp aus',
tooManyAttempts:
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3734,6 +3734,9 @@ const translations = {
thisBankAccount: 'This bank account will be used for business payments on your workspace',
accountNumber: 'Account number',
routingNumber: 'Routing number',
internationalBankAccountDetails: 'International bank account details',
iban: 'IBAN',
swiftBicCode: 'SWIFT/BIC code',
chooseAnAccountBelow: 'Choose an account below',
addBankAccount: 'Add bank account',
chooseAnAccount: 'Choose an account',
Expand Down Expand Up @@ -3783,6 +3786,7 @@ const translations = {
restrictedBusiness: "Please confirm the business isn't on the list of restricted businesses",
routingNumber: 'Please enter a valid routing number',
accountNumber: 'Please enter a valid account number',
swiftCodeOrIban: 'Please enter a valid Swift code/IBAN',
routingAndAccountNumberCannotBeSame: "Routing and account numbers can't match",
companyType: 'Please select a valid company type',
tooManyAttempts: 'Due to a high number of login attempts, this option has been disabled for 24 hours. Please try again later or enter details manually instead.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3508,6 +3508,9 @@ ${amount} para ${merchant} - ${date}`,
thisBankAccount: 'Esta cuenta bancaria se utilizará para pagos comerciales en tu espacio de trabajo',
accountNumber: 'Número de cuenta',
routingNumber: 'Número de ruta',
internationalBankAccountDetails: 'Datos de la cuenta bancaria internacional',
iban: 'IBAN',
swiftBicCode: 'Código SWIFT/BIC',
chooseAnAccountBelow: 'Elige una cuenta a continuación',
addBankAccount: 'Añadir cuenta bancaria',
chooseAnAccount: 'Elige una cuenta',
Expand Down Expand Up @@ -3557,6 +3560,7 @@ ${amount} para ${merchant} - ${date}`,
restrictedBusiness: 'Por favor, confirma que la empresa no está en la lista de negocios restringidos',
routingNumber: 'Por favor, introduce un número de ruta válido',
accountNumber: 'Por favor, introduce un número de cuenta válido',
swiftCodeOrIban: 'Por favor, introduce un código Swift/IBAN válido',
routingAndAccountNumberCannotBeSame: 'Los números de ruta y de cuenta no pueden ser iguales',
companyType: 'Por favor, selecciona un tipo de compañía válido',
tooManyAttempts:
Expand Down
4 changes: 4 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3646,6 +3646,9 @@ ${amount} pour ${merchant} - ${date}`,
thisBankAccount: 'Ce compte bancaire sera utilisé pour les paiements professionnels dans votre espace de travail',
accountNumber: 'Numéro de compte',
routingNumber: 'Numéro de routage',
internationalBankAccountDetails: 'Coordonnées bancaires internationales',
iban: 'IBAN',
swiftBicCode: 'Code SWIFT/BIC',
chooseAnAccountBelow: 'Choisissez un compte ci-dessous',
addBankAccount: 'Ajouter un compte bancaire',
chooseAnAccount: 'Choisissez un compte',
Expand Down Expand Up @@ -3696,6 +3699,7 @@ ${amount} pour ${merchant} - ${date}`,
restrictedBusiness: 'Veuillez confirmer que l’entreprise ne figure pas sur la liste des entreprises restreintes',
routingNumber: 'Veuillez saisir un numéro d’acheminement valide',
accountNumber: 'Veuillez saisir un numéro de compte valide',
swiftCodeOrIban: 'Veuillez saisir un code Swift/IBAN valide',
routingAndAccountNumberCannotBeSame: 'Le code de routage et le numéro de compte ne peuvent pas être identiques',
companyType: 'Veuillez sélectionner un type d’entreprise valide',
tooManyAttempts:
Expand Down
4 changes: 4 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3627,6 +3627,9 @@ ${amount} per ${merchant} - ${date}`,
thisBankAccount: 'Questo conto bancario sarà utilizzato per i pagamenti aziendali nel tuo spazio di lavoro',
accountNumber: 'Numero di conto',
routingNumber: 'Numero di instradamento',
internationalBankAccountDetails: 'Dati del conto bancario internazionale',
iban: 'IBAN',
swiftBicCode: 'Codice SWIFT/BIC',
chooseAnAccountBelow: 'Scegli un account qui sotto',
addBankAccount: 'Aggiungi conto bancario',
chooseAnAccount: 'Scegli un account',
Expand Down Expand Up @@ -3676,6 +3679,7 @@ ${amount} per ${merchant} - ${date}`,
restrictedBusiness: 'Conferma che l’azienda non sia nell’elenco delle attività soggette a restrizioni',
routingNumber: 'Inserisci un numero di instradamento valido',
accountNumber: 'Inserisci un numero di conto valido',
swiftCodeOrIban: 'Inserisci un codice Swift/IBAN valido',
routingAndAccountNumberCannotBeSame: 'I numeri di routing e di conto non possono coincidere',
companyType: 'Seleziona un tipo di azienda valido',
tooManyAttempts: 'A causa di un numero elevato di tentativi di accesso, questa opzione è stata disabilitata per 24 ore. Riprova più tardi o inserisci invece i dati manualmente.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3594,6 +3594,9 @@ ${integrationName === CONST.ONBOARDING_ACCOUNTING_MAPPING.other ? 'あなたの'
thisBankAccount: 'この銀行口座は、ワークスペースでのビジネス支払いに使用されます',
accountNumber: '口座番号',
routingNumber: 'ルーティング番号',
internationalBankAccountDetails: '海外銀行口座情報',
iban: 'IBAN',
swiftBicCode: 'SWIFT/BICコード',
chooseAnAccountBelow: '下のアカウントを選択してください',
addBankAccount: '銀行口座を追加',
chooseAnAccount: 'アカウントを選択',
Expand Down Expand Up @@ -3643,6 +3646,7 @@ ${integrationName === CONST.ONBOARDING_ACCOUNTING_MAPPING.other ? 'あなたの'
restrictedBusiness: 'ビジネスが制限対象の事業一覧に含まれていないことを確認してください',
routingNumber: '有効なルーティング番号を入力してください',
accountNumber: '有効な口座番号を入力してください',
swiftCodeOrIban: '有効なSwiftコード/IBANを入力してください',
routingAndAccountNumberCannotBeSame: 'ルーティング番号と口座番号を同じにすることはできません',
companyType: '有効な会社の種類を選択してください',
tooManyAttempts: 'ログイン試行回数が多すぎるため、このオプションは24時間無効になっています。時間をおいてから再度お試しいただくか、代わりに詳細情報を手動で入力してください。',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3623,6 +3623,9 @@ ${amount} voor ${merchant} - ${date}`,
thisBankAccount: 'Deze bankrekening wordt gebruikt voor zakelijke betalingen in je workspace',
accountNumber: 'Rekeningnummer',
routingNumber: 'Routingnummer',
internationalBankAccountDetails: 'Internationale bankrekeninggegevens',
iban: 'IBAN',
swiftBicCode: 'SWIFT/BIC-code',
chooseAnAccountBelow: 'Kies een account hieronder',
addBankAccount: 'Bankrekening toevoegen',
chooseAnAccount: 'Kies een account',
Expand Down Expand Up @@ -3672,6 +3675,7 @@ ${amount} voor ${merchant} - ${date}`,
restrictedBusiness: 'Bevestig dat het bedrijf niet op de lijst met beperkte bedrijven staat',
routingNumber: 'Voer een geldig routingnummer in',
accountNumber: 'Voer een geldig rekeningnummer in',
swiftCodeOrIban: 'Voer een geldige Swift-code/IBAN in',
routingAndAccountNumberCannotBeSame: 'Routing- en rekeningnummers mogen niet hetzelfde zijn',
companyType: 'Selecteer een geldig bedrijfstype',
tooManyAttempts: 'Vanwege een groot aantal inlogpogingen is deze optie voor 24 uur uitgeschakeld. Probeer het later opnieuw of voer de gegevens in plaats daarvan handmatig in.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3608,6 +3608,9 @@ ${amount} dla ${merchant} - ${date}`,
thisBankAccount: 'To konto bankowe będzie używane do płatności firmowych w Twoim obszarze roboczym',
accountNumber: 'Numer konta',
routingNumber: 'Numer rozliczeniowy',
internationalBankAccountDetails: 'Dane międzynarodowego konta bankowego',
iban: 'IBAN',
swiftBicCode: 'Kod SWIFT/BIC',
chooseAnAccountBelow: 'Wybierz konto poniżej',
addBankAccount: 'Dodaj konto bankowe',
chooseAnAccount: 'Wybierz konto',
Expand Down Expand Up @@ -3657,6 +3660,7 @@ ${amount} dla ${merchant} - ${date}`,
restrictedBusiness: 'Potwierdź, że firma nie znajduje się na liście działalności objętych ograniczeniami',
routingNumber: 'Wprowadź prawidłowy numer rozliczeniowy',
accountNumber: 'Wprowadź prawidłowy numer konta',
swiftCodeOrIban: 'Wprowadź prawidłowy kod Swift/IBAN',
routingAndAccountNumberCannotBeSame: 'Numer rozliczeniowy i numer konta nie mogą być takie same',
companyType: 'Wybierz prawidłowy typ firmy',
tooManyAttempts: 'Ze względu na dużą liczbę prób logowania ta opcja została wyłączona na 24 godziny. Spróbuj ponownie później lub wprowadź dane ręcznie.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,9 @@ ${amount} para ${merchant} - ${date}`,
thisBankAccount: 'Esta conta bancária será usada para pagamentos empresariais no seu workspace',
accountNumber: 'Número da conta',
routingNumber: 'Número de roteamento',
internationalBankAccountDetails: 'Dados da conta bancária internacional',
iban: 'IBAN',
swiftBicCode: 'Código SWIFT/BIC',
chooseAnAccountBelow: 'Escolha uma conta abaixo',
addBankAccount: 'Adicionar conta bancária',
chooseAnAccount: 'Escolha uma conta',
Expand Down Expand Up @@ -3661,6 +3664,7 @@ ${amount} para ${merchant} - ${date}`,
restrictedBusiness: 'Confirme que a empresa não está na lista de empresas restritas',
routingNumber: 'Insira um número de roteamento válido',
accountNumber: 'Insira um número de conta válido',
swiftCodeOrIban: 'Por favor, insira um código Swift/IBAN válido',
routingAndAccountNumberCannotBeSame: 'Os números de roteamento e da conta não podem ser iguais',
companyType: 'Selecione um tipo de empresa válido',
tooManyAttempts: 'Devido ao alto número de tentativas de login, esta opção foi desativada por 24 horas. Tente novamente mais tarde ou insira os dados manualmente.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3521,6 +3521,9 @@ ${amount},商户:${merchant} - 日期:${date}`,
thisBankAccount: '此银行账户将用于您工作区的业务付款',
accountNumber: '账号编号',
routingNumber: '路由号码',
internationalBankAccountDetails: '国际银行账户信息',
iban: 'IBAN',
swiftBicCode: 'SWIFT/BIC 代码',
chooseAnAccountBelow: '在下方选择一个账户',
addBankAccount: '添加银行账户',
chooseAnAccount: '选择一个账户',
Expand Down Expand Up @@ -3569,6 +3572,7 @@ ${amount},商户:${merchant} - 日期:${date}`,
restrictedBusiness: '请确认该企业不在受限制业务列表中',
routingNumber: '请输入有效的路由号码',
accountNumber: '请输入有效的账户号码',
swiftCodeOrIban: '请输入有效的 Swift 代码/IBAN',
routingAndAccountNumberCannotBeSame: '路由号码和账号不能相同',
companyType: '请选择一个有效的公司类型',
tooManyAttempts: '由于登录尝试次数过多,此选项已被禁用 24 小时。请稍后重试,或改为手动输入详细信息。',
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/parameters/AddPersonalBankAccountParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type AddPersonalBankAccountParams = {
addressZip?: string;
addressCountry?: string;
confirmedOwnershipDetails?: boolean;
iban?: string;
swiftCode?: string;
};

export default AddPersonalBankAccountParams;
2 changes: 2 additions & 0 deletions src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ function addPersonalBankAccount(
addressZip: account?.addressZipCode,
addressCountry: account?.country,
confirmedOwnershipDetails: account?.confirmedOwnershipDetails,
iban: account?.iban,
swiftCode: account?.swiftCode,
};
if (policyID) {
parameters.policyID = policyID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ScreenWrapper from '@components/ScreenWrapper';

import useAndroidBackButtonHandler from '@hooks/useAndroidBackButtonHandler';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useRootNavigationState from '@hooks/useRootNavigationState';
import useSubPage from '@hooks/useSubPage';

Expand All @@ -22,14 +23,15 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import {createShouldCollectInternationalDepositDetailsSelector} from '@src/selectors/Policy';
import type {InternationalBankAccountForm} from '@src/types/form';
import type {BankAccountList, CorpayFields, PrivatePersonalDetails} from '@src/types/onyx';
import type {BankAccountList, CorpayFields, Policy, PrivatePersonalDetails} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';

import {useRoute} from '@react-navigation/native';
import React from 'react';
import React, {useCallback} from 'react';

import type CustomSubPageProps from './types';

Expand All @@ -39,6 +41,7 @@ import BankAccountDetails from './subPages/BankAccountDetails';
import BankInformation from './subPages/BankInformation';
import Confirmation from './subPages/Confirmation';
import CountrySelection from './subPages/CountrySelection';
import InternationalBankAccountDetails from './subPages/InternationalBankAccountDetails';
import Success from './subPages/Success';
import {getFieldsMap, getInitialPersonalDetailsValues, getInitialSubstep, getSubstepValues, testValidation} from './utils';

Expand All @@ -55,15 +58,19 @@ type InternationalDepositAccountContentProps = {
const pages = [
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.COUNTRY, component: CountrySelection},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.ACCOUNT_DETAILS, component: BankAccountDetails},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.INTERNATIONAL_BANK_ACCOUNT_DETAILS, component: InternationalBankAccountDetails},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.ACCOUNT_TYPE, component: AccountType},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.BANK_INFORMATION, component: BankInformation},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.ACCOUNT_HOLDER_DETAILS, component: AccountHolderInformation},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.CONFIRM, component: Confirmation},
{pageName: CONST.CORPAY_FIELDS.PAGE_NAME.SUCCESS, component: Success},
];

function getSkippedPages(skipAccountTypeStep: boolean, skipAccountHolderInformationStep: boolean) {
function getSkippedPages(skipAccountTypeStep: boolean, skipAccountHolderInformationStep: boolean, skipInternationalBankAccountDetailsStep: boolean) {
const skippedSteps = [];
if (skipInternationalBankAccountDetailsStep) {
skippedSteps.push(CONST.CORPAY_FIELDS.PAGE_NAME.INTERNATIONAL_BANK_ACCOUNT_DETAILS);
}
if (skipAccountTypeStep) {
skippedSteps.push(CONST.CORPAY_FIELDS.PAGE_NAME.ACCOUNT_TYPE);
}
Expand All @@ -87,6 +94,12 @@ function InternationalDepositAccountContent({
const fieldsMap = getFieldsMap(corpayFields);

const values = getSubstepValues(privatePersonalDetails, corpayFields, bankAccountList, draftValues, country, fieldsMap);
const bankCountry = values.bankCountry;
const shouldCollectInternationalDepositDetailsSelector = useCallback(
(policies: OnyxCollection<Policy>) => createShouldCollectInternationalDepositDetailsSelector(bankCountry)(policies),
[bankCountry],
);
const [shouldCollectInternationalDepositDetails] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: shouldCollectInternationalDepositDetailsSelector});

const initialAccountHolderDetailsValues = getInitialPersonalDetailsValues(privatePersonalDetails);

Expand All @@ -96,7 +109,11 @@ function InternationalDepositAccountContent({

const skipAccountHolderInformationStep = testValidation(initialAccountHolderDetailsValues, fieldsMap[CONST.CORPAY_FIELDS.PAGE_NAME.ACCOUNT_HOLDER_DETAILS]);

const skippedPages = getSkippedPages(skipAccountTypeStep, skipAccountHolderInformationStep);
// Skip the international bank account details step when no collecting policy needs international details for the
// selected bank country, or once we already have both the IBAN and SWIFT/BIC code.
const skipInternationalBankAccountDetailsStep = !shouldCollectInternationalDepositDetails || (!!values.iban && !!values.swiftCode);

const skippedPages = getSkippedPages(skipAccountTypeStep, skipAccountHolderInformationStep, skipInternationalBankAccountDetailsStep);

const route = useRoute<PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.ADD_BANK_ACCOUNT>>();
const topmostFullScreenRoute = useRootNavigationState((state) => state?.routes.findLast((r) => isFullScreenName(r.name)));
Expand Down
Loading
Loading