From da4e43b8bc544cbb67ce270e2af971925c2b63d1 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 25c434fb02b0df5f3dcdd57cd033534345d82c0d 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 e742ae9a890..b5778e881b9 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2263,6 +2263,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, +<<<<<<< HEAD coupon_code: function() { var me = this; frappe.run_serially([ @@ -2271,6 +2272,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 3525f0e5856223fea6e95c15a584d418d40537dc Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Mon, 7 Mar 2022 11:52:16 +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 b5778e881b9..c89e93e97f0 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2263,17 +2263,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; @@ -2285,7 +2275,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) } });