fix: billing flow

This commit is contained in:
Jannat Patel
2023-09-21 12:52:31 +05:30
parent 3d00d96716
commit 153a8428f7
5 changed files with 34 additions and 6 deletions

View File

@@ -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)

View File

@@ -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
)