Merge pull request #30443 from frappe/mergify/bp/develop/pr-30438

fix: Incorrect default amount to pay for POS invoices (backport #30438)
This commit is contained in:
Deepesh Garg 2022-04-10 18:56:02 +05:30 committed by GitHub
commit 0f414d51f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -34,12 +34,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
frappe.model.set_value(item.doctype, item.name, "rate", item_rate); frappe.model.set_value(item.doctype, item.name, "rate", item_rate);
} }
calculate_taxes_and_totals(update_paid_amount) { async calculate_taxes_and_totals(update_paid_amount) {
this.discount_amount_applied = false; this.discount_amount_applied = false;
this._calculate_taxes_and_totals(); this._calculate_taxes_and_totals();
this.calculate_discount_amount(); this.calculate_discount_amount();
this.calculate_shipping_charges(); await this.calculate_shipping_charges();
// Advance calculation applicable to Sales /Purchase Invoice // Advance calculation applicable to Sales /Purchase Invoice
if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype) if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype)
@ -275,8 +275,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
calculate_shipping_charges() { calculate_shipping_charges() {
frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]); 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)) { if (frappe.meta.get_docfield(this.frm.doc.doctype, "shipping_rule", this.frm.doc.name)) {
this.shipping_rule(); return this.shipping_rule();
this._calculate_taxes_and_totals();
} }
} }

View File

@ -974,6 +974,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
return this.frm.call({ return this.frm.call({
doc: this.frm.doc, doc: this.frm.doc,
method: "apply_shipping_rule", method: "apply_shipping_rule",
callback: function(r) {
me._calculate_taxes_and_totals();
}
}).fail(() => this.frm.set_value('shipping_rule', '')); }).fail(() => this.frm.set_value('shipping_rule', ''));
} }
} }