added beneficiary deletion feature
This commit is contained in:
@@ -44,6 +44,16 @@ async function getSingleBeneficiary(customerNo, accountNo) {
|
||||
return result.rows[0];
|
||||
}
|
||||
|
||||
async function deleteBeneficiary(customerNo, beneficiaryAccountNo) {
|
||||
const queryStr =
|
||||
'DELETE FROM beneficiaries WHERE customer_no = $1 AND account_no = $2';
|
||||
const result = await db.query(queryStr, [customerNo, beneficiaryAccountNo]);
|
||||
if (result.rowCount == 0) {
|
||||
throw new Error('ACCOUNT_NOT_FOUND');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
async function getAllBeneficiaries(customerNo) {
|
||||
const queryStr =
|
||||
'SELECT b.account_no, b.name, b.account_type, b.ifsc_code, i.bank_name, i.branch_name FROM beneficiaries b JOIN ifsc_details i ON b.ifsc_code = i.ifsc_code WHERE customer_no = $1';
|
||||
@@ -66,4 +76,5 @@ module.exports = {
|
||||
validateOutsideBank,
|
||||
getAllBeneficiaries,
|
||||
getSingleBeneficiary,
|
||||
deleteBeneficiary,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user