Skip to content

Commit

Permalink
fix: validate amount and currency for paid courses and batches
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Nov 18, 2024
1 parent dcf5c72 commit 1ecbc2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lms/lms/doctype/lms_batch/lms_batch.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@
"depends_on": "paid_batch",
"fieldname": "amount",
"fieldtype": "Currency",
"label": "Amount"
"label": "Amount",
"mandatory_depends_on": "paid_batch"
},
{
"depends_on": "paid_batch",
"fieldname": "currency",
"fieldtype": "Link",
"label": "Currency",
"mandatory_depends_on": "paid_batch",
"options": "Currency"
},
{
Expand Down Expand Up @@ -328,7 +330,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-07-18 18:06:37.229885",
"modified": "2024-11-18 16:28:41.336928",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch",
Expand Down
5 changes: 5 additions & 0 deletions lms/lms/doctype/lms_batch/lms_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def validate(self):
self.validate_duplicate_courses()
self.validate_duplicate_students()
self.validate_payments_app()
self.validate_amount_and_currency()
self.validate_duplicate_assessments()
self.validate_membership()
self.validate_timetable()
Expand Down Expand Up @@ -64,6 +65,10 @@ def validate_payments_app(self):
if "payments" not in installed_apps:
frappe.throw(_("Please install the Payments app to create a paid batches."))

def validate_amount_and_currency(self):
if self.paid_batch and (not self.amount or not self.currency):
frappe.throw(_("Amount and currency are required for paid batches."))

def validate_duplicate_assessments(self):
assessments = [row.assessment_name for row in self.assessment]
for assessment in self.assessment:
Expand Down
5 changes: 5 additions & 0 deletions lms/lms/doctype/lms_course/lms_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def validate(self):
self.validate_video_link()
self.validate_status()
self.validate_payments_app()
self.validate_amount_and_currency()
self.image = validate_image(self.image)

def validate_published(self):
Expand Down Expand Up @@ -51,6 +52,10 @@ def validate_payments_app(self):
if "payments" not in installed_apps:
frappe.throw(_("Please install the Payments app to create a paid courses."))

def validate_amount_and_currency(self):
if self.paid_course and (not self.amount and not self.currency):
frappe.throw(_("Amount and currency are required for paid courses."))

def on_update(self):
if not self.upcoming and self.has_value_changed("upcoming"):
self.send_email_to_interested_users()
Expand Down

0 comments on commit 1ecbc2e

Please sign in to comment.