From 485e6b6a0931c9ec9709879d878894ea8760e7ca Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 27 Mar 2022 13:02:31 +0530 Subject: [PATCH] fix: Incorrect default amount to pay for POS invoices (cherry picked from commit a044e9268786b3395f2e33fd5b79e64bc60160a5) # Conflicts: # erpnext/public/js/controllers/taxes_and_totals.js --- erpnext/public/js/controllers/taxes_and_totals.js | 9 ++++++--- erpnext/public/js/controllers/transaction.js | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 9fec43b74ef..c861ebb19df 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -34,12 +34,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { frappe.model.set_value(item.doctype, item.name, "rate", item_rate); } +<<<<<<< HEAD calculate_taxes_and_totals(update_paid_amount) { +======= + calculate_taxes_and_totals: async function(update_paid_amount) { +>>>>>>> a044e92687 (fix: Incorrect default amount to pay for POS invoices) this.discount_amount_applied = false; this._calculate_taxes_and_totals(); this.calculate_discount_amount(); - this.calculate_shipping_charges(); + await this.calculate_shipping_charges(); // Advance calculation applicable to Sales /Purchase Invoice if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype) @@ -275,8 +279,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { calculate_shipping_charges() { frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]); if (frappe.meta.get_docfield(this.frm.doc.doctype, "shipping_rule", this.frm.doc.name)) { - this.shipping_rule(); - this._calculate_taxes_and_totals(); + return this.shipping_rule(); } } diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a8cec0ad12a..25df4785c31 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1087,6 +1087,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe return this.frm.call({ doc: this.frm.doc, method: "apply_shipping_rule", + callback: function(r) { + me._calculate_taxes_and_totals(); + } }).fail(() => this.frm.set_value('shipping_rule', '')); } }