[fix] call apply price list, apply pricing rule only if price list is mentioned or there are items in the table
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 87cc2f6..49f47e0 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -76,7 +76,7 @@
if(this.frm.doc.__islocal && !(this.frm.doc.taxes || []).length
&& !(this.frm.doc.__onload ? this.frm.doc.__onload.load_after_mapping : false)) {
this.apply_default_taxes();
- } else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"]
+ } else if(this.frm.doc.__islocal && this.frm.doc.company && this.frm.doc["items"]
&& !this.frm.doc.is_pos) {
me.calculate_taxes_and_totals();
}
@@ -507,7 +507,7 @@
}
if(this.frm.fields_dict["advances"]) {
- setup_field_label_map(["advance_amount", "allocated_amount"],
+ setup_field_label_map(["advance_amount", "allocated_amount"],
this.frm.doc.party_account_currency, "advances");
}
@@ -558,9 +558,15 @@
apply_pricing_rule: function(item, calculate_taxes_and_totals) {
var me = this;
+ var args = this._get_args(item);
+ if (!(args.item_list && args.item_list.length)) {
+ if(calculate_taxes_and_totals) me.calculate_taxes_and_totals();
+ return;
+ }
+
return this.frm.call({
method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.apply_pricing_rule",
- args: { args: this._get_args(item) },
+ args: { args: args },
callback: function(r) {
if (!r.exc && r.message) {
me._set_values_for_item_list(r.message);
@@ -648,6 +654,9 @@
apply_price_list: function(item) {
var me = this;
var args = this._get_args(item);
+ if (!((args.item_list && args.item_list.length) || args.price_list)) {
+ return;
+ }
return this.frm.call({
method: "erpnext.stock.get_item_details.apply_price_list",
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index 5b8dd04..e44a53f 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -72,21 +72,20 @@
key = "currency_exchange_rate:{0}:{1}".format(from_currency, to_currency)
value = cache.get(key)
- print value
-
if not value:
import requests
response = requests.get("http://api.fixer.io/latest", params={
"base": from_currency,
"symbols": to_currency
})
- # expire in 24 hours
+ # expire in 6 hours
response.raise_for_status()
value = response.json()["rates"][to_currency]
- cache.setex(key, value, 24 * 60 * 60)
+ cache.setex(key, value, 6 * 60 * 60)
+
return flt(value)
except:
- frappe.msgprint(_("Unable to find exchange rate"))
+ frappe.msgprint(_("Unable to find exchange rate for {0} to {1}").format(from_currency, to_currency))
return 0.0
else:
return value
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 6c6f84b..71bc64a 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -69,7 +69,7 @@
if args.get("is_subcontracted") == "Yes":
out.bom = get_default_bom(args.item_code)
-
+
return out
def process_args(args):
@@ -427,6 +427,9 @@
return result.currency
def get_price_list_currency_and_exchange_rate(args):
+ if not args.price_list:
+ return {}
+
price_list_currency = get_price_list_currency(args.price_list)
plc_conversion_rate = args.plc_conversion_rate