fix: ensure fresh grand_total_diff is used for each calculation

(cherry picked from commit b3fdef8d19)
This commit is contained in:
Sagar Vora
2025-12-11 17:48:37 +05:30
committed by Mergify
parent 857ab70f4e
commit 2d198e698a
2 changed files with 10 additions and 2 deletions

View File

@@ -378,6 +378,9 @@ class calculate_taxes_and_totals:
self._calculate()
def calculate_taxes(self):
# reset value from earlier calculations
self.grand_total_diff = 0
doc = self.doc
if not doc.get("taxes"):
return
@@ -587,7 +590,7 @@ class calculate_taxes_and_totals:
self.grand_total_diff = 0
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"):
self.doc.grand_total = flt(self.doc.get("taxes")[-1].total) + grand_total_diff