fix: hide and reset discount control on new POS order

(cherry picked from commit 5b0053f8dd)
This commit is contained in:
ljain112
2024-09-11 18:54:55 +05:30
committed by Mergify
parent a6a2b2daae
commit 42494db3c7

View File

@@ -389,28 +389,14 @@ erpnext.PointOfSale.ItemCart = class {
placeholder: discount ? discount + "%" : __("Enter discount percentage."), placeholder: discount ? discount + "%" : __("Enter discount percentage."),
input_class: "input-xs", input_class: "input-xs",
onchange: function () { onchange: function () {
if (flt(this.value) != 0) { this.value = flt(this.value);
frappe.model.set_value( frappe.model.set_value(
frm.doc.doctype, frm.doc.doctype,
frm.doc.name, frm.doc.name,
"additional_discount_percentage", "additional_discount_percentage",
flt(this.value) flt(this.value)
); );
me.hide_discount_control(this.value); me.hide_discount_control(this.value);
} else {
frappe.model.set_value(
frm.doc.doctype,
frm.doc.name,
"additional_discount_percentage",
0
);
me.$add_discount_elem.css({
border: "1px dashed var(--gray-500)",
padding: "var(--padding-sm) var(--padding-md)",
});
me.$add_discount_elem.html(`${me.get_discount_icon()} ${__("Add Discount")}`);
me.discount_field = undefined;
}
}, },
}, },
parent: this.$add_discount_elem.find(".add-discount-field"), parent: this.$add_discount_elem.find(".add-discount-field"),
@@ -421,9 +407,13 @@ erpnext.PointOfSale.ItemCart = class {
} }
hide_discount_control(discount) { hide_discount_control(discount) {
if (!discount) { if (!flt(discount)) {
this.$add_discount_elem.css({ padding: "0px", border: "none" }); this.$add_discount_elem.css({
this.$add_discount_elem.html(`<div class="add-discount-field"></div>`); border: "1px dashed var(--gray-500)",
padding: "var(--padding-sm) var(--padding-md)",
});
this.$add_discount_elem.html(`${this.get_discount_icon()} ${__("Add Discount")}`);
this.discount_field = undefined;
} else { } else {
this.$add_discount_elem.css({ this.$add_discount_elem.css({
border: "1px dashed var(--dark-green-500)", border: "1px dashed var(--dark-green-500)",
@@ -1051,6 +1041,7 @@ erpnext.PointOfSale.ItemCart = class {
this.highlight_checkout_btn(false); this.highlight_checkout_btn(false);
} }
this.hide_discount_control(frm.doc.additional_discount_percentage);
this.update_totals_section(frm); this.update_totals_section(frm);
if (frm.doc.docstatus === 1) { if (frm.doc.docstatus === 1) {