mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
fix: ensure fresh grand_total_diff is used for each calculation
This commit is contained in:
@@ -398,6 +398,9 @@ class calculate_taxes_and_totals:
|
|||||||
self._calculate()
|
self._calculate()
|
||||||
|
|
||||||
def calculate_taxes(self):
|
def calculate_taxes(self):
|
||||||
|
# reset value from earlier calculations
|
||||||
|
self.grand_total_diff = 0
|
||||||
|
|
||||||
doc = self.doc
|
doc = self.doc
|
||||||
if not doc.get("taxes"):
|
if not doc.get("taxes"):
|
||||||
return
|
return
|
||||||
@@ -684,7 +687,7 @@ class calculate_taxes_and_totals:
|
|||||||
self.grand_total_diff = 0
|
self.grand_total_diff = 0
|
||||||
|
|
||||||
def calculate_totals(self):
|
def calculate_totals(self):
|
||||||
grand_total_diff = getattr(self, "grand_total_diff", 0)
|
grand_total_diff = self.grand_total_diff
|
||||||
|
|
||||||
if self.doc.get("taxes"):
|
if self.doc.get("taxes"):
|
||||||
self.doc.grand_total = flt(self.doc.get("taxes")[-1].total) + grand_total_diff
|
self.doc.grand_total = flt(self.doc.get("taxes")[-1].total) + grand_total_diff
|
||||||
|
|||||||
@@ -380,6 +380,9 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
calculate_taxes() {
|
calculate_taxes() {
|
||||||
|
// reset value from earlier calculations
|
||||||
|
this.grand_total_diff = 0;
|
||||||
|
|
||||||
const doc = this.frm.doc;
|
const doc = this.frm.doc;
|
||||||
if (!doc.taxes?.length) return;
|
if (!doc.taxes?.length) return;
|
||||||
|
|
||||||
@@ -617,6 +620,8 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
|
|
||||||
if (diff && Math.abs(diff) <= 5.0 / Math.pow(10, precision("tax_amount", last_tax))) {
|
if (diff && Math.abs(diff) <= 5.0 / Math.pow(10, precision("tax_amount", last_tax))) {
|
||||||
me.grand_total_diff = diff;
|
me.grand_total_diff = diff;
|
||||||
|
} else {
|
||||||
|
me.grand_total_diff = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -626,7 +631,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
// Changing sequence can cause rounding_adjustmentng issue and on-screen discrepency
|
// Changing sequence can cause rounding_adjustmentng issue and on-screen discrepency
|
||||||
const me = this;
|
const me = this;
|
||||||
const tax_count = this.frm.doc.taxes?.length;
|
const tax_count = this.frm.doc.taxes?.length;
|
||||||
const grand_total_diff = this.grand_total_diff || 0;
|
const grand_total_diff = this.grand_total_diff;
|
||||||
|
|
||||||
this.frm.doc.grand_total = flt(
|
this.frm.doc.grand_total = flt(
|
||||||
tax_count ? this.frm.doc["taxes"][tax_count - 1].total + grand_total_diff : this.frm.doc.net_total
|
tax_count ? this.frm.doc["taxes"][tax_count - 1].total + grand_total_diff : this.frm.doc.net_total
|
||||||
|
|||||||
Reference in New Issue
Block a user