feat: added transactions record keeping feature
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { logger } = require('../util/logger');
|
const { logger } = require('../util/logger');
|
||||||
|
const {
|
||||||
|
recordInterBankTransaction,
|
||||||
|
} = require('../services/recordkeeping.service');
|
||||||
|
|
||||||
async function send(
|
async function send(
|
||||||
|
customerNo,
|
||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
amount,
|
amount,
|
||||||
@@ -20,7 +24,6 @@ async function send(
|
|||||||
stTransferAmount: amount,
|
stTransferAmount: amount,
|
||||||
stRemarks: remarks,
|
stRemarks: remarks,
|
||||||
};
|
};
|
||||||
logger.info(reqData, 'request data to be sent to IMPS server');
|
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
'http://localhost:6768/kccb/api/IMPS/Producer',
|
'http://localhost:6768/kccb/api/IMPS/Producer',
|
||||||
reqData,
|
reqData,
|
||||||
@@ -30,7 +33,17 @@ async function send(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
logger.info(response, 'response from IMPS');
|
await recordInterBankTransaction(
|
||||||
|
customerNo,
|
||||||
|
'imps',
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
ifscCode,
|
||||||
|
amount,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
response.data
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error, 'error from IMPS');
|
logger.error(error, 'error from IMPS');
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const {
|
||||||
|
recordInterBankTransaction,
|
||||||
|
} = require('../services/recordkeeping.service');
|
||||||
|
|
||||||
async function send(
|
async function send(
|
||||||
|
customerNo,
|
||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
amount,
|
amount,
|
||||||
@@ -8,6 +12,7 @@ async function send(
|
|||||||
beneficiaryName,
|
beneficiaryName,
|
||||||
remitterName
|
remitterName
|
||||||
) {
|
) {
|
||||||
|
const commission = 0;
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
'http://localhost:8690/kccb/Neftfundtransfer',
|
'http://localhost:8690/kccb/Neftfundtransfer',
|
||||||
@@ -15,7 +20,7 @@ async function send(
|
|||||||
stFromAcc: fromAccount,
|
stFromAcc: fromAccount,
|
||||||
stToAcc: toAccount,
|
stToAcc: toAccount,
|
||||||
stTranAmt: amount,
|
stTranAmt: amount,
|
||||||
stCommission: 0,
|
stCommission: commission,
|
||||||
stIfscCode: ifscCode,
|
stIfscCode: ifscCode,
|
||||||
stFullName: remitterName,
|
stFullName: remitterName,
|
||||||
stBeneName: beneficiaryName,
|
stBeneName: beneficiaryName,
|
||||||
@@ -24,6 +29,18 @@ async function send(
|
|||||||
stAddress3: '',
|
stAddress3: '',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
await recordInterBankTransaction(
|
||||||
|
customerNo,
|
||||||
|
'neft',
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
ifscCode,
|
||||||
|
amount,
|
||||||
|
commission,
|
||||||
|
beneficiaryName,
|
||||||
|
remitterName,
|
||||||
|
response.data.status
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const {
|
||||||
|
recordInterBankTransaction,
|
||||||
|
} = require('../services/recordkeeping.service');
|
||||||
|
|
||||||
async function send(
|
async function send(
|
||||||
|
customerNo,
|
||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
amount,
|
amount,
|
||||||
@@ -8,6 +12,7 @@ async function send(
|
|||||||
beneficiaryName,
|
beneficiaryName,
|
||||||
remitterName
|
remitterName
|
||||||
) {
|
) {
|
||||||
|
const commission = 0;
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
'http://localhost:8690/kccb/Rtgsfundtransfer',
|
'http://localhost:8690/kccb/Rtgsfundtransfer',
|
||||||
@@ -15,7 +20,7 @@ async function send(
|
|||||||
stFromAcc: fromAccount,
|
stFromAcc: fromAccount,
|
||||||
stToAcc: toAccount,
|
stToAcc: toAccount,
|
||||||
stTranAmt: amount,
|
stTranAmt: amount,
|
||||||
stCommission: 0,
|
stCommission: commission,
|
||||||
stIfscCode: ifscCode,
|
stIfscCode: ifscCode,
|
||||||
stFullName: remitterName,
|
stFullName: remitterName,
|
||||||
stBeneName: beneficiaryName,
|
stBeneName: beneficiaryName,
|
||||||
@@ -24,6 +29,18 @@ async function send(
|
|||||||
stAddress3: '',
|
stAddress3: '',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
await recordInterBankTransaction(
|
||||||
|
customerNo,
|
||||||
|
'rtgs',
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
ifscCode,
|
||||||
|
amount,
|
||||||
|
commission,
|
||||||
|
beneficiaryName,
|
||||||
|
remitterName,
|
||||||
|
response.data.status
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const {
|
||||||
|
recordIntraBankTransaction,
|
||||||
|
} = require('../services/recordkeeping.service');
|
||||||
|
|
||||||
async function transfer(
|
async function transfer(
|
||||||
fromAccountNo,
|
fromAccountNo,
|
||||||
toAccountNo,
|
toAccountNo,
|
||||||
toAccountType,
|
toAccountType,
|
||||||
amount,
|
amount,
|
||||||
// narration = 'transfer from mobile'
|
customerNo,
|
||||||
narration = ''
|
narration = ''
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
@@ -19,6 +22,14 @@ async function transfer(
|
|||||||
narration,
|
narration,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
await recordIntraBankTransaction(
|
||||||
|
customerNo,
|
||||||
|
fromAccountNo,
|
||||||
|
toAccountNo,
|
||||||
|
toAccountType,
|
||||||
|
amount,
|
||||||
|
response.data.status
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@@ -13,6 +13,7 @@ const impsRoute = async (req, res) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await impsController.send(
|
const result = await impsController.send(
|
||||||
|
req.user,
|
||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
amount,
|
amount,
|
||||||
|
@@ -19,6 +19,7 @@ const neftRoute = async (req, res) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await neftController.send(
|
const result = await neftController.send(
|
||||||
|
req.user,
|
||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
amount,
|
amount,
|
||||||
|
@@ -19,6 +19,7 @@ const rtgsRoute = async (req, res) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await rtgsController.send(
|
const result = await rtgsController.send(
|
||||||
|
req.user,
|
||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
amount,
|
amount,
|
||||||
|
@@ -14,7 +14,8 @@ const transferRoute = async (req, res) => {
|
|||||||
fromAccount,
|
fromAccount,
|
||||||
toAccount,
|
toAccount,
|
||||||
toAccountType,
|
toAccountType,
|
||||||
amount
|
amount,
|
||||||
|
req.user
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result.status === 'O.K.') {
|
if (result.status === 'O.K.') {
|
||||||
|
52
src/services/recordkeeping.service.js
Normal file
52
src/services/recordkeeping.service.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
const db = require('../config/db');
|
||||||
|
|
||||||
|
const recordIntraBankTransaction = async (
|
||||||
|
customerNo,
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
accountType,
|
||||||
|
amount,
|
||||||
|
status
|
||||||
|
) => {
|
||||||
|
const trxType = 'TRF';
|
||||||
|
const query =
|
||||||
|
'INSERT INTO transactions (customer_no, trx_type, from_account, to_account, to_account_type, amount, status) VALUES ($1, $2, $3, $4, $5, $6, $7)';
|
||||||
|
await db.query(query, [
|
||||||
|
customerNo,
|
||||||
|
trxType,
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
accountType,
|
||||||
|
amount,
|
||||||
|
status,
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
const recordInterBankTransaction = async (
|
||||||
|
customerNo,
|
||||||
|
trxType,
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
ifscCode,
|
||||||
|
amount,
|
||||||
|
commission,
|
||||||
|
beneficiaryName,
|
||||||
|
remitterName,
|
||||||
|
status
|
||||||
|
) => {
|
||||||
|
const query =
|
||||||
|
'INSERT INTO transactions (customer_no, trx_type, from_account, to_account, ifsc_code, amount, commission, beneficiary_name, remitter_name, status) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)';
|
||||||
|
await db.query(query, [
|
||||||
|
customerNo,
|
||||||
|
trxType,
|
||||||
|
fromAccount,
|
||||||
|
toAccount,
|
||||||
|
ifscCode,
|
||||||
|
amount,
|
||||||
|
commission,
|
||||||
|
beneficiaryName,
|
||||||
|
remitterName,
|
||||||
|
status,
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { recordIntraBankTransaction, recordInterBankTransaction };
|
Reference in New Issue
Block a user