Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Corpay bank info step and update file upload logic #52054

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ const CONST = {
ALLOWED_FILE_TYPES: ['pdf', 'jpg', 'jpeg', 'png'],
FILE_LIMIT: 10,
TOTAL_FILES_SIZE_LIMIT: 5242880,
BANK_INFO_STEP_ACCOUNT_HOLDER_KEY_PREFIX: 'accountHolder',
STEP: {
COUNTRY: 'CountryStep',
BANK_INFO: 'BankInfoStep',
Expand Down
13 changes: 8 additions & 5 deletions src/components/UploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ function UploadFile({
const theme = useTheme();

const handleFileUpload = (files: FileObject[]) => {
const totalSize = files.reduce((sum, file) => sum + (file.size ?? 0), 0);
const resultedFiles = [...uploadedFiles, ...files];

const totalSize = resultedFiles.reduce((sum, file) => sum + (file.size ?? 0), 0);

if (totalFilesSizeLimit) {
if (totalSize > totalFilesSizeLimit) {
Expand All @@ -78,7 +80,7 @@ function UploadFile({
}
}

if (fileLimit && files.length > 0 && files.length > fileLimit) {
if (fileLimit && resultedFiles.length > 0 && resultedFiles.length > fileLimit) {
setError(translate('attachmentPicker.tooManyFiles', {fileLimit}));
return;
}
Expand All @@ -98,6 +100,7 @@ function UploadFile({

onInputChange(newFilesToUpload);
onUpload(newFilesToUpload);
setError('');
};

return (
Expand Down Expand Up @@ -131,13 +134,13 @@ function UploadFile({
medium
/>
<Text
style={[styles.ml2, styles.mr2, styles.textBold, styles.breakWord, styles.w100]}
style={[styles.ml2, styles.mr2, styles.textBold, styles.breakWord, styles.w100, styles.flexShrink1]}
numberOfLines={2}
>
{file.name}
</Text>
<PressableWithFeedback
onPress={() => onRemove(file?.uri ?? '')}
onPress={() => onRemove(file?.name ?? '')}
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('common.remove')}
>
Expand All @@ -151,7 +154,7 @@ function UploadFile({
))}
{errorText !== '' && (
<DotIndicatorMessage
textStyles={[styles.formError]}
style={[styles.formError, styles.mt3]}
type="error"
messages={{errorText}}
/>
Expand Down
11 changes: 11 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import type {
InvalidPropertyParams,
InvalidValueParams,
IssueVirtualCardParams,
LastFourDigitsParams,
LastSyncAccountingParams,
LastSyncDateParams,
LocalTimeParams,
Expand Down Expand Up @@ -2255,6 +2256,16 @@ const translations = {
findCountry: 'Find country',
selectCountry: 'Select country',
},
bankInfoStep: {
whatAreYour: 'What are your business bank account details?',
letsDoubleCheck: 'Let’s double check that everything looks fine.',
thisBankAccount: 'This bank account will be used for business payments on your workspace',
accountNumber: 'Account number',
bankStatement: 'Bank statement',
chooseFile: 'Choose file',
uploadYourLatest: 'Upload your latest statement',
pleaseUpload: ({lastFourDigits}: LastFourDigitsParams) => `Please upload the most recent monthly statement for your business bank account ending in ${lastFourDigits}.`,
},
signerInfoStep: {
signerInfo: 'Signer info',
},
Expand Down
11 changes: 11 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import type {
InvalidPropertyParams,
InvalidValueParams,
IssueVirtualCardParams,
LastFourDigitsParams,
LastSyncAccountingParams,
LastSyncDateParams,
LocalTimeParams,
Expand Down Expand Up @@ -2278,6 +2279,16 @@ const translations = {
findCountry: 'Encontrar país',
selectCountry: 'Seleccione su país',
},
bankInfoStep: {
whatAreYour: '¿Cuáles son los detalles de tu cuenta bancaria comercial?',
letsDoubleCheck: 'Verifiquemos que todo esté bien.',
thisBankAccount: 'Esta cuenta bancaria se utilizará para pagos comerciales en tu espacio de trabajo.',
accountNumber: 'Número de cuenta',
bankStatement: 'Extracto bancario',
chooseFile: 'Elegir archivo',
uploadYourLatest: '¿Cuáles son los detalles de tu cuenta bancaria comercial?',
pleaseUpload: ({lastFourDigits}: LastFourDigitsParams) => `Por favor suba el estado de cuenta mensual más reciente de tu cuenta bancaria comercial que termina en ${lastFourDigits}.`,
},
signerInfoStep: {
signerInfo: 'Información del firmante',
},
Expand Down
5 changes: 5 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ type FileLimitParams = {
fileLimit: number;
};

type LastFourDigitsParams = {
lastFourDigits: string;
};

type CompanyCardBankName = {
bankName: string;
};
Expand Down Expand Up @@ -637,6 +641,7 @@ export type {
HeldRequestParams,
InstantSummaryParams,
IssueVirtualCardParams,
LastFourDigitsParams,
LocalTimeParams,
LogSizeParams,
LoggedInAsParams,
Expand Down
158 changes: 158 additions & 0 deletions src/libs/actions/BankAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,163 @@ function validateBankAccount(bankAccountID: number, validateCode: string, policy
API.write(WRITE_COMMANDS.VALIDATE_BANK_ACCOUNT_WITH_TRANSACTIONS, parameters, onyxData);
}

function getCorpayBankAccountFields(country: string, currency: string) {
// TODO - Use parameters when API is ready
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const parameters = {
countryISO: country,
currency,
isWithdrawal: true,
isBusinessBankAccount: true,
};

// return API.read(READ_COMMANDS.GET_CORPAY_BANK_ACCOUNT_FIELDS, parameters);
return {
bankCountry: 'AU',
bankCurrency: 'AUD',
classification: 'Business',
destinationCountry: 'AU',
formFields: [
{
errorMessage: 'Swift must be less than 12 characters',
id: 'swiftBicCode',
isRequired: false,
isRequiredInValueSet: true,
label: 'Swift Code',
regEx: '^.{0,12}$',
validationRules: [
{
errorMessage: 'Swift must be less than 12 characters',
regEx: '^.{0,12}$',
},
{
errorMessage: 'The following characters are not allowed: <,>, "',
regEx: '^[^<>\\x22]*$',
},
],
},
{
errorMessage: 'Beneficiary Bank Name must be less than 250 characters',
id: 'bankName',
isRequired: true,
isRequiredInValueSet: true,
label: 'Bank Name',
regEx: '^.{0,250}$',
validationRules: [
{
errorMessage: 'Beneficiary Bank Name must be less than 250 characters',
regEx: '^.{0,250}$',
},
{
errorMessage: 'The following characters are not allowed: <,>, "',
regEx: '^[^<>\\x22]*$',
},
],
},
{
errorMessage: 'City must be less than 100 characters',
id: 'bankCity',
isRequired: true,
isRequiredInValueSet: true,
label: 'Bank City',
regEx: '^.{0,100}$',
validationRules: [
{
errorMessage: 'City must be less than 100 characters',
regEx: '^.{0,100}$',
},
{
errorMessage: 'The following characters are not allowed: <,>, "',
regEx: '^[^<>\\x22]*$',
},
],
},
{
errorMessage: 'Bank Address Line 1 must be less than 1000 characters',
id: 'bankAddressLine1',
isRequired: true,
isRequiredInValueSet: true,
label: 'Bank Address',
regEx: '^.{0,1000}$',
validationRules: [
{
errorMessage: 'Bank Address Line 1 must be less than 1000 characters',
regEx: '^.{0,1000}$',
},
{
errorMessage: 'The following characters are not allowed: <,>, "',
regEx: '^[^<>\\x22]*$',
},
],
},
{
detailedRule: [
{
isRequired: true,
value: [
{
errorMessage: 'Beneficiary Account Number is invalid. Value should be 1 to 50 characters long.',
regEx: '^.{1,50}$',
ruleDescription: '1 to 50 characters',
},
],
},
],
errorMessage: 'Beneficiary Account Number is invalid. Value should be 1 to 50 characters long.',
id: 'accountNumber',
isRequired: true,
isRequiredInValueSet: true,
label: 'Account Number (iACH)',
regEx: '^.{1,50}$',
validationRules: [
{
errorMessage: 'Beneficiary Account Number is invalid. Value should be 1 to 50 characters long.',
regEx: '^.{1,50}$',
ruleDescription: '1 to 50 characters',
},
{
errorMessage: 'The following characters are not allowed: <,>, "',
regEx: '^[^<>\\x22]*$',
},
],
},
{
detailedRule: [
{
isRequired: true,
value: [
{
errorMessage: 'BSB Number is invalid. Value should be exactly 6 digits long.',
regEx: '^[0-9]{6}$',
ruleDescription: 'Exactly 6 digits',
},
],
},
],
errorMessage: 'BSB Number is invalid. Value should be exactly 6 digits long.',
id: 'routingCode',
isRequired: true,
isRequiredInValueSet: true,
label: 'BSB Number',
regEx: '^[0-9]{6}$',
validationRules: [
{
errorMessage: 'BSB Number is invalid. Value should be exactly 6 digits long.',
regEx: '^[0-9]{6}$',
ruleDescription: 'Exactly 6 digits',
},
{
errorMessage: 'The following characters are not allowed: <,>, "',
regEx: '^[^<>\\x22]*$',
},
],
},
],
paymentMethods: ['E'],
preferredMethod: 'E',
};
}

function clearReimbursementAccount() {
Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null);
}
Expand Down Expand Up @@ -572,6 +729,7 @@ export {
updateAddPersonalBankAccountDraft,
clearPersonalBankAccountSetupType,
validatePlaidSelection,
getCorpayBankAccountFields,
};

export type {BusinessAddress, PersonalAddress};
Loading
Loading