Merge pull request #2379 from nathando/develop

Remove get_server_field from leave_application
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 3fe011f..6c387e4 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1 +1 @@
-__version__ = '4.9.3'
+__version__ = '4.11.0'
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index 7a833f7..825a8dd 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -310,22 +310,19 @@
 		self.total_amount_in_words = money_in_words(amt, company_currency)
 
 	def check_credit_days(self):
-		date_diff = 0
 		if self.cheque_date:
-			date_diff = (getdate(self.cheque_date)-getdate(self.posting_date)).days
-
-		if date_diff <= 0: return
-
-		# Get List of Customer Account
-		acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
-		 	"master_type")=='Customer', self.get('entries'))
-
-		for d in acc_list:
-			credit_days = self.get_credit_days_for(d.account)
-			# Check credit days
-			if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days:
-				msgprint(_("Maximum allowed credit is {0} days after posting date").format(credit_days),
-					raise_exception=1)
+			for d in self.get("entries"):
+				if flt(d.credit) > 0 and d.against_invoice \
+					and frappe.db.get_value("Account", d.account, "master_type")=='Customer':
+						posting_date = frappe.db.get_value("Sales Invoice", d.against_invoice, "posting_date")
+						credit_days = self.get_credit_days_for(d.account)
+						if credit_days:
+							date_diff = (getdate(self.cheque_date) - getdate(posting_date)).days
+							if date_diff > flt(credit_days):
+								msgprint(_("Note: Reference Date exceeds allowed credit days by {0} days for {1}")
+									.format(date_diff - flt(credit_days), d.account))
+								if not self.get_authorized_user():
+									raise frappe.ValidationError
 
 	def get_credit_days_for(self, ac):
 		if not self.credit_days_for.has_key(ac):
@@ -333,8 +330,7 @@
 
 		if not self.credit_days_for[ac]:
 			if self.credit_days_global==-1:
-				self.credit_days_global = cint(frappe.db.get_value("Company",
-					self.company, "credit_days"))
+				self.credit_days_global = cint(frappe.db.get_value("Company", self.company, "credit_days"))
 
 			return self.credit_days_global
 		else:
@@ -343,10 +339,7 @@
 	def get_authorized_user(self):
 		if self.is_approving_authority==-1:
 			self.is_approving_authority = 0
-
-			# Fetch credit controller role
-			approving_authority = frappe.db.get_value("Accounts Settings", None,
-				"credit_controller")
+			approving_authority = frappe.db.get_value("Accounts Settings", None, "credit_controller")
 
 			# Check logged-in user is authorized
 			if approving_authority in frappe.user.get_roles():
diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.py b/erpnext/accounts/doctype/payment_tool/payment_tool.py
index 578a316..4d4d8e8 100644
--- a/erpnext/accounts/doctype/payment_tool/payment_tool.py
+++ b/erpnext/accounts/doctype/payment_tool/payment_tool.py
@@ -3,7 +3,7 @@
 
 from __future__ import unicode_literals
 import frappe
-from frappe import _, scrub
+from frappe import _
 from frappe.utils import flt
 from frappe.model.document import Document
 import json
@@ -93,7 +93,7 @@
 			and docstatus = 1
 			and ifnull(status, "") != "Stopped"
 			and ifnull(grand_total, 0) > ifnull(advance_paid, 0)
-			and ifnull(per_billed, 0) < 100.0
+			and abs(100 - ifnull(per_billed, 0)) > 0.01
 		""" % (voucher_type, 'customer' if party_type == "Customer" else 'supplier', '%s'),
 		party_name, as_dict = True)
 
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 2d7d4e5..05e7625 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -4,7 +4,7 @@
 app_description = "Open Source Enterprise Resource Planning for Small and Midsized Organizations"
 app_icon = "icon-th"
 app_color = "#e74c3c"
-app_version = "4.9.3"
+app_version = "4.11.0"
 
 error_report_email = "support@erpnext.com"
 
diff --git a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py
index e44133e..d6cabd8 100644
--- a/erpnext/patches/v4_2/update_requested_and_ordered_qty.py
+++ b/erpnext/patches/v4_2/update_requested_and_ordered_qty.py
@@ -18,7 +18,7 @@
 					"indented_qty": get_indented_qty(item_code, warehouse),
 					"ordered_qty": get_ordered_qty(item_code, warehouse)
 				})
-				if count / 200 == 0:
+				if count % 200 == 0:
 					frappe.db.commit()
 			except:
 				frappe.db.rollback()
diff --git a/erpnext/translations/hr.csv b/erpnext/translations/hr.csv
index 4f5c050..8728106 100644
--- a/erpnext/translations/hr.csv
+++ b/erpnext/translations/hr.csv
@@ -661,7 +661,7 @@
 Currency exchange rate master.,Majstor valute .

 Current Address,Trenutna adresa

 Current Address Is,Trenutni Adresa je

-Current Assets,Dugotrajna imovina

+Current Assets,Trenutna imovina

 Current BOM,Trenutni BOM

 Current BOM and New BOM can not be same,Trenutni troškovnik i novi troškovnik ne mogu biti isti

 Current Fiscal Year,Tekuće fiskalne godine

diff --git a/setup.py b/setup.py
index 0e13a53..924331f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import os
 
-version = "4.9.3"
+version = "4.11.0"
 
 with open("requirements.txt", "r") as f:
 	install_requires = f.readlines()