Skip to content

Commit

Permalink
Merge pull request #1068 from pateljannat/payment-issues
Browse files Browse the repository at this point in the history
fix: batch enrollment after payment completion
  • Loading branch information
pateljannat authored Oct 17, 2024
2 parents 9c90756 + 49a765a commit 5f43e67
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lms/lms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ def update_payment_record(doctype, docname):
if doctype == "LMS Course":
enroll_in_course(data.payment, docname)
else:
enroll_in_batch(data.payment, docname)
enroll_in_batch(docname, data.payment)
except Exception as e:
frappe.log_error(frappe.get_traceback(), _("Enrollment Failed"))

Expand Down Expand Up @@ -1709,20 +1709,26 @@ def enroll_in_batch(batch, payment_name=None):
):
student = frappe.new_doc("Batch Student")
current_count = frappe.db.count("Batch Student", {"parent": batch})
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 if payment_name else None,
"source": payment.source if payment_name else None,
"parent": batch,
"parenttype": "LMS Batch",
"parentfield": "students",
"idx": current_count + 1,
}
)

if payment_name:
payment = frappe.db.get_value(
"LMS Payment", payment_name, ["name", "source"], as_dict=True
)
student.update(
{
"payment": payment.name,
"source": payment.source,
}
)

student.save(ignore_permissions=True)

0 comments on commit 5f43e67

Please sign in to comment.