wip : add payment report for admin
wip: add payment failure for admin
This commit is contained in:
@@ -60,6 +60,90 @@ async function inactive_users(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getTransactions(req, res) {
|
||||
const {
|
||||
trx_type,
|
||||
from_date,
|
||||
to_date,
|
||||
client,
|
||||
amount_min,
|
||||
amount_max,
|
||||
customer_no
|
||||
} = req.body;
|
||||
|
||||
if (!trx_type || !from_date || !to_date) {
|
||||
return res.status(400).json({ error: 'trx_type, from_date and to_date are required' });
|
||||
}
|
||||
|
||||
module.exports = { active_users ,inactive_users };
|
||||
try {
|
||||
const filters = {
|
||||
trx_type,
|
||||
from_date,
|
||||
to_date,
|
||||
client,
|
||||
amount_min,
|
||||
amount_max,
|
||||
customer_no
|
||||
};
|
||||
|
||||
const transactions = await reportService.getTransactions(filters);
|
||||
const transactions_list = transactions.map(u => ({
|
||||
|
||||
customer_no: u.customer_no,
|
||||
from_account: u.from_account,
|
||||
to_account: u.to_account,
|
||||
ifsc_code: u.ifsc_code,
|
||||
amount :u.amount,
|
||||
created_at :u.created_at,
|
||||
trx_type:u.trx_type,
|
||||
status: u.status,
|
||||
}));
|
||||
|
||||
res.json({ count: transactions.length, transactions_list });
|
||||
|
||||
} catch (err) {
|
||||
logger.error(err, 'failed to fetch transactions');
|
||||
res.status(500).json({ error: 'something went wrong' });
|
||||
}
|
||||
}
|
||||
|
||||
async function getFailedTransactions(req, res) {
|
||||
const {
|
||||
from_date,
|
||||
to_date,
|
||||
customer_no
|
||||
} = req.body;
|
||||
|
||||
if (!from_date || !to_date) {
|
||||
return res.status(400).json({ error: 'from_date and to_date are required' });
|
||||
}
|
||||
|
||||
try {
|
||||
const filters = {
|
||||
from_date,
|
||||
to_date,
|
||||
customer_no
|
||||
};
|
||||
|
||||
const transactions = await reportService.getFailedTransactions(filters);
|
||||
const transactions_list = transactions.map(u => ({
|
||||
|
||||
customer_no: u.customer_no,
|
||||
from_account: u.from_account,
|
||||
to_account: u.to_account,
|
||||
ifsc_code: u.ifsc_code,
|
||||
amount :u.amount,
|
||||
created_at :u.created_at,
|
||||
trx_type:u.trx_type,
|
||||
status: u.status,
|
||||
}));
|
||||
|
||||
res.json({ count: transactions.length, transactions_list });
|
||||
|
||||
} catch (err) {
|
||||
logger.error(err, 'failed to fetch transactions');
|
||||
res.status(500).json({ error: 'something went wrong' });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { active_users ,inactive_users, getTransactions ,getFailedTransactions };
|
||||
Reference in New Issue
Block a user