Merge branch 'develop' into depr-expense-account
diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
index e05e4a1..d8b8606 100644
--- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
@@ -543,6 +543,75 @@
 		frappe.get_doc("Item Price", {"item_code": "Water Flask"}).delete()
 		item.delete()
 
+	def test_pricing_rule_for_different_currency(self):
+		make_item("Test Sanitizer Item")
+
+		pricing_rule_record = {
+			"doctype": "Pricing Rule",
+			"title": "_Test Sanitizer Rule",
+			"apply_on": "Item Code",
+			"items": [{
+				"item_code": "Test Sanitizer Item",
+			}],
+			"selling": 1,
+			"currency": "INR",
+			"rate_or_discount": "Rate",
+			"rate": 0,
+			"priority": 2,
+			"margin_type": "Percentage",
+			"margin_rate_or_amount": 0.0,
+			"company": "_Test Company"
+		}
+
+		rule = frappe.get_doc(pricing_rule_record)
+		rule.rate_or_discount = 'Rate'
+		rule.rate = 100.0
+		rule.insert()
+
+		rule1 = frappe.get_doc(pricing_rule_record)
+		rule1.currency = 'USD'
+		rule1.rate_or_discount = 'Rate'
+		rule1.rate = 2.0
+		rule1.priority = 1
+		rule1.insert()
+
+		args = frappe._dict({
+			"item_code": "Test Sanitizer Item",
+			"company": "_Test Company",
+			"price_list": "_Test Price List",
+			"currency": "USD",
+			"doctype": "Sales Invoice",
+			"conversion_rate": 1,
+			"price_list_currency": "_Test Currency",
+			"plc_conversion_rate": 1,
+			"order_type": "Sales",
+			"customer": "_Test Customer",
+			"name": None,
+			"transaction_date": frappe.utils.nowdate()
+		})
+
+		details = get_item_details(args)
+		self.assertEqual(details.price_list_rate, 2.0)
+
+
+		args = frappe._dict({
+			"item_code": "Test Sanitizer Item",
+			"company": "_Test Company",
+			"price_list": "_Test Price List",
+			"currency": "INR",
+			"doctype": "Sales Invoice",
+			"conversion_rate": 1,
+			"price_list_currency": "_Test Currency",
+			"plc_conversion_rate": 1,
+			"order_type": "Sales",
+			"customer": "_Test Customer",
+			"name": None,
+			"transaction_date": frappe.utils.nowdate()
+		})
+
+		details = get_item_details(args)
+		self.assertEqual(details.price_list_rate, 100.0)
+
 	def test_pricing_rule_for_transaction(self):
 		make_item("Water Flask 1")
 		frappe.delete_doc_if_exists('Pricing Rule', '_Test Pricing Rule')
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index 9655ac4..02bfc9d 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -264,6 +264,11 @@
 			else:
 				p.variant_of = None
 
+	if len(pricing_rules) > 1:
+		filtered_rules = list(filter(lambda x: x.currency==args.get('currency'), pricing_rules))
+		if filtered_rules:
+			pricing_rules = filtered_rules
+
 	# find pricing rule with highest priority
 	if pricing_rules:
 		max_priority = max(cint(p.priority) for p in pricing_rules)
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js
index f9259fb..e3eed92 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.js
+++ b/erpnext/manufacturing/doctype/job_card/job_card.js
@@ -23,12 +23,6 @@
 		);
 	},
 
-	onload: function(frm) {
-		if (frm.doc.scrap_items.length == 0) {
-			frm.fields_dict['scrap_items_section'].collapse();
-		}
-	},
-
 	refresh: function(frm) {
 		frappe.flags.pause_job = 0;
 		frappe.flags.resume_job = 0;
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index d4ad719..2e2b8b7 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -463,11 +463,14 @@
 
 
 def check_credit_limit(customer, company, ignore_outstanding_sales_order=False, extra_amount=0):
+	credit_limit = get_credit_limit(customer, company)
+	if not credit_limit:
+		return
+
 	customer_outstanding = get_customer_outstanding(customer, company, ignore_outstanding_sales_order)
 	if extra_amount > 0:
 		customer_outstanding += flt(extra_amount)
 
-	credit_limit = get_credit_limit(customer, company)
 	if credit_limit > 0 and flt(customer_outstanding) > credit_limit:
 		msgprint(_("Credit limit has been crossed for customer {0} ({1}/{2})")
 			.format(customer, customer_outstanding, credit_limit))
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 5ebfa04..dedd2d3 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -413,7 +413,7 @@
 			frappe.get_attr(module_name)(company, False)
 		except Exception as e:
 			frappe.log_error()
-			frappe.throw(_("Failed to setup defaults for country {0}. Please contact support@erpnext.com").format(frappe.bold(country)))
+			frappe.throw(_("Failed to setup defaults for country {0}. Please contact support.").format(frappe.bold(country)))
 
 
 def update_company_current_month_sales(company):
diff --git a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.html b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.html
index de7e38e..adab478 100644
--- a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.html
+++ b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.html
@@ -1,19 +1,19 @@
 {% for d in data %}
 	<div class="dashboard-list-item" style="padding: 7px 15px;">
 		<div class="row">
-			<div class="col-sm-2 small" style="margin-top: 8px;">
+			<div class="col-sm-2" style="margin-top: 8px;">
 				<a data-type="warehouse" data-name="{{ d.warehouse }}">{{ d.warehouse }}</a>
 			</div>
-			<div class="col-sm-2 small" style="margin-top: 8px; ">
+			<div class="col-sm-2" style="margin-top: 8px; ">
 				<a data-type="item" data-name="{{ d.item_code }}">{{ d.item_code }}</a>
 			</div>
-			<div class="col-sm-1 small" style="margin-top: 8px; ">
+			<div class="col-sm-1" style="margin-top: 8px; ">
 				{{ d.stock_capacity }}
 			</div>
-			<div class="col-sm-2 small" style="margin-top: 8px; ">
+			<div class="col-sm-2" style="margin-top: 8px; ">
 				{{ d.actual_qty }}
 			</div>
-			<div class="col-sm-2 small">
+			<div class="col-sm-2">
 				<div class="progress" title="Occupied Qty: {{ d.actual_qty }}" style="margin-bottom: 4px; height: 7px; margin-top: 14px;">
 					<div class="progress-bar" role="progressbar"
 						aria-valuenow="{{ d.percent_occupied }}"
@@ -23,16 +23,19 @@
 					</div>
 				</div>
 			</div>
-			<div class="col-sm-1 small" style="margin-top: 8px;">
+			<div class="col-sm-1" style="margin-top: 8px;">
 				{{ d.percent_occupied }}%
 			</div>
 			{% if can_write %}
-			<div class="col-sm-1 text-right" style="margin-top: 2px;">
-				<button class="btn btn-default btn-xs btn-edit"
-				style="margin-top: 4px;margin-bottom: 4px;"
-				data-warehouse="{{ d.warehouse }}"
-				data-item="{{ escape(d.item_code) }}"
-				data-company="{{ escape(d.company) }}">{{ __("Edit Capacity") }}</a>
+			<div class="col-sm-2 text-right" style="margin-top: 2px;">
+				<button
+					class="btn btn-default btn-xs btn-edit"
+					style="margin: 4px 0; float: left;"
+					data-warehouse="{{ d.warehouse }}"
+					data-item="{{ escape(d.item_code) }}"
+					data-company="{{ escape(d.company) }}">
+					{{ __("Edit Capacity") }}
+				</button>
 			</div>
 			{% endif %}
 		</div>
diff --git a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js
index c0ffdc9..ea27dd2 100644
--- a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js
+++ b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary.js
@@ -4,7 +4,7 @@
 		title: 'Warehouse Capacity Summary',
 		single_column: true
 	});
-	page.set_secondary_action('Refresh', () => page.capacity_dashboard.refresh(), 'octicon octicon-sync');
+	page.set_secondary_action('Refresh', () => page.capacity_dashboard.refresh(), 'refresh');
 	page.start = 0;
 
 	page.company_field = page.add_field({
diff --git a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary_header.html b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary_header.html
index 7ac5e64..1183ad4 100644
--- a/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary_header.html
+++ b/erpnext/stock/page/warehouse_capacity_summary/warehouse_capacity_summary_header.html
@@ -1,18 +1,18 @@
 <div class="dashboard-list-item" style="padding: 12px 15px;">
 	<div class="row">
-		<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
+		<div class="col-sm-2 text-muted" style="margin-top: 8px;">
 			Warehouse
 		</div>
-		<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
+		<div class="col-sm-2 text-muted" style="margin-top: 8px;">
 			Item
 		</div>
-		<div class="col-sm-1 small text-muted" style="margin-top: 8px;">
+		<div class="col-sm-1 text-muted" style="margin-top: 8px;">
 			Stock Capacity
 		</div>
-		<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
+		<div class="col-sm-2 text-muted" style="margin-top: 8px;">
 			Balance Stock Qty
 		</div>
-		<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
+		<div class="col-sm-2 text-muted" style="margin-top: 8px;">
 			% Occupied
 		</div>
 	</div>