From 559b1eade95ebc63f6e94c9f2a25966a27da1068 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:28:42 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20closing=20balance=20in=20report=20?= =?UTF-8?q?=E2=80=9ESummen-=20un=20Saldenliste=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../summen__und_saldenliste.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/erpnext_germany/erpnext_germany/report/summen__und_saldenliste/summen__und_saldenliste.py b/erpnext_germany/erpnext_germany/report/summen__und_saldenliste/summen__und_saldenliste.py index ea85a06..ea0f875 100644 --- a/erpnext_germany/erpnext_germany/report/summen__und_saldenliste/summen__und_saldenliste.py +++ b/erpnext_germany/erpnext_germany/report/summen__und_saldenliste/summen__und_saldenliste.py @@ -178,7 +178,7 @@ def get_data(company: str, fy_start, month_start, month_end): .left_join(opening_balance) .on(opening_balance.account == sum_in_month.account) .left_join(account) - .on(sum_until_month.account == account.name) + .on(sum_in_month.account == account.name) .select( sum_in_month.account, sum_in_month.account_currency, @@ -191,17 +191,33 @@ def get_data(company: str, fy_start, month_start, month_end): Case() .when( account.root_type.isin(("Asset", "Expense")), - (Coalesce(opening_balance.debit, 0) + sum_until_month.debit + sum_in_month.debit) - - (Coalesce(opening_balance.credit, 0) + sum_until_month.credit + sum_in_month.credit), + ( + Coalesce(opening_balance.debit, 0) + + Coalesce(sum_until_month.debit, 0) + + Coalesce(sum_in_month.debit, 0) + ) + - ( + Coalesce(opening_balance.credit, 0) + + Coalesce(sum_until_month.credit, 0) + + Coalesce(sum_in_month.credit, 0) + ), ) .else_(None), Case() .when( account.root_type.isin(("Liability", "Equity", "Income")), - (Coalesce(opening_balance.credit, 0) + sum_until_month.credit + sum_in_month.credit) - - (Coalesce(opening_balance.debit, 0) + sum_until_month.debit + sum_in_month.debit), + ( + Coalesce(opening_balance.credit, 0) + + Coalesce(sum_until_month.credit, 0) + + Coalesce(sum_in_month.credit, 0) + ) + - ( + Coalesce(opening_balance.debit, 0) + + Coalesce(sum_until_month.debit, 0) + + Coalesce(sum_in_month.debit, 0) + ), ) - .else_(None) + .else_(None), ) )