From 153a8428f7c9621afd0ccfdd141e73788080672a Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 21 Sep 2023 12:52:31 +0530 Subject: [PATCH] fix: billing flow --- lms/lms/doctype/lms_batch/lms_batch.js | 7 ++++++- lms/lms/doctype/lms_batch/lms_batch.json | 7 ++++--- lms/public/js/common_functions.js | 1 + lms/www/batches/batch_details.py | 13 ++++++++++++- lms/www/batches/index.py | 12 +++++++++++- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lms/lms/doctype/lms_batch/lms_batch.js b/lms/lms/doctype/lms_batch/lms_batch.js index 3028e564..07e88ed3 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.js +++ b/lms/lms/doctype/lms_batch/lms_batch.js @@ -12,7 +12,12 @@ frappe.ui.form.on("LMS Batch", { }); frm.set_query("reference_doctype", "timetable", function () { - let doctypes = ["Course Lesson", "LMS Quiz", "LMS Assignment"]; + let doctypes = [ + "Course Lesson", + "LMS Quiz", + "LMS Assignment", + "LMS Live Class", + ]; return { filters: { name: ["in", doctypes], diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index 2f916303..d4e4ea6d 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -146,8 +146,9 @@ }, { "fieldname": "category", - "fieldtype": "Autocomplete", - "label": "Category" + "fieldtype": "Link", + "label": "Category", + "options": "LMS Category" }, { "fieldname": "section_break_ubxi", @@ -221,7 +222,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-09-20 11:25:10.683688", + "modified": "2023-09-20 14:40:45.940540", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index 8da2d052..59edd021 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -320,6 +320,7 @@ const open_batch_dialog = () => { label: __("Category"), fieldname: "category", options: "LMS Category", + only_select: 1, default: batch_info && batch_info.category, }, { diff --git a/lms/www/batches/batch_details.py b/lms/www/batches/batch_details.py index 91d11927..297a3bcb 100644 --- a/lms/www/batches/batch_details.py +++ b/lms/www/batches/batch_details.py @@ -1,6 +1,10 @@ import frappe from frappe import _ -from lms.lms.utils import has_course_moderator_role, has_course_evaluator_role +from lms.lms.utils import ( + has_course_moderator_role, + has_course_evaluator_role, + check_multicurrency, +) from lms.www.utils import is_student @@ -29,6 +33,13 @@ def get_context(context): as_dict=1, ) + if context.batch_info.amount and context.batch_info.currency: + amount, currency = check_multicurrency( + context.batch_info.amount, context.batch_info.currency + ) + context.batch_info.amount = amount + context.batch_info.currency = currency + context.is_moderator = has_course_moderator_role() context.is_evaluator = has_course_evaluator_role() context.is_student = is_student(batch_name) diff --git a/lms/www/batches/index.py b/lms/www/batches/index.py index 273af9d2..292d7cab 100644 --- a/lms/www/batches/index.py +++ b/lms/www/batches/index.py @@ -1,6 +1,10 @@ import frappe from frappe.utils import getdate -from lms.lms.utils import has_course_moderator_role, has_course_evaluator_role +from lms.lms.utils import ( + has_course_moderator_role, + has_course_evaluator_role, + check_multicurrency, +) def get_context(context): @@ -28,6 +32,12 @@ def get_context(context): for batch in batches: batch.student_count = frappe.db.count("Batch Student", {"parent": batch.name}) batch.course_count = frappe.db.count("Batch Course", {"parent": batch.name}) + + if batch.amount and batch.currency: + amount, currency = check_multicurrency(batch.amount, batch.currency) + batch.amount = amount + batch.currency = currency + batch.seats_left = ( batch.seat_count - batch.student_count if batch.seat_count else None )