Skip to content

Commit

Permalink
Merge pull request #10994 from Expensify/nikki-refactor-beneficial-ow…
Browse files Browse the repository at this point in the history
…ners

[Refactor] Use new API Command: UpdateBeneficialOwnersForBankAccount
  • Loading branch information
MariaHCD authored Oct 17, 2022
2 parents 363d98f + 6b765e7 commit 26e0618
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -304,6 +320,7 @@ export {
updatePersonalInformationForBankAccount,
validateBankAccount,
updateCompanyInformationForBankAccount,
updateBeneficialOwnersForBankAccount,
connectBankAccountWithPlaid,
updatePlaidData,
};
5 changes: 4 additions & 1 deletion src/pages/ReimbursementAccount/ACHContractStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -142,14 +143,16 @@ 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
// prevent the data from being sent to the API
this.setState(prevState => ({
beneficialOwners: !prevState.hasOtherBeneficialOwners ? [] : prevState.beneficialOwners,
}),
() => BankAccounts.setupWithdrawalAccount({...this.state}));
() => BankAccounts.updateBeneficialOwnersForBankAccount({...this.state, beneficialOwners: JSON.stringify(this.state.beneficialOwners), bankAccountID}));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 26e0618

Please sign in to comment.