fix: coupon code is applied even if ignore_pricing_rule is enabled

This commit is contained in:
Saqib Ansari 2022-02-17 15:59:12 +05:30
parent d9fc3f3d90
commit 2743999785
2 changed files with 29 additions and 14 deletions

View File

@ -2284,20 +2284,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
coupon_code() { coupon_code() {
var me = this; var me = this;
if (this.frm.doc.coupon_code) { frappe.run_serially([
frappe.run_serially([ () => this.frm.doc.ignore_pricing_rule=1,
() => this.frm.doc.ignore_pricing_rule=1, () => me.ignore_pricing_rule(),
() => me.ignore_pricing_rule(), () => this.frm.doc.ignore_pricing_rule=0,
() => this.frm.doc.ignore_pricing_rule=0, () => me.apply_pricing_rule()
() => me.apply_pricing_rule(), ]);
() => this.frm.save()
]);
} else {
frappe.run_serially([
() => this.frm.doc.ignore_pricing_rule=1,
() => me.ignore_pricing_rule()
]);
}
} }
}; };

View File

@ -169,6 +169,29 @@ erpnext.PointOfSale.Payment = class {
} }
}); });
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
if (!frm.doc.ignore_pricing_rule) {
if (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 {
frappe.run_serially([
() => frm.doc.ignore_pricing_rule=1,
() => frm.trigger('ignore_pricing_rule'),
() => frm.doc.ignore_pricing_rule=0,
() => frm.save(),
() => this.update_totals_section(frm.doc)
]);
}
}
});
this.setup_listener_for_payments(); this.setup_listener_for_payments();
this.$payment_modes.on('click', '.shortcut', function() { this.$payment_modes.on('click', '.shortcut', function() {