fix: Incorrect provisional profit and loss in balance sheet
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py
index dc1f7aa..f10a5ea 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.py
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py
@@ -120,11 +120,11 @@
opening_balance = 0
float_precision = cint(frappe.db.get_default("float_precision")) or 2
if asset:
- opening_balance = flt(asset[0].get("opening_balance", 0), float_precision)
+ opening_balance = flt(asset[-1].get("opening_balance", 0), float_precision)
if liability:
- opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision)
+ opening_balance -= flt(liability[-1].get("opening_balance", 0), float_precision)
if equity:
- opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
+ opening_balance -= flt(equity[-1].get("opening_balance", 0), float_precision)
opening_balance = flt(opening_balance, float_precision)
if opening_balance:
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 03ae0ae..db28cdf 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -282,7 +282,8 @@
total_row = {
"account_name": _("Total {0} ({1})").format(_(root_type), _(balance_must_be)),
"account": _("Total {0} ({1})").format(_(root_type), _(balance_must_be)),
- "currency": company_currency
+ "currency": company_currency,
+ "opening_balance": 0.0
}
for row in out:
@@ -294,6 +295,7 @@
total_row.setdefault("total", 0.0)
total_row["total"] += flt(row["total"])
+ total_row["opening_balance"] += row["opening_balance"]
row["total"] = ""
if "total" in total_row: