From 1dab195560021347c2edfae4ffcedc93be647868 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Fri, 29 Sep 2023 18:20:02 +0530 Subject: [PATCH 1/2] fix: add only float row values for total --- .../accounts_receivable_summary.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py index cffc87895e..f89841523a 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py @@ -99,13 +99,11 @@ class AccountsReceivableSummary(ReceivablePayableReport): # Add all amount columns for k in list(self.party_total[d.party]): - if k not in ["currency", "sales_person"]: - - self.party_total[d.party][k] += d.get(k, 0.0) + if type(self.party_total[d.party][k]) == float: + self.party_total[d.party][k] += d.get(k) or 0.0 # set territory, customer_group, sales person etc self.set_party_details(d) - self.party_total[d.party].update({"party_type": d.party_type}) def init_party_total(self, row): self.party_total.setdefault( @@ -124,6 +122,7 @@ class AccountsReceivableSummary(ReceivablePayableReport): "total_due": 0.0, "future_amount": 0.0, "sales_person": [], + "party_type": row.party_type, } ), ) @@ -133,13 +132,12 @@ class AccountsReceivableSummary(ReceivablePayableReport): for key in ("territory", "customer_group", "supplier_group"): if row.get(key): - self.party_total[row.party][key] = row.get(key) - + self.party_total[row.party][key] = row.get(key, "") if row.sales_person: - self.party_total[row.party].sales_person.append(row.sales_person) + self.party_total[row.party].sales_person.append(row.get("sales_person", "")) if self.filters.sales_partner: - self.party_total[row.party]["default_sales_partner"] = row.get("default_sales_partner") + self.party_total[row.party]["default_sales_partner"] = row.get("default_sales_partner", "") def get_columns(self): self.columns = [] From 67440c38aef1f94432c0ec97f9bef065363d3a1b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 3 Oct 2023 17:38:43 +0530 Subject: [PATCH 2/2] refactor: use `isinstance` over `type` --- .../accounts_receivable_summary/accounts_receivable_summary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py index f89841523a..60274cd8b1 100644 --- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py +++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py @@ -99,7 +99,7 @@ class AccountsReceivableSummary(ReceivablePayableReport): # Add all amount columns for k in list(self.party_total[d.party]): - if type(self.party_total[d.party][k]) == float: + if isinstance(self.party_total[d.party][k], float): self.party_total[d.party][k] += d.get(k) or 0.0 # set territory, customer_group, sales person etc