feat: add waitlist module, quick payment/transaction edit, and catering fee deduction from professor share

This commit is contained in:
2026-08-23 23:00:02 +03:30
parent e3b51a1629
commit 53fce86ad5
21 changed files with 609 additions and 16 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ const sanitizeNotes = (notes) => {
const rialsToToman = (value) => Math.floor(toNonNegativeNumber(value) / 10);
const isCancelledTransaction = (trx = {}) => String(trx.status || '').toLowerCase() === 'cancelled';
const isCancelledTransaction = (trx = {}) => ['cancelled', 'reverted'].includes(String(trx.status || '').toLowerCase());
const isPaidTransaction = (trx = {}) => {
if (isCancelledTransaction(trx)) return false;
+5 -2
View File
@@ -48,9 +48,12 @@ const resolveSessionDurationHours = (cls = {}) => {
/**
* Model A — percentage of class revenue.
* `revenue` is the amount the percentage should be applied to (e.g. actual received revenue).
* `serviceFeePerPerson` (catering / service expenses per student) is deducted first before calculating the professor share.
*/
const calculatePercentageShare = ({ payoutPercentage = 0, revenue = 0 } = {}) => {
return (toPercentage(payoutPercentage) / 100) * toNonNegativeNumber(revenue);
const calculatePercentageShare = ({ payoutPercentage = 0, revenue = 0, serviceFeePerPerson = 0, studentsCount = 0 } = {}) => {
const totalServiceFee = toNonNegativeNumber(serviceFeePerPerson) * toNonNegativeNumber(studentsCount);
const netRevenue = Math.max(0, toNonNegativeNumber(revenue) - totalServiceFee);
return (toPercentage(payoutPercentage) / 100) * netRevenue;
};
/**
+15
View File
@@ -52,6 +52,21 @@ describe('calculatePercentageShare (Model A)', () => {
assert.equal(calculatePercentageShare({ payoutPercentage: 40, revenue: 10_000_000 }), 4_000_000);
});
it('deducts serviceFeePerPerson * studentsCount from revenue before calculating percentage', () => {
// 2 students with 10M tuition (revenue = 20M), serviceFeePerPerson = 400,000, 50% payout
// Net revenue = 20M - (400,000 * 2) = 19,200,000
// Professor share = 19,200,000 * 50% = 9,600,000
assert.equal(
calculatePercentageShare({
payoutPercentage: 50,
revenue: 20_000_000,
serviceFeePerPerson: 400_000,
studentsCount: 2
}),
9_600_000
);
});
it('clamps percentage above 100 and negative revenue to zero', () => {
assert.equal(calculatePercentageShare({ payoutPercentage: 150, revenue: 1_000_000 }), 1_000_000);
assert.equal(calculatePercentageShare({ payoutPercentage: 40, revenue: -500 }), 0);