added ifsc code validation for internal transfers
This commit is contained in:
@@ -56,17 +56,22 @@ async function deleteBeneficiary(customerNo, beneficiaryAccountNo) {
|
|||||||
|
|
||||||
async function getAllBeneficiaries(customerNo) {
|
async function getAllBeneficiaries(customerNo) {
|
||||||
const queryStr =
|
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';
|
'SELECT b.account_no, b.name, b.account_type, b.ifsc_code, i.bank_name, i.branch_name FROM beneficiaries b JOIN LATERAL( SELECT * FROM ifsc_details i WHERE i.ifsc_code = b.ifsc_code LIMIT 1 ) i ON true WHERE customer_no = $1';
|
||||||
const result = await db.query(queryStr, [customerNo]);
|
const result = await db.query(queryStr, [customerNo]);
|
||||||
const list = result.rows.map((row) => {
|
const list = result.rows.map((row) => {
|
||||||
return {
|
const details = {
|
||||||
accountNo: row['account_no'],
|
accountNo: row['account_no'],
|
||||||
name: row['name'],
|
name: row['name'],
|
||||||
accountType: row['account_type'],
|
accountType: row['account_type'],
|
||||||
ifscCode: row['ifsc_code'],
|
|
||||||
bankName: row['bank_name'],
|
|
||||||
branchName: row['branch_name'],
|
|
||||||
};
|
};
|
||||||
|
if (row['ifsc_code'] === '_') {
|
||||||
|
details['bankName'] = 'THE KANGRA CENTRAL COOPERATIVE BANK LIMITED';
|
||||||
|
} else {
|
||||||
|
details['ifscCode'] = row['ifsc_code'];
|
||||||
|
details['bankName'] = row['bank_name'];
|
||||||
|
details['branchName'] = row['branch_name'];
|
||||||
|
}
|
||||||
|
return details;
|
||||||
});
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
Reference in New Issue
Block a user