[fix] removed validation of conversion rate equals 1 from all transaction

This commit is contained in:
Akhilesh Darjee 2013-10-11 13:34:10 +05:30
parent 93c836c86d
commit 1797cfef63
7 changed files with 15 additions and 50 deletions

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 19:29:05", "creation": "2013-05-24 19:29:05",
"docstatus": 0, "docstatus": 0,
"modified": "2013-10-03 18:54:31", "modified": "2013-10-11 13:12:38",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -225,7 +225,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "1.00",
"description": "Rate at which Customer Currency is converted to customer's base currency", "description": "Rate at which Customer Currency is converted to customer's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -21,8 +21,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
company: wn.defaults.get_default("company"), company: wn.defaults.get_default("company"),
fiscal_year: wn.defaults.get_default("fiscal_year"), fiscal_year: wn.defaults.get_default("fiscal_year"),
is_subcontracted: "No", is_subcontracted: "No",
conversion_rate: 1.0,
plc_conversion_rate: 1.0
}, function(fieldname, value) { }, function(fieldname, value) {
if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname]) if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname])
me.frm.set_value(fieldname, value); me.frm.set_value(fieldname, value);
@ -131,10 +129,16 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
company: function() { company: function() {
if(this.frm.doc.company && this.frm.fields_dict.currency) { if(this.frm.doc.company && this.frm.fields_dict.currency) {
var company_currency = this.get_company_currency();
if(!this.frm.doc.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"); this.frm.script_manager.trigger("currency");
} }
}, },
@ -233,29 +237,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
this.calculate_taxes_and_totals(); 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) { row_id: function(doc, cdt, cdn) {
var tax = wn.model.get_doc(cdt, cdn); var tax = wn.model.get_doc(cdt, cdn);
try { try {
@ -486,12 +467,8 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
} }
var company_currency = this.get_company_currency(); 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) + wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) +
" 1 " + this.frm.doc.currency + " = [?] " + company_currency); " 1 " + this.frm.doc.currency + " = [?] " + company_currency);
} }

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 19:29:08", "creation": "2013-05-24 19:29:08",
"docstatus": 0, "docstatus": 0,
"modified": "2013-09-10 10:46:33", "modified": "2013-10-11 13:21:07",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -257,7 +257,6 @@
"width": "100px" "width": "100px"
}, },
{ {
"default": "1.00",
"description": "Rate at which customer's currency is converted to company's base currency", "description": "Rate at which customer's currency is converted to company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-06-18 12:39:59", "creation": "2013-06-18 12:39:59",
"docstatus": 0, "docstatus": 0,
"modified": "2013-08-09 14:46:17", "modified": "2013-10-11 13:18:47",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -272,7 +272,6 @@
"width": "100px" "width": "100px"
}, },
{ {
"default": "1.00",
"description": "Rate at which customer's currency is converted to company's base currency", "description": "Rate at which customer's currency is converted to company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 19:29:09", "creation": "2013-05-24 19:29:09",
"docstatus": 0, "docstatus": 0,
"modified": "2013-08-09 14:46:32", "modified": "2013-10-11 13:19:40",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -230,7 +230,7 @@
"depends_on": "eval:doc.po_no", "depends_on": "eval:doc.po_no",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "po_date", "fieldname": "po_date",
"fieldtype": "Data", "fieldtype": "Date",
"hidden": 1, "hidden": 1,
"label": "Customer's Purchase Order Date", "label": "Customer's Purchase Order Date",
"no_copy": 0, "no_copy": 0,
@ -263,7 +263,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "1.00",
"description": "Rate at which customer's currency is converted to company's base currency", "description": "Rate at which customer's currency is converted to company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-21 16:16:39", "creation": "2013-05-21 16:16:39",
"docstatus": 0, "docstatus": 0,
"modified": "2013-08-09 14:47:05", "modified": "2013-10-11 13:20:13",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -215,7 +215,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "1.00",
"description": "Rate at which supplier's currency is converted to company's base currency", "description": "Rate at which supplier's currency is converted to company's base currency",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "conversion_rate", "fieldname": "conversion_rate",

View File

@ -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") company_currency = webnotes.conn.get_value("Company", company, "default_currency")
# parenthesis for 'OR' are necessary as we want it to evaluate as if not conversion_rate:
# 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:
msgprint(_('Please enter valid ') + conversion_rate_label + (': ') msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
+ ("1 %s = [?] %s" % (currency, company_currency)), + ("1 %s = [?] %s" % (currency, company_currency)),
raise_exception=True) raise_exception=True)