Skip to content

Commit

Permalink
feat: add closing balance to Summen- und Saldenliste
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Dec 31, 2023
1 parent 93bc99e commit a248c9d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import frappe
from frappe import _
from frappe.query_builder.functions import Sum, Cast
from frappe.query_builder.functions import Sum, Cast, Coalesce
from pypika.terms import Case


Expand Down Expand Up @@ -81,6 +81,20 @@ def get_columns(current_month_name: str):
"width": 170,
"options": "account_currency",
},
{
"fieldname": "debit_closing_balance",
"label": _("Debit Closing Balance"),
"fieldtype": "Currency",
"width": 170,
"options": "account_currency",
},
{
"fieldname": "credit_closing_balance",
"label": _("Credit Closing Balance"),
"fieldtype": "Currency",
"width": 170,
"options": "account_currency",
},
]


Expand Down Expand Up @@ -163,6 +177,8 @@ def get_data(company: str, fy_start, month_start, month_end):
.on(sum_until_month.account == sum_in_month.account)
.left_join(opening_balance)
.on(opening_balance.account == sum_in_month.account)
.left_join(account)
.on(sum_until_month.account == account.name)
.select(
sum_in_month.account,
sum_in_month.account_currency,
Expand All @@ -172,6 +188,20 @@ def get_data(company: str, fy_start, month_start, month_end):
sum_until_month.credit,
sum_in_month.debit,
sum_in_month.credit,
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),
)
.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),
)
.else_(None)
)
)

Expand Down
2 changes: 2 additions & 0 deletions erpnext_germany/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ Debit in {0},Soll im {0},
Credit in {0},Haben im {0},
Debit Opening Balance,Soll Anfangsbestand,
Credit Opening Balance,Haben Anfangsbestand,
Debit Closing Balance,Soll Endbestand,
Credit Closing Balance,Haben Endbestand,

0 comments on commit a248c9d

Please sign in to comment.