b2604d1f77
Prior to this commit, custom Accounting Dimensions are not (by default) shown or even considered in generating a General Ledger report. Moreover, as they are not considered, they are not used to distinguish GL Entry lines in the same voucher with the same Account when the "Group By" value is "Group by Voucher (Consolidated)". This situation leads to lines with different values for the accounting dimension to be ganged together in the General Ledger view of a Journal entry, making the entry difficult for an accountant to read. This commit alleviates the problem by adding a checkbox to control whether Accounting Dimension columns are considered in the General Ledger report. When they are considered, they are displayed and also included in the key that distinguishes lines in the "Group by Voucher (Consolidated)" mode. Resolves #23033.
175 lines
4.3 KiB
JavaScript
175 lines
4.3 KiB
JavaScript
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
|
// License: GNU General Public License v3. See license.txt
|
|
|
|
frappe.query_reports["General Ledger"] = {
|
|
"filters": [
|
|
{
|
|
"fieldname":"company",
|
|
"label": __("Company"),
|
|
"fieldtype": "Link",
|
|
"options": "Company",
|
|
"default": frappe.defaults.get_user_default("Company"),
|
|
"reqd": 1
|
|
},
|
|
{
|
|
"fieldname":"finance_book",
|
|
"label": __("Finance Book"),
|
|
"fieldtype": "Link",
|
|
"options": "Finance Book"
|
|
},
|
|
{
|
|
"fieldname":"from_date",
|
|
"label": __("From Date"),
|
|
"fieldtype": "Date",
|
|
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
|
"reqd": 1,
|
|
"width": "60px"
|
|
},
|
|
{
|
|
"fieldname":"to_date",
|
|
"label": __("To Date"),
|
|
"fieldtype": "Date",
|
|
"default": frappe.datetime.get_today(),
|
|
"reqd": 1,
|
|
"width": "60px"
|
|
},
|
|
{
|
|
"fieldname":"account",
|
|
"label": __("Account"),
|
|
"fieldtype": "Link",
|
|
"options": "Account",
|
|
"get_query": function() {
|
|
var company = frappe.query_report.get_filter_value('company');
|
|
return {
|
|
"doctype": "Account",
|
|
"filters": {
|
|
"company": company,
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"fieldname":"voucher_no",
|
|
"label": __("Voucher No"),
|
|
"fieldtype": "Data",
|
|
on_change: function() {
|
|
frappe.query_report.set_filter_value('group_by', "Group by Voucher (Consolidated)");
|
|
}
|
|
},
|
|
{
|
|
"fieldtype": "Break",
|
|
},
|
|
{
|
|
"fieldname":"party_type",
|
|
"label": __("Party Type"),
|
|
"fieldtype": "Link",
|
|
"options": "Party Type",
|
|
"default": "",
|
|
on_change: function() {
|
|
frappe.query_report.set_filter_value('party', "");
|
|
}
|
|
},
|
|
{
|
|
"fieldname":"party",
|
|
"label": __("Party"),
|
|
"fieldtype": "MultiSelectList",
|
|
get_data: function(txt) {
|
|
if (!frappe.query_report.filters) return;
|
|
|
|
let party_type = frappe.query_report.get_filter_value('party_type');
|
|
if (!party_type) return;
|
|
|
|
return frappe.db.get_link_options(party_type, txt);
|
|
},
|
|
on_change: function() {
|
|
var party_type = frappe.query_report.get_filter_value('party_type');
|
|
var parties = frappe.query_report.get_filter_value('party');
|
|
|
|
if(!party_type || parties.length === 0 || parties.length > 1) {
|
|
frappe.query_report.set_filter_value('party_name', "");
|
|
frappe.query_report.set_filter_value('tax_id', "");
|
|
return;
|
|
} else {
|
|
var party = parties[0];
|
|
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
|
|
frappe.db.get_value(party_type, party, fieldname, function(value) {
|
|
frappe.query_report.set_filter_value('party_name', value[fieldname]);
|
|
});
|
|
|
|
if (party_type === "Customer" || party_type === "Supplier") {
|
|
frappe.db.get_value(party_type, party, "tax_id", function(value) {
|
|
frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"fieldname":"party_name",
|
|
"label": __("Party Name"),
|
|
"fieldtype": "Data",
|
|
"hidden": 1
|
|
},
|
|
{
|
|
"fieldname":"group_by",
|
|
"label": __("Group by"),
|
|
"fieldtype": "Select",
|
|
"options": ["", __("Group by Voucher"), __("Group by Voucher (Consolidated)"),
|
|
__("Group by Account"), __("Group by Party")],
|
|
"default": __("Group by Voucher (Consolidated)")
|
|
},
|
|
{
|
|
"fieldname":"tax_id",
|
|
"label": __("Tax Id"),
|
|
"fieldtype": "Data",
|
|
"hidden": 1
|
|
},
|
|
{
|
|
"fieldname": "presentation_currency",
|
|
"label": __("Currency"),
|
|
"fieldtype": "Select",
|
|
"options": erpnext.get_presentation_currency_list()
|
|
},
|
|
{
|
|
"fieldname":"cost_center",
|
|
"label": __("Cost Center"),
|
|
"fieldtype": "MultiSelectList",
|
|
get_data: function(txt) {
|
|
return frappe.db.get_link_options('Cost Center', txt);
|
|
}
|
|
},
|
|
{
|
|
"fieldname":"project",
|
|
"label": __("Project"),
|
|
"fieldtype": "MultiSelectList",
|
|
get_data: function(txt) {
|
|
return frappe.db.get_link_options('Project', txt);
|
|
}
|
|
},
|
|
{
|
|
"fieldname": "include_dimensions",
|
|
"label": __("Consider Accounting Dimensions"),
|
|
"fieldtype": "Check",
|
|
"default": 0
|
|
},
|
|
{
|
|
"fieldname": "show_opening_entries",
|
|
"label": __("Show Opening Entries"),
|
|
"fieldtype": "Check"
|
|
},
|
|
{
|
|
"fieldname": "include_default_book_entries",
|
|
"label": __("Include Default Book Entries"),
|
|
"fieldtype": "Check"
|
|
},
|
|
{
|
|
"fieldname": "show_cancelled_entries",
|
|
"label": __("Show Cancelled Entries"),
|
|
"fieldtype": "Check"
|
|
}
|
|
]
|
|
}
|
|
|
|
erpnext.utils.add_dimensions('General Ledger', 15)
|
|
|