feat: add waitlist module, quick payment/transaction edit, and catering fee deduction from professor share
This commit is contained in:
@@ -42,9 +42,15 @@ const paymentSchema = new mongoose.Schema({
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
enum: ['pending', 'partial', 'paid', 'overdue'],
|
||||
enum: ['pending', 'partial', 'paid', 'overdue', 'cancelled', 'reverted'],
|
||||
default: 'pending'
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
enum: ['regular', 'waiting_list'],
|
||||
default: 'regular',
|
||||
index: true
|
||||
},
|
||||
notes: { type: String, trim: true, maxlength: 5000 },
|
||||
isDeleted: {
|
||||
type: Boolean,
|
||||
@@ -72,6 +78,9 @@ paymentSchema.virtual('transactions', {
|
||||
paymentSchema.pre('save', function (next) {
|
||||
this.discount = normalizeDiscount(this.discount, this.amount);
|
||||
const payable = getPayableAmount(this);
|
||||
if (this.status === 'cancelled' || this.status === 'reverted') {
|
||||
return next();
|
||||
}
|
||||
if (this.paidAmount >= payable) {
|
||||
this.status = 'paid';
|
||||
} else if (this.paidAmount > 0) {
|
||||
|
||||
Reference in New Issue
Block a user