From dcef0de906fa3268dc22f1bc6477fdbbbb45c542 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 25 Feb 2022 14:36:29 +0530 Subject: [PATCH 1/3] fix(pos): mode of payment disappears after save (cherry picked from commit 69c34cd7ae128dde56cde10c53b479331c33d56f) --- erpnext/accounts/doctype/pos_invoice/pos_invoice.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 2d6bef5bca5..9d585411582 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -439,7 +439,6 @@ class POSInvoice(SalesInvoice): self.paid_amount = 0 def set_account_for_mode_of_payment(self): - self.payments = [d for d in self.payments if d.amount or d.base_amount or d.default] for pay in self.payments: if not pay.account: pay.account = get_bank_cash_account(pay.mode_of_payment, self.company).get("account") From f2264fa58dedd14b7240b91233b560a80a895672 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 25 Feb 2022 15:18:06 +0530 Subject: [PATCH 2/3] fix(pos): coupon code is applied even if ignore pricing rule is check (cherry picked from commit 81514516f3c7106a5b211796bb74ddad0a6add20) # Conflicts: # erpnext/public/js/controllers/transaction.js --- erpnext/public/js/controllers/transaction.js | 15 +++++++++++ .../selling/page/point_of_sale/pos_payment.js | 25 +++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 4801b333df9..a6c223385a3 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2264,6 +2264,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, +<<<<<<< HEAD coupon_code: function() { var me = this; frappe.run_serially([ @@ -2272,6 +2273,20 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ () => this.frm.doc.ignore_pricing_rule=0, () => me.apply_pricing_rule() ]); +======= + coupon_code() { + 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 + ]); + } +>>>>>>> 81514516f3 (fix(pos): coupon code is applied even if ignore pricing rule is check) } }); diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js index 4d75e6ef1bf..1e9f6d7d920 100644 --- a/erpnext/selling/page/point_of_sale/pos_payment.js +++ b/erpnext/selling/page/point_of_sale/pos_payment.js @@ -170,17 +170,20 @@ 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) - ]); - } + 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" + }); } }); From 6bb1dccddd3ed903177aaff186a2655d89c23eb6 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 25 Feb 2022 15:45:52 +0530 Subject: [PATCH 3/3] fix: merge conflicts --- erpnext/public/js/controllers/transaction.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a6c223385a3..a89776250f2 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2264,17 +2264,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, -<<<<<<< HEAD coupon_code: function() { - 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() - ]); -======= - coupon_code() { 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; @@ -2286,7 +2276,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ () => this.frm._last_coupon_code = this.frm.doc.coupon_code ]); } ->>>>>>> 81514516f3 (fix(pos): coupon code is applied even if ignore pricing rule is check) } });