fix(pos): coupon code is applied even if ignore pricing rule is check

(cherry picked from commit 81514516f3)

# Conflicts:
#	erpnext/selling/page/point_of_sale/pos_payment.js
This commit is contained in:
Saqib Ansari 2022-02-25 15:18:06 +05:30 committed by mergify-bot
parent c75283265b
commit 823979fbcc
2 changed files with 28 additions and 7 deletions

View File

@ -2283,13 +2283,17 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
coupon_code() {
var me = this;
frappe.run_serially([
() => this.frm.doc.ignore_pricing_rule=1,
() => me.ignore_pricing_rule(),
() => this.frm.doc.ignore_pricing_rule=0,
() => me.apply_pricing_rule()
]);
if (this.frm.doc.coupon_code || this.frm._last_coupon_code) {
// reset pricing rules if coupon code is set or is unset
const _ignore_pricing_rule = this.frm.doc.ignore_pricing_rule;
return frappe.run_serially([
() => this.frm.doc.ignore_pricing_rule=1,
() => this.frm.trigger('ignore_pricing_rule'),
() => this.frm.doc.ignore_pricing_rule=_ignore_pricing_rule,
() => this.frm.trigger('apply_pricing_rule'),
() => this.frm._last_coupon_code = this.frm.doc.coupon_code
]);
}
}
};

View File

@ -170,6 +170,7 @@ erpnext.PointOfSale.Payment = class {
});
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
<<<<<<< HEAD
if (!frm.doc.ignore_pricing_rule) {
if (frm.doc.coupon_code) {
frappe.run_serially([
@ -189,6 +190,22 @@ erpnext.PointOfSale.Payment = class {
() => this.update_totals_section(frm.doc)
]);
}
=======
if (!frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
frappe.run_serially([
() => frm.doc.ignore_pricing_rule=1,
() => frm.trigger('ignore_pricing_rule'),
() => frm.doc.ignore_pricing_rule=0,
() => frm.trigger('apply_pricing_rule'),
() => frm.save(),
() => this.update_totals_section(frm.doc)
]);
} else if (frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
frappe.show_alert({
message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."),
indicator: "orange"
});
>>>>>>> 81514516f3 (fix(pos): coupon code is applied even if ignore pricing rule is check)
}
});