Files
gameno-api/components/financialReports/financialReportController.js
T
kavehhn e3b51a1629 feat(financial-reports): add institute-wide analytics endpoint
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.
2026-08-23 18:24:32 +03:30

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);
});