From 52dd7665e76bc57c6f46f6fed01800286be8b21f Mon Sep 17 00:00:00 2001 From: Navin-S-R Date: Sun, 1 Mar 2026 23:54:41 +0530 Subject: [PATCH] fix(gross-profit): apply precision-based rounding to grouped totals --- .../accounts/report/gross_profit/gross_profit.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/gross_profit/gross_profit.py b/erpnext/accounts/report/gross_profit/gross_profit.py index 55ab95ac662..a53c2134e3f 100644 --- a/erpnext/accounts/report/gross_profit/gross_profit.py +++ b/erpnext/accounts/report/gross_profit/gross_profit.py @@ -649,7 +649,7 @@ class GrossProfitGenerator: new_row = row self.set_average_based_on_payment_term_portion(new_row, row, invoice_portion) else: - new_row.qty += flt(row.qty) + new_row.qty = flt((new_row.qty + row.qty), self.float_precision) self.set_average_based_on_payment_term_portion(new_row, row, invoice_portion, True) new_row = self.set_average_rate(new_row) @@ -659,11 +659,17 @@ class GrossProfitGenerator: if i == 0: new_row = row else: - new_row.qty += flt(row.qty) - new_row.buying_amount += flt(row.buying_amount, self.currency_precision) - new_row.base_amount += flt(row.base_amount, self.currency_precision) + new_row.qty = flt((new_row.qty + row.qty), self.float_precision) + new_row.buying_amount = flt( + (new_row.buying_amount + row.buying_amount), self.currency_precision + ) + new_row.base_amount = flt( + (new_row.base_amount + row.base_amount), self.currency_precision + ) if self.filters.get("group_by") == "Sales Person": - new_row.allocated_amount += flt(row.allocated_amount, self.currency_precision) + new_row.allocated_amount = flt( + (new_row.allocated_amount + row.allocated_amount), self.currency_precision + ) new_row = self.set_average_rate(new_row) self.grouped_data.append(new_row)