diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index 482b7783..515aa8ce 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -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" }, { @@ -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", diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py index cebe2584..af034ec3 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.py +++ b/lms/lms/doctype/lms_batch/lms_batch.py @@ -28,6 +28,7 @@ class LMSBatch(Document): 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() @@ -64,6 +65,10 @@ class LMSBatch(Document): 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: diff --git a/lms/lms/doctype/lms_course/lms_course.py b/lms/lms/doctype/lms_course/lms_course.py index ba8b7701..e3e54a40 100644 --- a/lms/lms/doctype/lms_course/lms_course.py +++ b/lms/lms/doctype/lms_course/lms_course.py @@ -19,6 +19,7 @@ class LMSCourse(Document): 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): @@ -51,6 +52,10 @@ class LMSCourse(Document): 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()