feat: Financial Ratio Report (#36130)
* feat: Financial Ratio report added * fix: Made columns dynamic * fix: Changed fieldtype of year column * fix: Added Financial Ratios for all Fiscal Years * fix: Added Validation of only Parent Having account_type of Direct Income, Indirect Income, Current Asset and Current Liability * fix: Added 4 more ratios * fix: added a function for repeated code * fix: added account_type in accounts utils and cleaned report code * fix: created function for avg_ratio_values * fix: cleaning code * fix: basic ratios completed * fix: cleaned the code * chore: code cleanup * chore: remove comments * chore: code cleanup * chore: cleanup account query * chore: Remove unused variables --------- Co-authored-by: Ritvik Sardana <ritviksardana@Ritviks-MacBook-Air.local> Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
@@ -179,6 +179,7 @@ def get_balance_on(
|
||||
in_account_currency=True,
|
||||
cost_center=None,
|
||||
ignore_account_permission=False,
|
||||
account_type=None,
|
||||
):
|
||||
if not account and frappe.form_dict.get("account"):
|
||||
account = frappe.form_dict.get("account")
|
||||
@@ -254,6 +255,21 @@ def get_balance_on(
|
||||
else:
|
||||
cond.append("""gle.account = %s """ % (frappe.db.escape(account, percent=False),))
|
||||
|
||||
if account_type:
|
||||
accounts = frappe.db.get_all(
|
||||
"Account",
|
||||
filters={"company": company, "account_type": account_type, "is_group": 0},
|
||||
pluck="name",
|
||||
order_by="lft",
|
||||
)
|
||||
|
||||
cond.append(
|
||||
"""
|
||||
gle.account in (%s)
|
||||
"""
|
||||
% (", ".join([frappe.db.escape(account) for account in accounts]))
|
||||
)
|
||||
|
||||
if party_type and party:
|
||||
cond.append(
|
||||
"""gle.party_type = %s and gle.party = %s """
|
||||
@@ -263,7 +279,8 @@ def get_balance_on(
|
||||
if company:
|
||||
cond.append("""gle.company = %s """ % (frappe.db.escape(company, percent=False)))
|
||||
|
||||
if account or (party_type and party):
|
||||
if account or (party_type and party) or account_type:
|
||||
|
||||
if in_account_currency:
|
||||
select_field = "sum(debit_in_account_currency) - sum(credit_in_account_currency)"
|
||||
else:
|
||||
@@ -276,7 +293,6 @@ def get_balance_on(
|
||||
select_field, " and ".join(cond)
|
||||
)
|
||||
)[0][0]
|
||||
|
||||
# if bal is None, return 0
|
||||
return flt(bal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user