From 9c7e3ed1d6ea5027f3a66cd99d86233ff30b8b04 Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Thu, 4 Jan 2024 15:55:40 +0100 Subject: [PATCH] fix(sales): Ensure markup_percentage is strictly in range 0-100% --- erpnext/public/js/utils/sales_common.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index 7e636d7ba4e..0a4006ebe92 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -460,7 +460,7 @@ erpnext.sales_common = { } gross_profit_percentage(doc, cdt, cdn) { - if (this.frm.fields_dict["items"].grid.fields_map["gross_profit_percentage"].read_only) { + if (this.frm.fields_dict["items"]?.grid.fields_map["gross_profit_percentage"]?.read_only) { return } @@ -480,13 +480,13 @@ erpnext.sales_common = { } markup_percentage(doc, cdt, cdn) { - if (this.frm.fields_dict["items"].grid.fields_map["markup_percentage"].read_only) { - return + if (this.frm.fields_dict["items"]?.grid.fields_map["markup_percentage"]?.read_only) { + return; } if (["Sales Order", "Quotation"].includes(this.frm.doc.doctype)) { const item = locals[cdt][cdn]; - if (item.markup_percentage && item.gross_profit_calculation_rule && !erpnext.selling.do_not_update_rate) { + if (item.unit_cost_price && item.markup_percentage > 0 && item.markup_percentage < 100 && item.gross_profit_calculation_rule && !erpnext.selling.do_not_update_rate) { const rate = item.unit_cost_price / (100 - item.markup_percentage) * 100 if (flt(item.rate, precision("rate", item)) != flt(rate, precision("rate", item))) { -- GitLab