From e725fcf2b21625d16cc9ad5ea75fbff8dc037af9 Mon Sep 17 00:00:00 2001 From: ChillarAnand Date: Thu, 25 Nov 2021 16:29:47 +0530 Subject: [PATCH] fix: Validate sample quantity in lab test template --- .../healthcare/doctype/lab_test_template/lab_test_template.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/healthcare/healthcare/doctype/lab_test_template/lab_test_template.py b/healthcare/healthcare/doctype/lab_test_template/lab_test_template.py index a75c533f94..22bcfd808b 100644 --- a/healthcare/healthcare/doctype/lab_test_template/lab_test_template.py +++ b/healthcare/healthcare/doctype/lab_test_template/lab_test_template.py @@ -10,6 +10,7 @@ from frappe import _ from frappe.model.document import Document from frappe.model.rename_doc import rename_doc +from frappe.utils import flt class LabTestTemplate(Document): @@ -21,6 +22,9 @@ def validate(self): if self.is_billable and (not self.lab_test_rate or self.lab_test_rate <= 0.0): frappe.throw(_('Standard Selling Rate should be greater than zero.')) + if self.sample and flt(self.sample_qty) <= 0: + frappe.throw(_('Sample Quantity cannot be negative or 0'), title=_('Invalid Quantity')) + self.validate_conversion_factor() self.enable_disable_item()