mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
Merge pull request #50289 from aerele/acc-dim-report
preserve accounting dimension filters while navigating between reports
This commit is contained in:
@@ -26,16 +26,13 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
{
|
{
|
||||||
fieldname: "cost_center",
|
fieldname: "cost_center",
|
||||||
label: __("Cost Center"),
|
label: __("Cost Center"),
|
||||||
fieldtype: "Link",
|
fieldtype: "MultiSelectList",
|
||||||
options: "Cost Center",
|
get_data: function (txt) {
|
||||||
get_query: () => {
|
return frappe.db.get_link_options("Cost Center", txt, {
|
||||||
var company = frappe.query_report.get_filter_value("company");
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
return {
|
});
|
||||||
filters: {
|
|
||||||
company: company,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_account",
|
fieldname: "party_account",
|
||||||
|
|||||||
@@ -45,16 +45,13 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
{
|
{
|
||||||
fieldname: "cost_center",
|
fieldname: "cost_center",
|
||||||
label: __("Cost Center"),
|
label: __("Cost Center"),
|
||||||
fieldtype: "Link",
|
fieldtype: "MultiSelectList",
|
||||||
options: "Cost Center",
|
get_data: function (txt) {
|
||||||
get_query: () => {
|
return frappe.db.get_link_options("Cost Center", txt, {
|
||||||
var company = frappe.query_report.get_filter_value("company");
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
return {
|
});
|
||||||
filters: {
|
|
||||||
company: company,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_type",
|
fieldname: "party_type",
|
||||||
|
|||||||
@@ -28,16 +28,13 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
{
|
{
|
||||||
fieldname: "cost_center",
|
fieldname: "cost_center",
|
||||||
label: __("Cost Center"),
|
label: __("Cost Center"),
|
||||||
fieldtype: "Link",
|
fieldtype: "MultiSelectList",
|
||||||
options: "Cost Center",
|
get_data: function (txt) {
|
||||||
get_query: () => {
|
return frappe.db.get_link_options("Cost Center", txt, {
|
||||||
var company = frappe.query_report.get_filter_value("company");
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
return {
|
});
|
||||||
filters: {
|
|
||||||
company: company,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_type",
|
fieldname: "party_type",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
|||||||
get_accounting_dimensions,
|
get_accounting_dimensions,
|
||||||
get_dimension_with_children,
|
get_dimension_with_children,
|
||||||
)
|
)
|
||||||
|
from erpnext.accounts.report.financial_statements import get_cost_centers_with_children
|
||||||
from erpnext.accounts.utils import (
|
from erpnext.accounts.utils import (
|
||||||
build_qb_match_conditions,
|
build_qb_match_conditions,
|
||||||
get_advance_payment_doctypes,
|
get_advance_payment_doctypes,
|
||||||
@@ -996,11 +997,7 @@ class ReceivablePayableReport:
|
|||||||
self.add_accounting_dimensions_filters()
|
self.add_accounting_dimensions_filters()
|
||||||
|
|
||||||
def get_cost_center_conditions(self):
|
def get_cost_center_conditions(self):
|
||||||
lft, rgt = frappe.db.get_value("Cost Center", self.filters.cost_center, ["lft", "rgt"])
|
cost_center_list = get_cost_centers_with_children(self.filters.cost_center)
|
||||||
cost_center_list = [
|
|
||||||
center.name
|
|
||||||
for center in frappe.get_list("Cost Center", filters={"lft": (">=", lft), "rgt": ("<=", rgt)})
|
|
||||||
]
|
|
||||||
self.qb_selection_filter.append(self.ple.cost_center.isin(cost_center_list))
|
self.qb_selection_filter.append(self.ple.cost_center.isin(cost_center_list))
|
||||||
|
|
||||||
def add_common_filters(self):
|
def add_common_filters(self):
|
||||||
|
|||||||
@@ -45,16 +45,13 @@ frappe.query_reports["Accounts Receivable Summary"] = {
|
|||||||
{
|
{
|
||||||
fieldname: "cost_center",
|
fieldname: "cost_center",
|
||||||
label: __("Cost Center"),
|
label: __("Cost Center"),
|
||||||
fieldtype: "Link",
|
fieldtype: "MultiSelectList",
|
||||||
options: "Cost Center",
|
get_data: function (txt) {
|
||||||
get_query: () => {
|
return frappe.db.get_link_options("Cost Center", txt, {
|
||||||
var company = frappe.query_report.get_filter_value("company");
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
return {
|
});
|
||||||
filters: {
|
|
||||||
company: company,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "party_type",
|
fieldname: "party_type",
|
||||||
|
|||||||
@@ -47,22 +47,23 @@ frappe.query_reports["Trial Balance"] = {
|
|||||||
{
|
{
|
||||||
fieldname: "cost_center",
|
fieldname: "cost_center",
|
||||||
label: __("Cost Center"),
|
label: __("Cost Center"),
|
||||||
fieldtype: "Link",
|
fieldtype: "MultiSelectList",
|
||||||
options: "Cost Center",
|
get_data: function (txt) {
|
||||||
get_query: function () {
|
return frappe.db.get_link_options("Cost Center", txt, {
|
||||||
var company = frappe.query_report.get_filter_value("company");
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
return {
|
});
|
||||||
doctype: "Cost Center",
|
|
||||||
filters: {
|
|
||||||
company: company,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
options: "Cost Center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "project",
|
fieldname: "project",
|
||||||
label: __("Project"),
|
label: __("Project"),
|
||||||
fieldtype: "Link",
|
fieldtype: "MultiSelectList",
|
||||||
|
get_data: function (txt) {
|
||||||
|
return frappe.db.get_link_options("Project", txt, {
|
||||||
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
|
});
|
||||||
|
},
|
||||||
options: "Project",
|
options: "Project",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
|||||||
from erpnext.accounts.report.financial_statements import (
|
from erpnext.accounts.report.financial_statements import (
|
||||||
filter_accounts,
|
filter_accounts,
|
||||||
filter_out_zero_value_rows,
|
filter_out_zero_value_rows,
|
||||||
|
get_cost_centers_with_children,
|
||||||
set_gl_entries_by_account,
|
set_gl_entries_by_account,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency
|
from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency
|
||||||
@@ -101,10 +102,6 @@ def get_data(filters):
|
|||||||
|
|
||||||
opening_balances = get_opening_balances(filters, ignore_is_opening)
|
opening_balances = get_opening_balances(filters, ignore_is_opening)
|
||||||
|
|
||||||
# add filter inside list so that the query in financial_statements.py doesn't break
|
|
||||||
if filters.project:
|
|
||||||
filters.project = [filters.project]
|
|
||||||
|
|
||||||
set_gl_entries_by_account(
|
set_gl_entries_by_account(
|
||||||
filters.company,
|
filters.company,
|
||||||
filters.from_date,
|
filters.from_date,
|
||||||
@@ -297,18 +294,12 @@ def get_opening_balance(
|
|||||||
opening_balance = opening_balance.where(closing_balance.voucher_type != "Period Closing Voucher")
|
opening_balance = opening_balance.where(closing_balance.voucher_type != "Period Closing Voucher")
|
||||||
|
|
||||||
if filters.cost_center:
|
if filters.cost_center:
|
||||||
lft, rgt = frappe.db.get_value("Cost Center", filters.cost_center, ["lft", "rgt"])
|
|
||||||
cost_center = frappe.qb.DocType("Cost Center")
|
|
||||||
opening_balance = opening_balance.where(
|
opening_balance = opening_balance.where(
|
||||||
closing_balance.cost_center.isin(
|
closing_balance.cost_center.isin(get_cost_centers_with_children(filters.get("cost_center")))
|
||||||
frappe.qb.from_(cost_center)
|
|
||||||
.select("name")
|
|
||||||
.where((cost_center.lft >= lft) & (cost_center.rgt <= rgt))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if filters.project:
|
if filters.project:
|
||||||
opening_balance = opening_balance.where(closing_balance.project == filters.project)
|
opening_balance = opening_balance.where(closing_balance.project.isin(filters.project))
|
||||||
|
|
||||||
if frappe.db.count("Finance Book"):
|
if frappe.db.count("Finance Book"):
|
||||||
if filters.get("include_default_book_entries"):
|
if filters.get("include_default_book_entries"):
|
||||||
|
|||||||
@@ -75,18 +75,35 @@ erpnext.financial_statements = {
|
|||||||
},
|
},
|
||||||
open_general_ledger: function (data) {
|
open_general_ledger: function (data) {
|
||||||
if (!data.account && !data.accounts) return;
|
if (!data.account && !data.accounts) return;
|
||||||
let project = $.grep(frappe.query_report.filters, function (e) {
|
let filters = frappe.query_report.filters;
|
||||||
|
|
||||||
|
let project = $.grep(filters, function (e) {
|
||||||
return e.df.fieldname == "project";
|
return e.df.fieldname == "project";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let cost_center = $.grep(filters, function (e) {
|
||||||
|
return e.df.fieldname == "cost_center";
|
||||||
|
});
|
||||||
|
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
account: data.account || data.accounts,
|
account: data.account || data.accounts,
|
||||||
company: frappe.query_report.get_filter_value("company"),
|
company: frappe.query_report.get_filter_value("company"),
|
||||||
from_date: data.from_date || data.year_start_date,
|
from_date: data.from_date || data.year_start_date,
|
||||||
to_date: data.to_date || data.year_end_date,
|
to_date: data.to_date || data.year_end_date,
|
||||||
project: project && project.length > 0 ? project[0].$input.val() : "",
|
project: project && project.length > 0 ? project[0].get_value() : "",
|
||||||
|
cost_center: cost_center && cost_center.length > 0 ? cost_center[0].get_value() : "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
filters.forEach((f) => {
|
||||||
|
if (f.df.fieldtype == "MultiSelectList") {
|
||||||
|
if (f.df.fieldname in frappe.route_options) return;
|
||||||
|
let value = f.get_value();
|
||||||
|
if (value && value.length > 0) {
|
||||||
|
frappe.route_options[f.df.fieldname] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let report = "General Ledger";
|
let report = "General Ledger";
|
||||||
|
|
||||||
if (["Payable", "Receivable"].includes(data.account_type)) {
|
if (["Payable", "Receivable"].includes(data.account_type)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user