brotherton-erpnext/erpnext/accounts/report/general_ledger/general_ledger.js

173 lines
4.3 KiB
JavaScript
Raw Normal View History

// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
2014-02-14 10:17:51 +00:00
frappe.query_reports["General Ledger"] = {
"filters": [
{
"fieldname":"company",
2014-04-14 10:55:30 +00:00
"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",
"get_query": function() {
var company = frappe.query_report_filters_by_name.company.get_value();
return {
"filters": {
"company": company,
}
};
}
},
{
"fieldname":"from_date",
2014-04-14 10:55:30 +00:00
"label": __("From Date"),
"fieldtype": "Date",
2014-02-14 10:17:51 +00:00
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
"reqd": 1,
"width": "60px"
},
{
"fieldname":"to_date",
2014-04-14 10:55:30 +00:00
"label": __("To Date"),
"fieldtype": "Date",
2014-02-14 10:17:51 +00:00
"default": frappe.datetime.get_today(),
"reqd": 1,
"width": "60px"
},
{
"fieldname":"account",
2014-04-14 10:55:30 +00:00
"label": __("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = frappe.query_report_filters_by_name.company.get_value();
return {
"doctype": "Account",
"filters": {
"company": company,
}
}
}
},
{
"fieldname":"voucher_no",
2014-04-14 10:55:30 +00:00
"label": __("Voucher No"),
"fieldtype": "Data",
on_change: function() {
frappe.query_report_filters_by_name.group_by.set_value("");
}
},
{
"fieldname":"project",
"label": __("Project"),
"fieldtype": "Link",
"options": "Project"
},
{
"fieldtype": "Break",
},
{
"fieldname":"party_type",
"label": __("Party Type"),
"fieldtype": "Link",
"options": "Party Type",
"default": "",
on_change: function() {
frappe.query_report_filters_by_name.party.set_value("");
}
},
{
"fieldname":"party",
"label": __("Party"),
"fieldtype": "MultiSelect",
get_data: function() {
if(!frappe.query_report_filters_by_name) return;
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
var parties = frappe.query_report_filters_by_name.party.get_value();
if(!party_type) {
frappe.throw(__("Please select Party Type first"));
}
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-06-27 06:26:30 +00:00
on_change: function() {
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
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) {
frappe.query_report_filters_by_name.party_name.set_value("");
frappe.query_report_filters_by_name.tax_id.set_value("");
return;
} 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]);
});
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"]);
});
}
}
}
},
{
"fieldname":"party_name",
"label": __("Party Name"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname":"group_by",
"label": __("Group by"),
"fieldtype": "Select",
"options": ["", "Group by Voucher", "Group by Account", "Group by Party"],
"default": "Group by Voucher"
},
{
"fieldname":"tax_id",
"label": __("Tax Id"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname": "presentation_currency",
"label": __("Currency"),
"fieldtype": "Select",
"options": erpnext.get_presentation_currency_list()
}
]
}