Add professor share calculation and financial reporting feature

Introduces per-class payout configuration (percentage or hourly rate,
plus an optional per-session expense allowance), pure calculation
utilities for professor payout/net profit/receivables, and a new
financial-reports API surface with per-class, per-session, and
date-range/monthly reports. Also adds full CRUD for institutional
expenses used in the range report, and wires up the new permissions
and roles. Fixes a pre-existing ReferenceError (missing
parseImportDate import) in paymentService that blocked creating
payments with dated transactions.
This commit is contained in:
2026-08-21 12:19:09 +03:30
parent 3c6eb278b0
commit 22b57eeae2
20 changed files with 1095 additions and 6 deletions
+31
View File
@@ -0,0 +1,31 @@
// /components/expenses/expenseController.js
'use strict';
const catchAsync = require('../../utils/catchAsync');
const expenseService = require('./expenseService');
const { successResponse, listResponse } = require('../../utils/apiResponse');
exports.getAll = catchAsync(async (req, res) => {
const { data, meta } = await expenseService.getAllExpenses(req.query);
return listResponse(res, 200, data, meta);
});
exports.getOne = catchAsync(async (req, res) => {
const expense = await expenseService.getExpenseById(req.params.id);
return successResponse(res, 200, 'Expense retrieved successfully', expense);
});
exports.create = catchAsync(async (req, res) => {
const expense = await expenseService.createExpense(req.body, req.user?._id);
return successResponse(res, 201, 'Expense created successfully', expense);
});
exports.update = catchAsync(async (req, res) => {
const expense = await expenseService.updateExpense(req.params.id, req.body);
return successResponse(res, 200, 'Expense updated successfully', expense);
});
exports.delete = catchAsync(async (req, res) => {
await expenseService.deleteExpense(req.params.id);
return successResponse(res, 200, 'Expense deleted successfully');
});