integrated acct statement with date range filter
This commit is contained in:
@@ -21,5 +21,27 @@ async function getLastTen(accountNumber) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getLastTen };
|
||||
async function getFiltered(accountNumber, fromDate, toDate) {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`http://localhost:8688/kccb/cbs/montlyacctstmt/details`,
|
||||
{
|
||||
params: { stacctno: accountNumber, fromdate: fromDate, todate: toDate },
|
||||
}
|
||||
);
|
||||
const transactions = response.data;
|
||||
const processedTransactions = transactions.map((tx) => ({
|
||||
id: tx.stTransactionNumber,
|
||||
name: tx.stTransactionDesc,
|
||||
date: tx.stTransactionDate,
|
||||
amount: tx.stTransactionAmount.slice(0, -3),
|
||||
type: tx.stTransactionAmount.slice(-2),
|
||||
}));
|
||||
return processedTransactions;
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
'API call failde: ' + (error.response?.data?.message || error.message)
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = { getLastTen, getFiltered };
|
||||
|
Reference in New Issue
Block a user