Adds GET /financial-reports/admin/analytics returning daily/weekly income trends (cash received vs. accrued session income), a multi-month received/payout/expense/profit breakdown, a per-class income-per-session leaderboard, payment-status distribution, and a due-date driven cash-flow forecast (overdue + upcoming installments) to power richer charts on the dashboard's financial reports page.
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
// /components/financialReports/financialReportController.js
|
|
'use strict';
|
|
|
|
const catchAsync = require('../../utils/catchAsync');
|
|
const financialReportService = require('./financialReportService');
|
|
const { successResponse } = require('../../utils/apiResponse');
|
|
|
|
exports.getClassReport = catchAsync(async (req, res) => {
|
|
const report = await financialReportService.getClassReport(req.params.classId);
|
|
return successResponse(res, 200, 'Class financial report retrieved successfully', report);
|
|
});
|
|
|
|
exports.getSessionReport = catchAsync(async (req, res) => {
|
|
const report = await financialReportService.getSessionReport(req.params.sessionId);
|
|
return successResponse(res, 200, 'Session financial report retrieved successfully', report);
|
|
});
|
|
|
|
exports.getRangeReport = catchAsync(async (req, res) => {
|
|
const report = await financialReportService.getRangeReport(req.query);
|
|
return successResponse(res, 200, 'Date-range financial report retrieved successfully', report);
|
|
});
|
|
|
|
exports.getAnalytics = catchAsync(async (req, res) => {
|
|
const report = await financialReportService.getAnalytics(req.query);
|
|
return successResponse(res, 200, 'Financial analytics retrieved successfully', report);
|
|
});
|