diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 66e04cd1e657..53fe6511b5d1 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -276,6 +276,22 @@ function updateCompanyInformationForBankAccount(bankAccount) { API.write('UpdateCompanyInformationForBankAccount', bankAccount, getVBBADataForOnyx()); } +/** + * Add beneficial owners for the bank account, accept the ACH terms and conditions and verify the accuracy of the information provided + * + * @param {Object} params + * + * // ACH Contract Step + * @param {Boolean} [params.ownsMoreThan25Percent] + * @param {Boolean} [params.hasOtherBeneficialOwners] + * @param {Boolean} [params.acceptTermsAndConditions] + * @param {Boolean} [params.certifyTrueInformation] + * @param {String} [params.beneficialOwners] + */ +function updateBeneficialOwnersForBankAccount(params) { + API.write('UpdateBeneficialOwnersForBankAccount', {...params}, getVBBADataForOnyx()); +} + /** * Create the bank account with manually entered data. * @@ -304,6 +320,7 @@ export { updatePersonalInformationForBankAccount, validateBankAccount, updateCompanyInformationForBankAccount, + updateBeneficialOwnersForBankAccount, connectBankAccountWithPlaid, updatePlaidData, }; diff --git a/src/pages/ReimbursementAccount/ACHContractStep.js b/src/pages/ReimbursementAccount/ACHContractStep.js index 743602cfa569..a5b131922ac9 100644 --- a/src/pages/ReimbursementAccount/ACHContractStep.js +++ b/src/pages/ReimbursementAccount/ACHContractStep.js @@ -4,6 +4,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; +import * as store from '../../libs/actions/ReimbursementAccount/store'; import Text from '../../components/Text'; import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; import styles from '../../styles/styles'; @@ -142,6 +143,8 @@ class ACHContractStep extends React.Component { return; } + const bankAccountID = lodashGet(store.getReimbursementAccountInSetup(), 'bankAccountID'); + // If they did not select that there are other beneficial owners, then we need to clear out the array here. The // reason we do it here is that if they filled out several beneficial owners, but then toggled the checkbox, we // want the data to remain in the form so we don't lose the user input until they submit the form. This will @@ -149,7 +152,7 @@ class ACHContractStep extends React.Component { this.setState(prevState => ({ beneficialOwners: !prevState.hasOtherBeneficialOwners ? [] : prevState.beneficialOwners, }), - () => BankAccounts.setupWithdrawalAccount({...this.state})); + () => BankAccounts.updateBeneficialOwnersForBankAccount({...this.state, beneficialOwners: JSON.stringify(this.state.beneficialOwners), bankAccountID})); } /** diff --git a/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js b/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js index 5763e0221106..e077b8668cce 100644 --- a/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js +++ b/src/pages/ReimbursementAccount/reimbursementAccountPropTypes.js @@ -28,7 +28,7 @@ export default PropTypes.shape({ error: PropTypes.string, /** Which field needs attention? */ - errorFields: PropTypes.objectOf(PropTypes.bool), + errorFields: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.bool, PropTypes.array])), /** Any additional error message to show */ errors: PropTypes.objectOf(PropTypes.string),