From 1f5029c8c6ba59e6ef8e2b75200e04681700fd6c Mon Sep 17 00:00:00 2001 From: Sajin SR Date: Thu, 5 Dec 2024 15:37:45 +0530 Subject: [PATCH] refactor: replace direct assignment with frm.set_value in Healthcare Package --- .../doctype/healthcare_package/healthcare_package.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/healthcare/healthcare/doctype/healthcare_package/healthcare_package.js b/healthcare/healthcare/doctype/healthcare_package/healthcare_package.js index 05eb2c5de5..cec21b00d6 100644 --- a/healthcare/healthcare/doctype/healthcare_package/healthcare_package.js +++ b/healthcare/healthcare/doctype/healthcare_package/healthcare_package.js @@ -1,7 +1,7 @@ // Copyright (c) 2024, earthians Health Informatics Pvt. Ltd. and contributors // For license information, please see license.txt -let package_docs_filter = ["Item","Clinical Procedure Template", "Observation Template", "Therapy Type"] +let package_docs_filter = ["Item", "Clinical Procedure Template", "Observation Template", "Therapy Type"] frappe.ui.form.on("Healthcare Package", { refresh: function (frm) { @@ -53,7 +53,7 @@ frappe.ui.form.on("Healthcare Package", { frm.via_discount_percentage = true; if(frm.doc.discount_percentage && frm.doc.discount_amount) { - frm.doc.discount_amount = 0; + frm.set_value("discount_amount", 0); } let discount_field = frm.doc.apply_discount_on == "Total" ? "total_amount" : "net_total"; @@ -69,7 +69,7 @@ frappe.ui.form.on("Healthcare Package", { discount_amount: function (frm) { if (!frm.via_discount_percentage) { - frm.doc.additional_discount_percentage = 0; + frm.set_value("discount_percentage", 0); let discount_field = frm.doc.apply_discount_on == "Total" ? "total_amount" : "net_total"; var total = flt(frm.doc[discount_field]); var discount_percentage = (flt(frm.doc.discount_amount) / total) * 100; @@ -77,6 +77,12 @@ frappe.ui.form.on("Healthcare Package", { frm.set_value("discount_percentage", discount_percentage) calculate_total_payable(frm); } + }, + + package_name: function (frm) { + if (frm.doc.package_name && !frm.doc.item_code) { + frm.set_value("item_code", frm.doc.package_name); + } } });