fix: batch self enrollment

This commit is contained in:
Jannat Patel
2024-10-11 19:16:40 +05:30
parent 961d5ec77b
commit eb350c5a20
5 changed files with 49 additions and 12 deletions

View File

@@ -1702,21 +1702,23 @@ def enroll_in_course(payment_name, course):
enrollment.save(ignore_permissions=True)
def enroll_in_batch(payment_name, batch):
@frappe.whitelist()
def enroll_in_batch(batch, payment_name=None):
if not frappe.db.exists(
"Batch Student", {"parent": batch, "student": frappe.session.user}
):
student = frappe.new_doc("Batch Student")
current_count = frappe.db.count("Batch Student", {"parent": batch})
payment = frappe.db.get_value(
"LMS Payment", payment_name, ["name", "source"], as_dict=True
)
if payment_name:
payment = frappe.db.get_value(
"LMS Payment", payment_name, ["name", "source"], as_dict=True
)
student.update(
{
"student": frappe.session.user,
"payment": payment.name,
"source": payment.source,
"payment": payment.name if payment_name else None,
"source": payment.source if payment_name else None,
"parent": batch,
"parenttype": "LMS Batch",
"parentfield": "students",