2018-02-12 09:34:50 +00:00
|
|
|
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
2013-12-06 11:06:23 +00:00
|
|
|
// License: GNU General Public License v3. See license.txt
|
|
|
|
|
2014-02-14 10:17:51 +00:00
|
|
|
frappe.query_reports["General Ledger"] = {
|
2013-12-06 11:06:23 +00:00
|
|
|
"filters": [
|
|
|
|
{
|
|
|
|
"fieldname":"company",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("Company"),
|
2013-12-06 11:06:23 +00:00
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Company",
|
2015-12-23 11:07:00 +00:00
|
|
|
"default": frappe.defaults.get_user_default("Company"),
|
2013-12-06 11:06:23 +00:00
|
|
|
"reqd": 1
|
|
|
|
},
|
2018-04-22 20:59:22 +00:00
|
|
|
{
|
|
|
|
"fieldname":"finance_book",
|
|
|
|
"label": __("Finance Book"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Finance Book",
|
|
|
|
"get_query": function() {
|
|
|
|
var company = frappe.query_report_filters_by_name.company.get_value();
|
|
|
|
return {
|
|
|
|
"filters": {
|
|
|
|
"company": company,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
2013-12-06 11:06:23 +00:00
|
|
|
{
|
|
|
|
"fieldname":"from_date",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("From Date"),
|
2013-12-06 11:06:23 +00:00
|
|
|
"fieldtype": "Date",
|
2014-02-14 10:17:51 +00:00
|
|
|
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
|
2013-12-06 11:06:23 +00:00
|
|
|
"reqd": 1,
|
|
|
|
"width": "60px"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"fieldname":"to_date",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("To Date"),
|
2013-12-06 11:06:23 +00:00
|
|
|
"fieldtype": "Date",
|
2014-02-14 10:17:51 +00:00
|
|
|
"default": frappe.datetime.get_today(),
|
2013-12-06 11:06:23 +00:00
|
|
|
"reqd": 1,
|
|
|
|
"width": "60px"
|
2013-12-27 12:03:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"fieldname":"account",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("Account"),
|
2013-12-27 12:03:55 +00:00
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Account",
|
|
|
|
"get_query": function() {
|
2016-09-01 12:23:19 +00:00
|
|
|
var company = frappe.query_report_filters_by_name.company.get_value();
|
2013-12-27 12:03:55 +00:00
|
|
|
return {
|
2015-01-12 06:48:54 +00:00
|
|
|
"doctype": "Account",
|
2013-12-27 12:03:55 +00:00
|
|
|
"filters": {
|
|
|
|
"company": company,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"fieldname":"voucher_no",
|
2014-04-14 10:55:30 +00:00
|
|
|
"label": __("Voucher No"),
|
2013-12-27 12:03:55 +00:00
|
|
|
"fieldtype": "Data",
|
2018-04-19 09:39:46 +00:00
|
|
|
on_change: function() {
|
|
|
|
frappe.query_report_filters_by_name.group_by.set_value("");
|
|
|
|
}
|
2013-12-27 12:03:55 +00:00
|
|
|
},
|
2017-01-24 09:42:24 +00:00
|
|
|
{
|
|
|
|
"fieldname":"project",
|
|
|
|
"label": __("Project"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Project"
|
|
|
|
},
|
2015-01-12 06:48:54 +00:00
|
|
|
{
|
|
|
|
"fieldtype": "Break",
|
|
|
|
},
|
2015-04-20 11:43:43 +00:00
|
|
|
{
|
|
|
|
"fieldname":"party_type",
|
|
|
|
"label": __("Party Type"),
|
2017-02-01 06:32:08 +00:00
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Party Type",
|
2018-03-27 05:59:25 +00:00
|
|
|
"default": "",
|
|
|
|
on_change: function() {
|
|
|
|
frappe.query_report_filters_by_name.party.set_value("");
|
|
|
|
}
|
2015-04-20 11:43:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"fieldname":"party",
|
|
|
|
"label": __("Party"),
|
2018-05-03 13:30:43 +00:00
|
|
|
"fieldtype": "MultiSelect",
|
|
|
|
get_data: function() {
|
|
|
|
if(!frappe.query_report_filters_by_name) return;
|
|
|
|
|
2016-09-01 12:23:19 +00:00
|
|
|
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
|
2018-05-03 13:30:43 +00:00
|
|
|
var parties = frappe.query_report_filters_by_name.party.get_value();
|
|
|
|
if(!party_type) {
|
2015-04-20 11:43:43 +00:00
|
|
|
frappe.throw(__("Please select Party Type first"));
|
|
|
|
}
|
2018-05-03 13:30:43 +00:00
|
|
|
|
|
|
|
const values = parties.split(/\s*,\s*/).filter(d => d);
|
|
|
|
const txt = parties.match(/[^,\s*]*$/)[0] || '';
|
|
|
|
let data = [];
|
|
|
|
|
|
|
|
frappe.call({
|
|
|
|
type: "GET",
|
|
|
|
method:'frappe.desk.search.search_link',
|
|
|
|
async: false,
|
|
|
|
no_spinner: true,
|
|
|
|
args: {
|
|
|
|
doctype: frappe.query_report_filters_by_name.party_type.get_value(),
|
|
|
|
txt: txt,
|
|
|
|
filters: {
|
|
|
|
"name": ["not in", values]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
callback: function(r) {
|
|
|
|
data = r.results;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return data;
|
2017-05-11 06:08:30 +00:00
|
|
|
},
|
2017-06-27 06:26:30 +00:00
|
|
|
on_change: function() {
|
2017-05-11 06:08:30 +00:00
|
|
|
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
|
2018-05-03 13:30:43 +00:00
|
|
|
var parties = frappe.query_report_filters_by_name.party.get_value();
|
|
|
|
const values = parties.split(/\s*,\s*/).filter(d => d);
|
|
|
|
|
|
|
|
if(!party_type || !parties || values.length>1) {
|
2017-05-11 06:08:30 +00:00
|
|
|
frappe.query_report_filters_by_name.party_name.set_value("");
|
2018-05-03 13:30:43 +00:00
|
|
|
frappe.query_report_filters_by_name.tax_id.set_value("");
|
2017-05-11 06:08:30 +00:00
|
|
|
return;
|
2018-05-03 13:30:43 +00:00
|
|
|
} else {
|
|
|
|
var party = values[0];
|
|
|
|
frappe.query_report_filters_by_name.show_name = true;
|
|
|
|
var fieldname = erpnext.utils.get_party_name(party_type) || "name";
|
|
|
|
frappe.db.get_value(party_type, party, fieldname, function(value) {
|
|
|
|
frappe.query_report_filters_by_name.party_name.set_value(value[fieldname]);
|
2018-03-23 09:34:37 +00:00
|
|
|
});
|
2018-05-03 13:30:43 +00:00
|
|
|
|
|
|
|
if (party_type === "Customer" || party_type === "Supplier") {
|
|
|
|
frappe.db.get_value(party_type, party, "tax_id", function(value) {
|
|
|
|
frappe.query_report_filters_by_name.tax_id.set_value(value["tax_id"]);
|
|
|
|
});
|
|
|
|
}
|
2018-03-23 09:34:37 +00:00
|
|
|
}
|
2015-04-20 11:43:43 +00:00
|
|
|
}
|
|
|
|
},
|
2017-05-11 06:08:30 +00:00
|
|
|
{
|
|
|
|
"fieldname":"party_name",
|
|
|
|
"label": __("Party Name"),
|
|
|
|
"fieldtype": "Data",
|
|
|
|
"hidden": 1
|
|
|
|
},
|
2018-04-17 09:42:26 +00:00
|
|
|
{
|
|
|
|
"fieldname":"group_by",
|
|
|
|
"label": __("Group by"),
|
|
|
|
"fieldtype": "Select",
|
2018-04-19 09:39:46 +00:00
|
|
|
"options": ["", "Group by Voucher", "Group by Account", "Group by Party"],
|
2018-04-17 09:42:26 +00:00
|
|
|
"default": "Group by Voucher"
|
|
|
|
},
|
2018-03-23 09:34:37 +00:00
|
|
|
{
|
|
|
|
"fieldname":"tax_id",
|
|
|
|
"label": __("Tax Id"),
|
|
|
|
"fieldtype": "Data",
|
|
|
|
"hidden": 1
|
|
|
|
},
|
2018-01-18 04:02:43 +00:00
|
|
|
{
|
2018-02-12 09:34:50 +00:00
|
|
|
"fieldname": "presentation_currency",
|
|
|
|
"label": __("Currency"),
|
|
|
|
"fieldtype": "Select",
|
|
|
|
"options": erpnext.get_presentation_currency_list()
|
2013-12-06 11:06:23 +00:00
|
|
|
}
|
|
|
|
]
|
2015-01-12 06:48:54 +00:00
|
|
|
}
|