From 78fa6954e5d0003f26bb5e03f9ab67feb0a5ecb8 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 3 Oct 2014 17:43:02 +0530 Subject: [PATCH 1/5] Fiscal year autofetch added --- .../doctype/fiscal_year/fiscal_year.json | 18 +++---- .../doctype/fiscal_year_company/__init__.py | 0 .../fiscal_year_company.json | 51 +++++++++++++++++++ .../fiscal_year_company.py | 9 ++++ .../journal_voucher/journal_voucher.js | 6 +++ .../journal_voucher/journal_voucher.json | 30 +++++------ erpnext/accounts/utils.py | 19 ++++--- .../doctype/purchase_order/purchase_order.js | 23 +++++++++ erpnext/public/js/transaction.js | 7 +++ erpnext/public/js/utils.js | 16 ++++++ .../stock/doctype/stock_entry/stock_entry.js | 14 +++-- .../doctype/stock_entry/stock_entry.json | 24 ++++----- 12 files changed, 167 insertions(+), 50 deletions(-) create mode 100644 erpnext/accounts/doctype/fiscal_year_company/__init__.py create mode 100644 erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.json create mode 100644 erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json index 0f7aefd3125..ed98b394fb2 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json @@ -39,23 +39,17 @@ "reqd": 1 }, { - "default": "No", - "description": "Entries are not allowed against this Fiscal Year if the year is closed.", - "fieldname": "is_fiscal_year_closed", - "fieldtype": "Select", - "in_list_view": 1, - "label": "Year Closed", - "no_copy": 1, - "oldfieldname": "is_fiscal_year_closed", - "oldfieldtype": "Select", - "options": "\nNo\nYes", + "fieldname": "company", + "fieldtype": "Table", + "label": "List of Companies", + "options": "Fiscal Year Company", "permlevel": 0, - "reqd": 0 + "precision": "" } ], "icon": "icon-calendar", "idx": 1, - "modified": "2014-07-14 05:30:56.843180", + "modified": "2014-10-02 13:40:40.298965", "modified_by": "Administrator", "module": "Accounts", "name": "Fiscal Year", diff --git a/erpnext/accounts/doctype/fiscal_year_company/__init__.py b/erpnext/accounts/doctype/fiscal_year_company/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.json b/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.json new file mode 100644 index 00000000000..5de4d3cb34e --- /dev/null +++ b/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.json @@ -0,0 +1,51 @@ +{ + "allow_copy": 0, + "allow_import": 0, + "allow_rename": 0, + "creation": "2014-10-02 13:35:44.155278", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "Master", + "fields": [ + { + "allow_on_submit": 0, + "fieldname": "company", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Company", + "no_copy": 0, + "options": "Company", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "in_create": 0, + "in_dialog": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 1, + "modified": "2014-10-02 13:35:44.155278", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Fiscal Year Company", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "read_only": 0, + "read_only_onload": 0, + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py b/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py new file mode 100644 index 00000000000..76a8bd40d19 --- /dev/null +++ b/erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py @@ -0,0 +1,9 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class FiscalYearCompany(Document): + pass diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 69269d07e91..2c2018e330d 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.accounts"); +frappe.require("assets/erpnext/js/utils.js"); erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ onload: function() { @@ -153,6 +154,11 @@ cur_frm.cscript.refresh = function(doc) { cur_frm.cscript.company = function(doc, cdt, cdn) { cur_frm.refresh_fields(); + erpnext.get_fiscal_year(doc); +} + +cur_frm.cscript.posting_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc); } cur_frm.cscript.is_opening = function(doc, cdt, cdn) { diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.json b/erpnext/accounts/doctype/journal_voucher/journal_voucher.json index 1638296c5c4..180a21105d3 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.json +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.json @@ -388,20 +388,6 @@ "read_only": 1, "report_hide": 1 }, - { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1, - "search_index": 1 - }, { "fieldname": "company", "fieldtype": "Link", @@ -416,6 +402,20 @@ "reqd": 1, "search_index": 1 }, + { + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1, + "search_index": 1 + }, { "allow_on_submit": 1, "fieldname": "select_print_heading", @@ -447,7 +447,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2014-09-09 05:35:31.217863", + "modified": "2014-10-02 14:51:20.624847", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Voucher", diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index cf57a61fe54..fb4a86c8f6d 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -12,26 +12,29 @@ import frappe.desk.reportview class FiscalYearError(frappe.ValidationError): pass class BudgetError(frappe.ValidationError): pass +@frappe.whitelist() +def get_fiscal_year(date=None, fiscal_year=None, label="Date", verbose=1, company=None): + return get_fiscal_years(date, fiscal_year, label, verbose, company)[0] -def get_fiscal_year(date=None, fiscal_year=None, label="Date", verbose=1): - return get_fiscal_years(date, fiscal_year, label, verbose)[0] - -def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1): +def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1, company=None): # if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate) cond = "" if fiscal_year: cond = "name = '%s'" % fiscal_year.replace("'", "\'") + elif company: + cond = """('%s' in (select company from `tabFiscal Year Company` + where `tabFiscal Year Company`.parent = `tabFiscal Year`.name)) + and '%s' >= year_start_date and '%s' <= year_end_date """ %(company, date, date) else: - cond = "'%s' >= year_start_date and '%s' <= year_end_date" % \ - (date, date) + cond = "'%s' >= year_start_date and '%s' <= year_end_date" %(date, date) + fy = frappe.db.sql("""select name, year_start_date, year_end_date from `tabFiscal Year` where %s order by year_start_date desc""" % cond) if not fy: error_msg = _("""{0} {1} not in any Fiscal Year""").format(label, formatdate(date)) - if verbose: frappe.msgprint(error_msg) + if verbose==1: frappe.msgprint(error_msg) raise FiscalYearError, error_msg - return fy def validate_fiscal_year(date, fiscal_year, label="Date"): diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 9433ebe20c5..3d66cd1f226 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -211,3 +211,26 @@ cur_frm.cscript.send_sms = function() { var sms_man = new SMSManager(cur_frm.doc); } +cur_frm.cscript.company = function(doc, cdt, cdn) { + get_fiscal_year(doc); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + get_fiscal_year(doc); +} + +function get_fiscal_year(doc) { + frappe.call({ + type:"GET", + method: "erpnext.accounts.utils.get_fiscal_year", + args: { + "company": doc.company, + "date": doc.transaction_date, + "verbose": '0' + }, + callback: function(r) { + var arr = r.message + if (arr != null) cur_frm.set_value("fiscal_year",arr[0]); + } + }); +} \ No newline at end of file diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 3a124850199..355a11c01a4 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -3,6 +3,8 @@ frappe.provide("erpnext"); frappe.require("assets/erpnext/js/controllers/stock_controller.js"); +frappe.require("assets/erpnext/js/utils.js"); + erpnext.TransactionController = erpnext.stock.StockController.extend({ onload: function() { @@ -221,6 +223,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.frm.script_manager.trigger("currency"); this.apply_pricing_rule(); } + erpnext.get_fiscal_year(this.frm.doc); + }, + + posting_date: function() { + erpnext.get_fiscal_year(this.frm.doc); }, get_company_currency: function() { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index ef7d03ea458..748678a497e 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -12,6 +12,22 @@ $.extend(erpnext, { return frappe.boot.sysdefaults.currency; }, + get_fiscal_year: function(doc) { + frappe.call({ + type:"GET", + method: "erpnext.accounts.utils.get_fiscal_year", + args: { + "company": doc.company, + "date": doc.posting_date, + "verbose": '0' + }, + callback: function(r) { + var arr = r.message + if (arr != null) cur_frm.set_value("fiscal_year",arr[0]); + } + }); + }, + toggle_naming_series: function() { if(cur_frm.fields_dict.naming_series) { cur_frm.toggle_display("naming_series", cur_frm.doc.__islocal?true:false); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 96dee3da4f5..8acf1a0f3fd 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1,10 +1,10 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt cur_frm.cscript.tname = "Stock Entry Detail"; cur_frm.cscript.fname = "mtn_details"; frappe.require("assets/erpnext/js/controllers/stock_controller.js"); +frappe.require("assets/erpnext/js/utils.js"); frappe.provide("erpnext.stock"); erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ @@ -462,4 +462,12 @@ cur_frm.fields_dict.supplier.get_query = function(doc, cdt, cdn) { return { query: "erpnext.controllers.queries.supplier_query" } } cur_frm.add_fetch('production_order', 'total_fixed_cost', 'total_fixed_cost'); -cur_frm.add_fetch('bom_no', 'total_fixed_cost', 'total_fixed_cost'); \ No newline at end of file +cur_frm.add_fetch('bom_no', 'total_fixed_cost', 'total_fixed_cost'); + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc); +} + +cur_frm.cscript.posting_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc); +} diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json index 5f78758c6c6..8cbfbef1eab 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.json +++ b/erpnext/stock/doctype/stock_entry/stock_entry.json @@ -509,17 +509,6 @@ "permlevel": 0, "read_only": 1 }, - { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 0, - "label": "Fiscal Year", - "options": "Fiscal Year", - "permlevel": 0, - "print_hide": 1, - "read_only": 0, - "reqd": 1 - }, { "allow_on_submit": 0, "fieldname": "company", @@ -538,6 +527,17 @@ "reqd": 1, "search_index": 0 }, + { + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 0, + "label": "Fiscal Year", + "options": "Fiscal Year", + "permlevel": 0, + "print_hide": 1, + "read_only": 0, + "reqd": 1 + }, { "allow_on_submit": 1, "fieldname": "select_print_heading", @@ -585,7 +585,7 @@ "is_submittable": 1, "issingle": 0, "max_attachments": 0, - "modified": "2014-09-16 15:56:37.514676", + "modified": "2014-10-03 14:55:44.916658", "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry", From e6b14a4bf6d1a8294284d4d61bc45bea081086cb Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 7 Oct 2014 12:50:17 +0530 Subject: [PATCH 2/5] Fixed issues --- .../doctype/fiscal_year/fiscal_year.json | 6 +++--- .../journal_voucher/journal_voucher.js | 4 ++-- erpnext/accounts/utils.py | 2 +- .../doctype/purchase_order/purchase_order.js | 21 +++---------------- erpnext/public/js/utils.js | 6 +++--- .../doctype/sales_order/sales_order.js | 8 +++++++ .../stock/doctype/stock_entry/stock_entry.js | 4 ++-- 7 files changed, 22 insertions(+), 29 deletions(-) diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json index ed98b394fb2..3927c4f5b59 100644 --- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.json +++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.json @@ -39,9 +39,9 @@ "reqd": 1 }, { - "fieldname": "company", + "fieldname": "fiscal_year_companies", "fieldtype": "Table", - "label": "List of Companies", + "label": "Fiscal Year Companies", "options": "Fiscal Year Company", "permlevel": 0, "precision": "" @@ -49,7 +49,7 @@ ], "icon": "icon-calendar", "idx": 1, - "modified": "2014-10-02 13:40:40.298965", + "modified": "2014-10-07 12:23:41.679419", "modified_by": "Administrator", "module": "Accounts", "name": "Fiscal Year", diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 2c2018e330d..a346f6c6c4b 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -154,11 +154,11 @@ cur_frm.cscript.refresh = function(doc) { cur_frm.cscript.company = function(doc, cdt, cdn) { cur_frm.refresh_fields(); - erpnext.get_fiscal_year(doc); + erpnext.get_fiscal_year(doc.company, doc.posting_date); } cur_frm.cscript.posting_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc); + erpnext.get_fiscal_year(doc.company, doc.posting_date); } cur_frm.cscript.is_opening = function(doc, cdt, cdn) { diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index fb4a86c8f6d..0c108a4efd7 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -24,7 +24,7 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1, compa elif company: cond = """('%s' in (select company from `tabFiscal Year Company` where `tabFiscal Year Company`.parent = `tabFiscal Year`.name)) - and '%s' >= year_start_date and '%s' <= year_end_date """ %(company, date, date) + and '%s' >= year_start_date and '%s' <= year_end_date """ %(company.replace("'", "\'"), date, date) else: cond = "'%s' >= year_start_date and '%s' <= year_end_date" %(date, date) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 3d66cd1f226..3a4ab4ad048 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.buying"); +frappe.require("assets/erpnext/js/utils.js"); cur_frm.cscript.tname = "Purchase Order Item"; cur_frm.cscript.fname = "po_details"; @@ -212,25 +213,9 @@ cur_frm.cscript.send_sms = function() { } cur_frm.cscript.company = function(doc, cdt, cdn) { - get_fiscal_year(doc); + erpnext.get_fiscal_year(doc.company, doc.transaction_date); } cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ - get_fiscal_year(doc); -} - -function get_fiscal_year(doc) { - frappe.call({ - type:"GET", - method: "erpnext.accounts.utils.get_fiscal_year", - args: { - "company": doc.company, - "date": doc.transaction_date, - "verbose": '0' - }, - callback: function(r) { - var arr = r.message - if (arr != null) cur_frm.set_value("fiscal_year",arr[0]); - } - }); + erpnext.get_fiscal_year(doc.company, doc.transaction_date); } \ No newline at end of file diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 748678a497e..b508471eaa3 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -12,13 +12,13 @@ $.extend(erpnext, { return frappe.boot.sysdefaults.currency; }, - get_fiscal_year: function(doc) { + get_fiscal_year: function(company, date) { frappe.call({ type:"GET", method: "erpnext.accounts.utils.get_fiscal_year", args: { - "company": doc.company, - "date": doc.posting_date, + "company": company, + "date": date, "verbose": '0' }, callback: function(r) { diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 628e43e1dfb..253373563e0 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -199,3 +199,11 @@ cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); }; + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 8acf1a0f3fd..d961b40f622 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -465,9 +465,9 @@ cur_frm.add_fetch('production_order', 'total_fixed_cost', 'total_fixed_cost'); cur_frm.add_fetch('bom_no', 'total_fixed_cost', 'total_fixed_cost'); cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc); + erpnext.get_fiscal_year(doc.company, doc.posting_date); } cur_frm.cscript.posting_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc); + erpnext.get_fiscal_year(doc.company, doc.posting_date); } From 565d986198c5fd68d9ebdfc981c629b0ee6457e6 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 7 Oct 2014 18:26:39 +0530 Subject: [PATCH 3/5] fiscal year auto fetch added to oppurtunity, quotation, material request, supplier quotation, expense claim doctypes + issues fixed --- .../supplier_quotation/supplier_quotation.js | 10 ++++ .../hr/doctype/expense_claim/expense_claim.js | 9 ++++ .../doctype/expense_claim/expense_claim.json | 47 +++++++++---------- erpnext/public/js/transaction.js | 4 +- erpnext/public/js/utils.js | 3 +- .../doctype/opportunity/opportunity.js | 8 ++++ .../doctype/opportunity/opportunity.json | 23 ++++----- .../selling/doctype/quotation/quotation.js | 9 ++++ .../material_request/material_request.js | 10 ++++ 9 files changed, 83 insertions(+), 40 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index b8d40ca236c..13fb4e04d70 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -11,6 +11,8 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} +frappe.require("assets/erpnext/js/utils.js"); + erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { this._super(); @@ -72,3 +74,11 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { filters:{'supplier': doc.supplier} } } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index a4ba2eb7bf9..a4a64d9092a 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.hr"); +frappe.require("assets/erpnext/js/utils.js"); erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({ make_bank_voucher: function() { @@ -154,3 +155,11 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.email_doc(frappe.boot.notification_settings.expense_claim_message); } } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.posting_date); +} + +cur_frm.cscript.posting_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.posting_date); +} \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.json b/erpnext/hr/doctype/expense_claim/expense_claim.json index 15ef03ed178..a82ef90c7b7 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.json +++ b/erpnext/hr/doctype/expense_claim/expense_claim.json @@ -89,6 +89,16 @@ "options": "Simple", "permlevel": 0 }, + { + "fieldname": "posting_date", + "fieldtype": "Date", + "in_filter": 1, + "label": "Posting Date", + "oldfieldname": "posting_date", + "oldfieldtype": "Date", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "employee", "fieldtype": "Link", @@ -114,17 +124,6 @@ "search_index": 0, "width": "150px" }, - { - "fieldname": "fiscal_year", - "fieldtype": "Link", - "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", - "permlevel": 0, - "reqd": 1 - }, { "fieldname": "company", "fieldtype": "Link", @@ -136,21 +135,22 @@ "permlevel": 0, "reqd": 1 }, + { + "fieldname": "fiscal_year", + "fieldtype": "Link", + "in_filter": 1, + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "cb1", "fieldtype": "Column Break", "permlevel": 0 }, - { - "fieldname": "posting_date", - "fieldtype": "Date", - "in_filter": 1, - "label": "Posting Date", - "oldfieldname": "posting_date", - "oldfieldtype": "Date", - "permlevel": 0, - "reqd": 1 - }, { "allow_on_submit": 0, "fieldname": "remark", @@ -190,7 +190,7 @@ "icon": "icon-money", "idx": 1, "is_submittable": 1, - "modified": "2014-08-27 07:08:48.454580", + "modified": "2014-10-07 18:22:14.689567", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim", @@ -206,7 +206,6 @@ "read": 1, "report": 1, "role": "Employee", - "user_permission_doctypes": "[\"Company\",\"Employee\",\"Expense Claim\",\"Fiscal Year\"]", "write": 1 }, { @@ -222,7 +221,6 @@ "report": 1, "role": "Expense Approver", "submit": 1, - "user_permission_doctypes": "[\"Expense Claim\",\"User\"]", "write": 1 }, { @@ -238,7 +236,6 @@ "report": 1, "role": "HR User", "submit": 1, - "user_permission_doctypes": "[\"Company\",\"Expense Claim\",\"Fiscal Year\"]", "write": 1 } ], diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 355a11c01a4..8fce8e89a7e 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -223,11 +223,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.frm.script_manager.trigger("currency"); this.apply_pricing_rule(); } - erpnext.get_fiscal_year(this.frm.doc); + erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.posting_date); }, posting_date: function() { - erpnext.get_fiscal_year(this.frm.doc); + erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.posting_date); }, get_company_currency: function() { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index b508471eaa3..5a0e9d4954f 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -22,8 +22,7 @@ $.extend(erpnext, { "verbose": '0' }, callback: function(r) { - var arr = r.message - if (arr != null) cur_frm.set_value("fiscal_year",arr[0]); + if (r.message) cur_frm.set_value("fiscal_year", r.message[0]); } }); }, diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js index df84d72b6b7..b29c03ac0b4 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.js +++ b/erpnext/selling/doctype/opportunity/opportunity.js @@ -8,6 +8,7 @@ frappe.ui.form.on_change("Opportunity", "contact_person", erpnext.utils.get_cont frappe.provide("erpnext.selling"); +frappe.require("assets/erpnext/js/utils.js"); cur_frm.email_field = "contact_email"; // TODO commonify this code @@ -145,3 +146,10 @@ cur_frm.cscript.send_sms = function() { var sms_man = new SMSManager(cur_frm.doc); } +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/selling/doctype/opportunity/opportunity.json b/erpnext/selling/doctype/opportunity/opportunity.json index 270fe779fe2..a47b21f176b 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.json +++ b/erpnext/selling/doctype/opportunity/opportunity.json @@ -272,13 +272,13 @@ "width": "50px" }, { - "fieldname": "fiscal_year", + "fieldname": "company", "fieldtype": "Link", "in_filter": 1, - "label": "Fiscal Year", - "oldfieldname": "fiscal_year", - "oldfieldtype": "Select", - "options": "Fiscal Year", + "label": "Company", + "oldfieldname": "company", + "oldfieldtype": "Link", + "options": "Company", "permlevel": 0, "print_hide": 1, "read_only": 0, @@ -307,13 +307,13 @@ "read_only": 0 }, { - "fieldname": "company", + "fieldname": "fiscal_year", "fieldtype": "Link", "in_filter": 1, - "label": "Company", - "oldfieldname": "company", - "oldfieldtype": "Link", - "options": "Company", + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "oldfieldtype": "Select", + "options": "Fiscal Year", "permlevel": 0, "print_hide": 1, "read_only": 0, @@ -388,7 +388,7 @@ "icon": "icon-info-sign", "idx": 1, "is_submittable": 1, - "modified": "2014-09-11 18:53:14.037512", + "modified": "2014-10-07 18:12:19.104820", "modified_by": "Administrator", "module": "Selling", "name": "Opportunity", @@ -396,6 +396,7 @@ "permissions": [ { "amend": 1, + "apply_user_permissions": 1, "cancel": 1, "create": 1, "delete": 1, diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 5f25446ed29..c00b6e1918f 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -12,6 +12,8 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} +frappe.require("assets/erpnext/js/utils.js"); + erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { var me = this; @@ -171,3 +173,10 @@ cur_frm.cscript.send_sms = function() { var sms_man = new SMSManager(cur_frm.doc); } +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 3729b55c7e3..27dd728cf5c 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -6,6 +6,8 @@ cur_frm.cscript.fname = "indent_details"; {% include 'buying/doctype/purchase_common/purchase_common.js' %}; +frappe.require("assets/erpnext/js/utils.js"); + erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({ onload: function(doc) { this._super(); @@ -195,3 +197,11 @@ cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} + +cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.transaction_date); +} \ No newline at end of file From 9614b552fd195aefa2a1301918f267b83938c4fa Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 8 Oct 2014 12:55:06 +0530 Subject: [PATCH 4/5] fiscal year auto-fetch added to c-form, installation_note, stock_reconciliation, customer_issue, maintanence_visit & removed for Expense Claim --- erpnext/accounts/doctype/c_form/c_form.js | 10 ++++++++++ .../hr/doctype/expense_claim/expense_claim.js | 9 --------- .../installation_note/installation_note.js | 9 +++++++++ .../stock_reconciliation.js | 9 +++++++++ .../stock_reconciliation.json | 20 +++++++++---------- .../doctype/customer_issue/customer_issue.js | 9 +++++++++ .../maintenance_visit/maintenance_visit.js | 9 +++++++++ 7 files changed, 56 insertions(+), 19 deletions(-) diff --git a/erpnext/accounts/doctype/c_form/c_form.js b/erpnext/accounts/doctype/c_form/c_form.js index 3bcfa5e4d9d..e4046d55184 100644 --- a/erpnext/accounts/doctype/c_form/c_form.js +++ b/erpnext/accounts/doctype/c_form/c_form.js @@ -3,6 +3,8 @@ //c-form js file // ----------------------------- +frappe.require("assets/erpnext/js/utils.js"); + cur_frm.fields_dict.invoice_details.grid.get_field("invoice_no").get_query = function(doc) { return { filters: { @@ -22,4 +24,12 @@ cur_frm.fields_dict.state.get_query = function(doc) { cur_frm.cscript.invoice_no = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; return get_server_fields('get_invoice_details', d.invoice_no, 'invoice_details', doc, cdt, cdn, 1); +} + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.received_date); +} + +cur_frm.cscript.received_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.received_date); } \ No newline at end of file diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index a4a64d9092a..e070b3f13dd 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.hr"); -frappe.require("assets/erpnext/js/utils.js"); erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({ make_bank_voucher: function() { @@ -154,12 +153,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { if(cint(frappe.boot.notification_settings && frappe.boot.notification_settings.expense_claim)) { cur_frm.email_doc(frappe.boot.notification_settings.expense_claim_message); } -} - -cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc.company, doc.posting_date); -} - -cur_frm.cscript.posting_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc.company, doc.posting_date); } \ No newline at end of file diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index e8dee46fd95..60e2f72ab21 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -4,6 +4,7 @@ cur_frm.cscript.tname = "Installation Note Item"; cur_frm.cscript.fname = "installed_item_details"; +frappe.require("assets/erpnext/js/utils.js"); frappe.ui.form.on_change("Installation Note", "customer", function(frm) { erpnext.utils.get_party_details(frm); }); @@ -69,3 +70,11 @@ erpnext.selling.InstallationNote = frappe.ui.form.Controller.extend({ }); $.extend(cur_frm.cscript, new erpnext.selling.InstallationNote({frm: cur_frm})); + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.inst_date); +} + +cur_frm.cscript.inst_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.inst_date); +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index 432a999b4ac..27ed872400c 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.require("assets/erpnext/js/controllers/stock_controller.js"); +frappe.require("assets/erpnext/js/utils.js"); frappe.provide("erpnext.stock"); erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ @@ -159,3 +160,11 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ }); cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm}); + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.posting_date); +} + +cur_frm.cscript.posting_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.posting_date); +} \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json index daba967a582..0035fe7aa65 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json @@ -1,5 +1,5 @@ { - "allow_copy": 1, + "allow_copy": 1, "autoname": "SR/.######", "creation": "2013-03-28 10:35:31", "description": "This tool helps you to update or fix the quantity and valuation of stock in the system. It is typically used to synchronise the system values and what actually exists in your warehouses.", @@ -41,6 +41,14 @@ "print_hide": 1, "read_only": 1 }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, { "fieldname": "fiscal_year", "fieldtype": "Link", @@ -50,14 +58,6 @@ "print_hide": 1, "reqd": 1 }, - { - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "permlevel": 0, - "reqd": 1 - }, { "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "fieldname": "expense_account", @@ -118,7 +118,7 @@ "idx": 1, "is_submittable": 1, "max_attachments": 1, - "modified": "2014-05-26 03:05:54.024413", + "modified": "2014-10-08 12:47:52.102135", "modified_by": "Administrator", "module": "Stock", "name": "Stock Reconciliation", diff --git a/erpnext/support/doctype/customer_issue/customer_issue.js b/erpnext/support/doctype/customer_issue/customer_issue.js index 67a265dd027..bcc59eabd3d 100644 --- a/erpnext/support/doctype/customer_issue/customer_issue.js +++ b/erpnext/support/doctype/customer_issue/customer_issue.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.support"); +frappe.require("assets/erpnext/js/utils.js"); frappe.ui.form.on_change("Customer Issue", "customer", function(frm) { erpnext.utils.get_party_details(frm) }); @@ -89,3 +90,11 @@ cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) { cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) { return{ query: "erpnext.controllers.queries.customer_query" } } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.complaint_date); +} + +cur_frm.cscript.complaint_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.complaint_date); +} \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js index e9a7c84a30b..ffdcb3ea75b 100644 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js @@ -2,6 +2,7 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.support"); +frappe.require("assets/erpnext/js/utils.js"); frappe.ui.form.on_change("Maintenance Visit", "customer", function(frm) { erpnext.utils.get_party_details(frm) }); @@ -92,3 +93,11 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) { cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) { return {query: "erpnext.controllers.queries.customer_query" } } + +cur_frm.cscript.company = function(doc, cdt, cdn) { + erpnext.get_fiscal_year(doc.company, doc.mntc_date); +} + +cur_frm.cscript.mntc_date = function(doc, cdt, cdn){ + erpnext.get_fiscal_year(doc.company, doc.mntc_date); +} \ No newline at end of file From eaae58f507e21b774a4feb7cb875bc082a42a4d0 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 9 Oct 2014 15:00:10 +0530 Subject: [PATCH 5/5] Transaction.js fixed , code commonified --- .../doctype/purchase_order/purchase_order.js | 9 ----- .../supplier_quotation/supplier_quotation.js | 10 ----- erpnext/public/js/transaction.js | 38 ++++++++++++------- erpnext/public/js/utils.js | 3 +- .../selling/doctype/quotation/quotation.js | 10 ----- .../doctype/sales_order/sales_order.js | 10 +---- .../material_request/material_request.js | 8 ---- 7 files changed, 27 insertions(+), 61 deletions(-) diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 3a4ab4ad048..8c2b1a25479 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt frappe.provide("erpnext.buying"); -frappe.require("assets/erpnext/js/utils.js"); cur_frm.cscript.tname = "Purchase Order Item"; cur_frm.cscript.fname = "po_details"; @@ -210,12 +209,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); -} - -cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc.company, doc.transaction_date); -} - -cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc.company, doc.transaction_date); } \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 13fb4e04d70..b9286a1c24a 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -11,8 +11,6 @@ cur_frm.cscript.other_fname = "other_charges"; {% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} -frappe.require("assets/erpnext/js/utils.js"); - erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ refresh: function() { this._super(); @@ -73,12 +71,4 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { return { filters:{'supplier': doc.supplier} } -} - -cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc.company, doc.transaction_date); -} - -cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc.company, doc.transaction_date); } \ No newline at end of file diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 8fce8e89a7e..41b384267f8 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -207,23 +207,33 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, company: function() { - if(this.frm.doc.company && this.frm.fields_dict.currency) { - var company_currency = this.get_company_currency(); - if (!this.frm.doc.currency) { - this.frm.set_value("currency", company_currency); - } + var me = this; + var fn = function() { + if(me.frm.doc.company && me.frm.fields_dict.currency) { + var company_currency = me.get_company_currency(); + if (!me.frm.doc.currency) { + me.frm.set_value("currency", company_currency); + } - if (this.frm.doc.currency == company_currency) { - this.frm.set_value("conversion_rate", 1.0); - } - if (this.frm.doc.price_list_currency == company_currency) { - this.frm.set_value('plc_conversion_rate', 1.0); - } + if (me.frm.doc.currency == company_currency) { + me.frm.set_value("conversion_rate", 1.0); + } + if (me.frm.doc.price_list_currency == company_currency) { + me.frm.set_value('plc_conversion_rate', 1.0); + } - this.frm.script_manager.trigger("currency"); - this.apply_pricing_rule(); + me.frm.script_manager.trigger("currency"); + me.apply_pricing_rule(); + } } - erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.posting_date); + + if (this.frm.doc.posting_date) var date = this.frm.doc.posting_date; + else var date = this.frm.doc.transaction_date; + erpnext.get_fiscal_year(this.frm.doc.company, date, fn); + }, + + transaction_date: function() { + erpnext.get_fiscal_year(this.frm.doc.company, this.frm.doc.transaction_date); }, posting_date: function() { diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 5a0e9d4954f..f72bcc447c6 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -12,7 +12,7 @@ $.extend(erpnext, { return frappe.boot.sysdefaults.currency; }, - get_fiscal_year: function(company, date) { + get_fiscal_year: function(company, date, fn) { frappe.call({ type:"GET", method: "erpnext.accounts.utils.get_fiscal_year", @@ -23,6 +23,7 @@ $.extend(erpnext, { }, callback: function(r) { if (r.message) cur_frm.set_value("fiscal_year", r.message[0]); + if (fn) fn(); } }); }, diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index c00b6e1918f..857a2591291 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -12,8 +12,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; {% include 'accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js' %} {% include 'accounts/doctype/sales_invoice/pos.js' %} -frappe.require("assets/erpnext/js/utils.js"); - erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ onload: function(doc, dt, dn) { var me = this; @@ -171,12 +169,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); -} - -cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc.company, doc.transaction_date); -} - -cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc.company, doc.transaction_date); } \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 253373563e0..65b91f4bd78 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -198,12 +198,4 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); -}; - -cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc.company, doc.transaction_date); -} - -cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc.company, doc.transaction_date); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index 27dd728cf5c..147a3b1d2c0 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -196,12 +196,4 @@ cur_frm.cscript['Unstop Material Request'] = function(){ cur_frm.cscript.send_sms = function() { frappe.require("assets/erpnext/js/sms_manager.js"); var sms_man = new SMSManager(cur_frm.doc); -} - -cur_frm.cscript.company = function(doc, cdt, cdn) { - erpnext.get_fiscal_year(doc.company, doc.transaction_date); -} - -cur_frm.cscript.transaction_date = function(doc, cdt, cdn){ - erpnext.get_fiscal_year(doc.company, doc.transaction_date); } \ No newline at end of file