From 1797cfef634c6b154dc10fe192d1ebc444509ee4 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 11 Oct 2013 13:34:10 +0530 Subject: [PATCH] [fix] removed validation of conversion rate equals 1 from all transaction --- .../doctype/sales_invoice/sales_invoice.txt | 3 +- public/js/transaction.js | 39 ++++--------------- selling/doctype/quotation/quotation.txt | 3 +- selling/doctype/sales_order/sales_order.txt | 3 +- stock/doctype/delivery_note/delivery_note.txt | 5 +-- .../purchase_receipt/purchase_receipt.txt | 3 +- utilities/transaction_base.py | 9 +---- 7 files changed, 15 insertions(+), 50 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index 516d1925a8..b168ba64fd 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/accounts/doctype/sales_invoice/sales_invoice.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:05", "docstatus": 0, - "modified": "2013-10-03 18:54:31", + "modified": "2013-10-11 13:12:38", "modified_by": "Administrator", "owner": "Administrator" }, @@ -225,7 +225,6 @@ "reqd": 1 }, { - "default": "1.00", "description": "Rate at which Customer Currency is converted to customer's base currency", "doctype": "DocField", "fieldname": "conversion_rate", diff --git a/public/js/transaction.js b/public/js/transaction.js index e12d1084e9..a7be5bdbf5 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -21,8 +21,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ company: wn.defaults.get_default("company"), fiscal_year: wn.defaults.get_default("fiscal_year"), is_subcontracted: "No", - conversion_rate: 1.0, - plc_conversion_rate: 1.0 }, function(fieldname, value) { if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname]) me.frm.set_value(fieldname, value); @@ -131,10 +129,16 @@ 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", this.get_company_currency()); + this.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); + this.frm.script_manager.trigger("currency"); } }, @@ -233,29 +237,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.calculate_taxes_and_totals(); }, - // serial_no: function(doc, cdt, cdn) { - // var me = this; - // var item = wn.model.get_doc(cdt, cdn); - // if (!item.item_code) { - // wn.call({ - // method: 'accounts.doctype.sales_invoice.pos.get_item_from_serial_no', - // args: {serial_no: this.serial_no.$input.val()}, - // callback: function(r) { - // if (r.message) { - // var item_code = r.message[0].item_code; - // var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item", - // this.frm.cscript.fname); - // child.item_code = item_code; - // me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); - // } - // else - // msgprint(wn._("Invalid Serial No.")); - // me.refresh(); - // } - // }); - // } - // }, - row_id: function(doc, cdt, cdn) { var tax = wn.model.get_doc(cdt, cdn); try { @@ -486,12 +467,8 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ } var company_currency = this.get_company_currency(); - var valid_conversion_rate = this.frm.doc.conversion_rate ? - ((this.frm.doc.currency == company_currency && this.frm.doc.conversion_rate == 1.0) || - (this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) : - false; - if(!valid_conversion_rate) { + if(!this.frm.doc.conversion_rate) { wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + " 1 " + this.frm.doc.currency + " = [?] " + company_currency); } diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index 3f97c980bc..62c36b432f 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:08", "docstatus": 0, - "modified": "2013-09-10 10:46:33", + "modified": "2013-10-11 13:21:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -257,7 +257,6 @@ "width": "100px" }, { - "default": "1.00", "description": "Rate at which customer's currency is converted to company's base currency", "doctype": "DocField", "fieldname": "conversion_rate", diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt index 94e63888e3..46a06b5bc4 100644 --- a/selling/doctype/sales_order/sales_order.txt +++ b/selling/doctype/sales_order/sales_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-18 12:39:59", "docstatus": 0, - "modified": "2013-08-09 14:46:17", + "modified": "2013-10-11 13:18:47", "modified_by": "Administrator", "owner": "Administrator" }, @@ -272,7 +272,6 @@ "width": "100px" }, { - "default": "1.00", "description": "Rate at which customer's currency is converted to company's base currency", "doctype": "DocField", "fieldname": "conversion_rate", diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt index f1493bb3bf..6834365b3f 100644 --- a/stock/doctype/delivery_note/delivery_note.txt +++ b/stock/doctype/delivery_note/delivery_note.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:09", "docstatus": 0, - "modified": "2013-08-09 14:46:32", + "modified": "2013-10-11 13:19:40", "modified_by": "Administrator", "owner": "Administrator" }, @@ -230,7 +230,7 @@ "depends_on": "eval:doc.po_no", "doctype": "DocField", "fieldname": "po_date", - "fieldtype": "Data", + "fieldtype": "Date", "hidden": 1, "label": "Customer's Purchase Order Date", "no_copy": 0, @@ -263,7 +263,6 @@ "reqd": 1 }, { - "default": "1.00", "description": "Rate at which customer's currency is converted to company's base currency", "doctype": "DocField", "fieldname": "conversion_rate", diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt index 11846435ce..f228a147c3 100755 --- a/stock/doctype/purchase_receipt/purchase_receipt.txt +++ b/stock/doctype/purchase_receipt/purchase_receipt.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:39", "docstatus": 0, - "modified": "2013-08-09 14:47:05", + "modified": "2013-10-11 13:20:13", "modified_by": "Administrator", "owner": "Administrator" }, @@ -215,7 +215,6 @@ "reqd": 1 }, { - "default": "1.00", "description": "Rate at which supplier's currency is converted to company's base currency", "doctype": "DocField", "fieldname": "conversion_rate", diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 36231bf4f1..9921910a8a 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -432,14 +432,7 @@ def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, c company_currency = webnotes.conn.get_value("Company", company, "default_currency") - # parenthesis for 'OR' are necessary as we want it to evaluate as - # mandatory valid condition and (1st optional valid condition - # or 2nd optional valid condition) - valid_conversion_rate = (conversion_rate and - ((currency == company_currency and conversion_rate == 1.00) - or (currency != company_currency and conversion_rate != 1.00))) - - if not valid_conversion_rate: + if not conversion_rate: msgprint(_('Please enter valid ') + conversion_rate_label + (': ') + ("1 %s = [?] %s" % (currency, company_currency)), raise_exception=True)