fix: trial balance opening balance not showing in the debit side for the liability account (#17944)
This commit is contained in:
parent
122cdaf87b
commit
a030138df8
@ -180,20 +180,28 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances, filters,
|
|||||||
|
|
||||||
if d["root_type"] == "Asset" or d["root_type"] == "Equity" or d["root_type"] == "Expense":
|
if d["root_type"] == "Asset" or d["root_type"] == "Equity" or d["root_type"] == "Expense":
|
||||||
d["opening_debit"] -= d["opening_credit"]
|
d["opening_debit"] -= d["opening_credit"]
|
||||||
d["opening_credit"] = 0.0
|
d["closing_debit"] -= d["closing_credit"]
|
||||||
total_row["opening_debit"] += d["opening_debit"]
|
|
||||||
|
# For opening
|
||||||
|
check_opening_closing_has_negative_value(d, "opening_debit", "opening_credit")
|
||||||
|
|
||||||
|
# For closing
|
||||||
|
check_opening_closing_has_negative_value(d, "closing_debit", "closing_credit")
|
||||||
|
|
||||||
if d["root_type"] == "Liability" or d["root_type"] == "Income":
|
if d["root_type"] == "Liability" or d["root_type"] == "Income":
|
||||||
d["opening_credit"] -= d["opening_debit"]
|
d["opening_credit"] -= d["opening_debit"]
|
||||||
d["opening_debit"] = 0.0
|
|
||||||
total_row["opening_credit"] += d["opening_credit"]
|
|
||||||
if d["root_type"] == "Asset" or d["root_type"] == "Equity" or d["root_type"] == "Expense":
|
|
||||||
d["closing_debit"] -= d["closing_credit"]
|
|
||||||
d["closing_credit"] = 0.0
|
|
||||||
total_row["closing_debit"] += d["closing_debit"]
|
|
||||||
if d["root_type"] == "Liability" or d["root_type"] == "Income":
|
|
||||||
d["closing_credit"] -= d["closing_debit"]
|
d["closing_credit"] -= d["closing_debit"]
|
||||||
d["closing_debit"] = 0.0
|
|
||||||
total_row["closing_credit"] += d["closing_credit"]
|
# For opening
|
||||||
|
check_opening_closing_has_negative_value(d, "opening_credit", "opening_debit")
|
||||||
|
|
||||||
|
# For closing
|
||||||
|
check_opening_closing_has_negative_value(d, "closing_credit", "closing_debit")
|
||||||
|
|
||||||
|
total_row["opening_debit"] += d["opening_debit"]
|
||||||
|
total_row["closing_debit"] += d["closing_debit"]
|
||||||
|
total_row["opening_credit"] += d["opening_credit"]
|
||||||
|
total_row["closing_credit"] += d["closing_credit"]
|
||||||
|
|
||||||
return total_row
|
return total_row
|
||||||
|
|
||||||
@ -219,8 +227,6 @@ def prepare_data(accounts, filters, total_row, parent_children_map, company_curr
|
|||||||
if d.account_number else d.account_name)
|
if d.account_number else d.account_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_opening_and_closing(d)
|
|
||||||
|
|
||||||
for key in value_fields:
|
for key in value_fields:
|
||||||
row[key] = flt(d.get(key, 0.0), 3)
|
row[key] = flt(d.get(key, 0.0), 3)
|
||||||
|
|
||||||
@ -295,22 +301,11 @@ def get_columns():
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def prepare_opening_and_closing(d):
|
def check_opening_closing_has_negative_value(d, dr_or_cr, switch_to_column):
|
||||||
d["closing_debit"] = d["opening_debit"] + d["debit"]
|
# If opening debit has negetive value then move it to opening credit and vice versa.
|
||||||
d["closing_credit"] = d["opening_credit"] + d["credit"]
|
|
||||||
|
|
||||||
if d["root_type"] == "Asset" or d["root_type"] == "Equity" or d["root_type"] == "Expense":
|
if d[dr_or_cr] < 0:
|
||||||
d["opening_debit"] -= d["opening_credit"]
|
d[switch_to_column] = abs(d[dr_or_cr])
|
||||||
d["opening_credit"] = 0.0
|
d[dr_or_cr] = 0.0
|
||||||
|
else:
|
||||||
if d["root_type"] == "Liability" or d["root_type"] == "Income":
|
d[switch_to_column] = 0.0
|
||||||
d["opening_credit"] -= d["opening_debit"]
|
|
||||||
d["opening_debit"] = 0.0
|
|
||||||
|
|
||||||
if d["root_type"] == "Asset" or d["root_type"] == "Equity" or d["root_type"] == "Expense":
|
|
||||||
d["closing_debit"] -= d["closing_credit"]
|
|
||||||
d["closing_credit"] = 0.0
|
|
||||||
|
|
||||||
if d["root_type"] == "Liability" or d["root_type"] == "Income":
|
|
||||||
d["closing_credit"] -= d["closing_debit"]
|
|
||||||
d["closing_debit"] = 0.0
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user