fix: check seats of a batch at the time of billing

This commit is contained in:
Jannat Patel
2025-03-20 11:03:08 +05:30
parent 04cbd6a1d8
commit 7ae3cf5d95
6 changed files with 1375 additions and 14 deletions

View File

@@ -35,7 +35,7 @@ def send_payment_reminder():
for payment in incomplete_payments:
if has_paid_later(payment):
continue
if is_batch_sold_out(payment):
continue
@@ -56,14 +56,19 @@ def has_paid_later(payment):
def is_batch_sold_out(payment):
if payment.payment_for_document_type == "LMS Batch":
seat_count = frappe.get_cached_value("LMS Batch", payment.payment_for_document, "seat_count")
number_of_students = frappe.db.count("LMS Batch Enrollment", {"batch": payment.payment_for_document})
seat_count = frappe.get_cached_value(
"LMS Batch", payment.payment_for_document, "seat_count"
)
number_of_students = frappe.db.count(
"LMS Batch Enrollment", {"batch": payment.payment_for_document}
)
if seat_count <= number_of_students:
return True
return False
def send_mail(payment):
subject = _("Complete Your Enrollment - Don't miss out!")
template = "payment_reminder"