added ifsc code validation for internal transfers

This commit is contained in:
2025-09-10 16:12:46 +05:30
parent 2516ff5f4c
commit 0d8371e3df

View File

@@ -56,17 +56,22 @@ async function deleteBeneficiary(customerNo, beneficiaryAccountNo) {
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';
'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 list = result.rows.map((row) => {
return {
const details = {
accountNo: row['account_no'],
name: row['name'],
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;