From cd17bdffcd701aec26d8e47eed93e5f6fe0cf36e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 28 Apr 2014 20:33:33 +0530 Subject: [PATCH] Fixes in account query, fiscal year and cost center --- .../bank_reconciliation/bank_reconciliation.js | 18 ++++++++++++++---- .../doctype/cost_center/cost_center.py | 5 ++++- .../doctype/fiscal_year/fiscal_year.js | 16 ++++++++++++---- erpnext/public/js/queries.js | 4 ---- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js index 089f61e821..72ab425d2e 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js @@ -1,8 +1,18 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.add_fetch("bank_account", "company", "company"); cur_frm.cscript.onload = function(doc, cdt, cdn){ - cur_frm.set_intro(' ' + - __("Update clearance date of Journal Entries marked as 'Bank Vouchers'")) -} \ No newline at end of file + cur_frm.set_intro(' ' + + __("Update clearance date of Journal Entries marked as 'Bank Vouchers'")); + + cur_frm.add_fetch("bank_account", "company", "company"); + + cur_frm.set_query("bank_account", function() { + return { + "filters": { + "account_type": "Bank", + "group_or_ledger": "Ledger" + } + }; + }); +} diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py index 71ebe6c745..b20cbe9caf 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.py +++ b/erpnext/accounts/doctype/cost_center/cost_center.py @@ -64,7 +64,10 @@ class CostCenter(NestedSet): """ Cost Center name must be unique """ - if (self.get("__islocal") or not self.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.cost_center_name, self.company)): + if ((self.get("__islocal") or not self.name) and + frappe.db.sql("select name from `tabCost Center` where cost_center_name=%s and company=%s", + (self.cost_center_name, self.company)) + ): msgprint(_("Cost Center Name already exists"), raise_exception=1) self.validate_mandatory() diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js index c83e1c891e..f6f19f7e82 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js @@ -2,15 +2,23 @@ // License: GNU General Public License v3. See license.txt $.extend(cur_frm.cscript, { + onload: function() { + if(cur_frm.doc.__islocal) { + cur_frm.set_value("year_start_date", + frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)); + } + }, refresh: function (doc, dt, dn) { var me = this; this.frm.toggle_enable('year_start_date', doc.__islocal) this.frm.toggle_enable('year_end_date', doc.__islocal) - + if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) { this.frm.add_custom_button(__("Set as Default"), this.frm.cscript.set_as_default); this.frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'")); - } else this.frm.set_intro(""); + } else { + this.frm.set_intro(""); + } }, set_as_default: function() { return frappe.call({ @@ -21,8 +29,8 @@ $.extend(cur_frm.cscript, { year_start_date: function(doc, dt, dn) { var me = this; - year_end_date = + year_end_date = frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1); this.frm.set_value("year_end_date", year_end_date); }, -}); \ No newline at end of file +}); diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index 117e192788..cdd14c6873 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -20,10 +20,6 @@ $.extend(erpnext.queries, { return { query: "erpnext.controllers.queries.supplier_query" }; }, - account: function() { - return { query: "erpnext.controllers.queries.account_query" }; - }, - item: function(filters) { var args = { query: "erpnext.controllers.queries.item_query" }; if(filters) args["filters"] = filters;