get the currencies from database rather than hardcoded

This commit is contained in:
tundebabzy
2018-01-18 13:56:46 +01:00
parent 55fe8d9987
commit 36e7b6303e

View File

@@ -1,7 +1,25 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.query_reports["General Ledger"] = { const get_currencies = () => {
// frappe.db.get_list returns a Promise
return frappe.db.get_list('GL Entry',
{
distinct: true,
fields:['account_currency'],
as_list: true
}
);
}
const flatten = (array) => {
return [].concat.apply([], array);
}
get_currencies()
.then((r) => flatten(r))
.then((currency_list) => {
frappe.query_reports["General Ledger"] = {
"filters": [ "filters": [
{ {
"fieldname":"company", "fieldname":"company",
@@ -110,7 +128,8 @@ frappe.query_reports["General Ledger"] = {
"fieldname": "presentation_currency", "fieldname": "presentation_currency",
"label": __("Currency"), "label": __("Currency"),
"fieldtype": "Select", "fieldtype": "Select",
"options": "NGN\nINR\nUSD" "options": currency_list
} }
] ]
} }
});