Skip to content

Commit

Permalink
refactor: replace direct assignment with frm.set_value in Healthcare …
Browse files Browse the repository at this point in the history
…Package
  • Loading branch information
Sajinsr committed Dec 23, 2024
1 parent 4b5c837 commit b13dc71
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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";
Expand All @@ -69,14 +69,20 @@ 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;

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);
}
}
});

Expand Down

0 comments on commit b13dc71

Please sign in to comment.