feat: filter based on accounting dimension in profitability analysis
This commit is contained in:
parent
ce9164ec69
commit
dd8c3d5462
@ -16,10 +16,23 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
"fieldname": "based_on",
|
"fieldname": "based_on",
|
||||||
"label": __("Based On"),
|
"label": __("Based On"),
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"options": ["Cost Center", "Project"],
|
"options": ["Cost Center", "Project", "Accounting Dimension"],
|
||||||
"default": "Cost Center",
|
"default": "Cost Center",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "accounting_dimension",
|
||||||
|
"label": __("Accounting Dimension"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Accounting Dimension",
|
||||||
|
"get_query": () =>{
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
"disabled": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "fiscal_year",
|
"fieldname": "fiscal_year",
|
||||||
"label": __("Fiscal Year"),
|
"label": __("Fiscal Year"),
|
||||||
|
@ -16,8 +16,8 @@ value_fields = ("income", "expense", "gross_profit_loss")
|
|||||||
|
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters.get("based_on"):
|
if filters.get("based_on") == "Accounting Dimension" and not filters.get("accounting_dimension"):
|
||||||
filters["based_on"] = "Cost Center"
|
frappe.throw(_("Select Accounting Dimension."))
|
||||||
|
|
||||||
based_on = filters.based_on.replace(" ", "_").lower()
|
based_on = filters.based_on.replace(" ", "_").lower()
|
||||||
validate_filters(filters)
|
validate_filters(filters)
|
||||||
@ -37,6 +37,8 @@ def get_accounts_data(based_on, company):
|
|||||||
)
|
)
|
||||||
elif based_on == "project":
|
elif based_on == "project":
|
||||||
return frappe.get_all("Project", fields=["name"], filters={"company": company}, order_by="name")
|
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:
|
else:
|
||||||
filters = {}
|
filters = {}
|
||||||
doctype = frappe.unscrub(based_on)
|
doctype = frappe.unscrub(based_on)
|
||||||
@ -60,7 +62,9 @@ def get_data(accounts, filters, based_on):
|
|||||||
filters.get("company"),
|
filters.get("company"),
|
||||||
filters.get("from_date"),
|
filters.get("from_date"),
|
||||||
filters.get("to_date"),
|
filters.get("to_date"),
|
||||||
based_on,
|
based_on
|
||||||
|
if based_on != "accounting_dimension"
|
||||||
|
else filters.accounting_dimension.replace(" ", "_").lower(),
|
||||||
gl_entries_by_account,
|
gl_entries_by_account,
|
||||||
ignore_closing_entries=not flt(filters.get("with_period_closing_entry")),
|
ignore_closing_entries=not flt(filters.get("with_period_closing_entry")),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user