fix: check seats of a batch at the time of billing
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user