Skip to content

Commit

Permalink
feat: filter based on accounting dimension in profitability analysis
Browse files Browse the repository at this point in the history
(cherry picked from commit dd8c3d5)
  • Loading branch information
GursheenK authored and mergify[bot] committed Jul 25, 2023
1 parent dc69f47 commit ba95df2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
"fieldname": "based_on",
"label": __("Based On"),
"fieldtype": "Select",
"options": ["Cost Center", "Project"],
"options": ["Cost Center", "Project", "Accounting Dimension"],
"default": "Cost Center",
"reqd": 1
},
{
"fieldname": "accounting_dimension",
"label": __("Accounting Dimension"),
"fieldtype": "Link",
"options": "Accounting Dimension",
"get_query": () =>{
return {
filters: {
"disabled": 0
}
}
}
},
{
"fieldname": "fiscal_year",
"label": __("Fiscal Year"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


def execute(filters=None):
if not filters.get("based_on"):
filters["based_on"] = "Cost Center"
if filters.get("based_on") == "Accounting Dimension" and not filters.get("accounting_dimension"):
frappe.throw(_("Select Accounting Dimension."))

based_on = filters.based_on.replace(" ", "_").lower()
validate_filters(filters)
Expand All @@ -37,6 +37,8 @@ def get_accounts_data(based_on, company):
)
elif based_on == "project":
return frappe.get_all("Project", fields=["name"], filters={"company": company}, order_by="name")
elif based_on == "accounting_dimension":
return frappe.get_all("Accounting Dimension", fields=["name"], order_by="name")
else:
filters = {}
doctype = frappe.unscrub(based_on)
Expand All @@ -60,7 +62,9 @@ def get_data(accounts, filters, based_on):
filters.get("company"),
filters.get("from_date"),
filters.get("to_date"),
based_on,
based_on
if based_on != "accounting_dimension"
else filters.accounting_dimension.replace(" ", "_").lower(),
gl_entries_by_account,
ignore_closing_entries=not flt(filters.get("with_period_closing_entry")),
)
Expand Down

0 comments on commit ba95df2

Please sign in to comment.