Merge pull request #6780 from rohitwaghchaure/float_issue

Change fieldtype from float to currency
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 4c87187..b548693 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.1.3'
+__version__ = '7.1.5'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 083ba6f..145ed81 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -763,7 +763,8 @@
 	return {
 		"account": account,
 		"balance": account_balance,
-		"party_balance": party_balance
+		"party_balance": party_balance,
+		"account_currency": frappe.db.get_value("Account", account, "account_currency")
 	}
 
 @frappe.whitelist()
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index f43a436..4c13fe3 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -392,7 +392,7 @@
 				if(index < 30){
 					$(frappe.render_template("pos_item", {
 						item_code: obj.name,
-						item_price: format_currency(obj.price_list_rate, obj.currency),
+						item_price: format_currency(obj.price_list_rate, me.frm.doc.currency),
 						item_name: obj.name===obj.item_name ? "" : obj.item_name,
 						item_image: obj.image ? "url('" + obj.image + "')" : null,
 						color: frappe.get_palette(obj.item_name),
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index 78af1ef..802888d 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -131,7 +131,8 @@
 
 	def send_email(self, data, sender, subject, message, attachments):
 		make(subject = subject, content=message,recipients=data.email_id, 
-			sender=sender,attachments = attachments, send_email=True)["name"]
+			sender=sender,attachments = attachments, send_email=True,
+		     	doctype=self.doctype, name=self.name)["name"]
 
 		frappe.msgprint(_("Email sent to supplier {0}").format(data.supplier))
 
diff --git a/erpnext/demo/setup/manufacture.py b/erpnext/demo/setup/manufacture.py
index 8ac2039..24ffd92 100644
--- a/erpnext/demo/setup/manufacture.py
+++ b/erpnext/demo/setup/manufacture.py
@@ -63,7 +63,10 @@
 	for i in items:
 		item = frappe.new_doc('Item')
 		item.update(i)
-		item.default_warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.default_warehouse}, limit=1)[0].name
+		if item.default_warehouse:
+			warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.default_warehouse}, limit=1)
+			if warehouse:
+				item.default_warehouse = warehouse[0].name
 		item.insert()
 
 def setup_product_bundle():
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index f25bbc3..278c398 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -41,9 +41,9 @@
 		setup_complete({
 			"first_name": "Test",
 			"last_name": "User",
-			"email": "test_demo@erpnext.com",
+			"email": "demo@erpnext.com",
 			"company_tagline": 'Awesome Products and Services',
-			"password": "test",
+			"password": "demo",
 			"fy_start_date": "2015-01-01",
 			"fy_end_date": "2015-12-31",
 			"bank_account": "National Bank",
diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py
index ac380f2..ea23853 100644
--- a/erpnext/demo/user/stock.py
+++ b/erpnext/demo/user/stock.py
@@ -85,9 +85,10 @@
 
 def submit_draft_stock_entries():
 	from erpnext.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \
-		DuplicateEntryForProductionOrderError, OperationsNotCompleteError
+		DuplicateEntryForProductionOrderError, OperationsNotCompleteError	
 
 	# try posting older drafts (if exists)
+	frappe.db.commit()
 	for st in frappe.db.get_values("Stock Entry", {"docstatus":0}, "name"):
 		try:
 			ste = frappe.get_doc("Stock Entry", st[0])
diff --git a/erpnext/docs/assets/img/articles/withhold-1.png b/erpnext/docs/assets/img/articles/withhold-1.png
new file mode 100644
index 0000000..89b63a0
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/withhold-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/withhold-2.gif b/erpnext/docs/assets/img/articles/withhold-2.gif
new file mode 100644
index 0000000..87a92c1
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/withhold-2.gif
Binary files differ
diff --git a/erpnext/docs/assets/img/stock/projected_quantity.png b/erpnext/docs/assets/img/stock/projected_quantity.png
new file mode 100644
index 0000000..d9879b2
--- /dev/null
+++ b/erpnext/docs/assets/img/stock/projected_quantity.png
Binary files differ
diff --git a/erpnext/docs/assets/img/stock/warehouse.png b/erpnext/docs/assets/img/stock/warehouse.png
index 6b968d3..748cee8 100644
--- a/erpnext/docs/assets/img/stock/warehouse.png
+++ b/erpnext/docs/assets/img/stock/warehouse.png
Binary files differ
diff --git a/erpnext/docs/user/manual/en/accounts/articles/adjust-withhold-amount-payment-entry.md b/erpnext/docs/user/manual/en/accounts/articles/adjust-withhold-amount-payment-entry.md
new file mode 100644
index 0000000..d469b28
--- /dev/null
+++ b/erpnext/docs/user/manual/en/accounts/articles/adjust-withhold-amount-payment-entry.md
@@ -0,0 +1,37 @@
+#Adjust Withhold Amount in the Payment Entry
+
+###Question
+
+Let's assume that outstanding against a Sales Invoice is 20,000. When client makes payment, they will only pay 19,600. Rest 400 will be booked under Withhold account. How to manage this scenario in the Payment Entry.
+
+###Answer
+
+In the Payment Entry, you can mention Withhold Account in the Deductions or Loss table. Detailed steps below.
+
+####Step 1: Setup Withhold Account
+
+Create a Withhold Account in your Chart of Accounts master.
+
+`Accounts > Chart of Accounts'
+
+####Step 2: Payment Entry
+
+To create Payment Entry, go to unpaid Sales Invoice and create click on Make Payment button.
+
+#####Step 2.1: Enter Payment Amount
+
+Enter Payment Amount as 19,600.
+
+<img alt="Sales Invoice Payment Amount" class="screenshot" src="{{docs_base_url}}/assets/img/articles/withhold-1.png">
+
+#####Step 2.2: Allocate Against Sales Invoice
+
+Against Sales Invoice, allocate 20,000 (explained in GIF below).
+
+#####Step 2.3: Add Deduction/Loss Account
+
+You can notice that there is a difference of 400 in the Payment Amount and the Amount Allocated against Sales Invoice. You can book this difference account under Withhold Account.
+
+<img alt="Deduction/Loss Account" class="screenshot" src="{{docs_base_url}}/assets/img/articles/withhold-2.gif">
+
+ Following same steps, you can also manage difference availed due to Currency Exchange Gain/Loss.
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/accounts/articles/index.txt b/erpnext/docs/user/manual/en/accounts/articles/index.txt
index c2fbf70..77474bd 100644
--- a/erpnext/docs/user/manual/en/accounts/articles/index.txt
+++ b/erpnext/docs/user/manual/en/accounts/articles/index.txt
@@ -11,4 +11,5 @@
 update-stock-option-in-sales-invoice
 what-is-the-differences-of-total-and-valuation-in-tax-and-charges
 withdrawing-salary-from-owners-equity-account
+adjust-withhold-amount-payment-entry
 c-form
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/stock/projected-quantity.md b/erpnext/docs/user/manual/en/stock/projected-quantity.md
index 9251a1b..d38bfc9 100644
--- a/erpnext/docs/user/manual/en/stock/projected-quantity.md
+++ b/erpnext/docs/user/manual/en/stock/projected-quantity.md
@@ -11,7 +11,7 @@
 Having a tight control of the projected inventory is crucial to determine
 shortages and to calculate the right order quantity.
 
-![Projected Quantity Stock Report]({{docs_base_url}}/assets/old_images/erpnext/projected-quantity-stock-report.png)
+![Projected Quantity Stock Report]({{docs_base_url}}/assets/img/stock/projected_quantity.png)
 
 
 > Projected Qty = Actual Qty + Planned Qty + Requested Qty + Ordered Qty -
diff --git a/erpnext/docs/user/manual/en/stock/stock-entry.md b/erpnext/docs/user/manual/en/stock/stock-entry.md
index 559f762..a47d863 100644
--- a/erpnext/docs/user/manual/en/stock/stock-entry.md
+++ b/erpnext/docs/user/manual/en/stock/stock-entry.md
@@ -38,6 +38,6 @@
 <img class="screenshot" alt="Additional Costs General Ledger" src="{{docs_base_url}}/assets/img/stock/additional-costs-general-ledger.png">
 
 
-> **Note:** To update Stock from a spreadsheet, see [Stock Reconciliation] ({{doc_base_url}}/user/manual/en/setting-up/stock-reconciliation-for-non-serialized-item.html).
+> **Note:** To update Stock from a spreadsheet, see [Stock Reconciliation]({{doc_base_url}}/user/manual/en/setting-up/stock-reconciliation-for-non-serialized-item.html).
 
 {next}
diff --git a/erpnext/docs/user/manual/en/stock/warehouse.md b/erpnext/docs/user/manual/en/stock/warehouse.md
index d86f401..172e469 100644
--- a/erpnext/docs/user/manual/en/stock/warehouse.md
+++ b/erpnext/docs/user/manual/en/stock/warehouse.md
@@ -4,10 +4,8 @@
 cities, towns, and villages. They mostly have loading docks to load and unload
 goods from trucks.
 
-To go to Warehouse, click on Stock and go to Warehouse under Masters.  You
-could also go to the Setup module and click on Warehouse under Master Data.
-
-> Stock > Warehouse > New Warehouse
+To go to Warehouse, click on Stock and go to Warehouse under Setup.  You
+could also switch to 'Tree' View or simply type warehouse tree in the awsone bar.
 
 <img class="screenshot" alt="Warehouse" src="{{docs_base_url}}/assets/img/stock/warehouse.png">
 
@@ -20,17 +18,6 @@
 wish a particular user to operate on a particular Warehouse, you can refrain
 the user from accessing that Warehouse.
 
-### Merge Warehouse
-
-In day to day transactions, duplicate entries are done by mistake, resulting
-in duplicate Warehouses. Duplicate records can be merged into a single
-Warehouse. From the top bar of the system select the File menu. Select Rename
-and Enter the correct Warehouse and check the Merge button. The system will
-replace all the links of wrong Warehouse with the correct Warehouse, in all
-transactions. Also, the available quantity (actual qty, reserved qty, ordered
-qty etc) of all items in the duplicate warehouse will be transferred to the
-correct warehouse. Once merging is done, delete the duplicate Warehouse.
-
 > Note: ERPNext system maintains stock balance for every distinct combination
 of Item and Warehouse. Thus you can get stock balance for any specific Item in
 a particular Warehouse on any particular date.
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 6d6ae97..86fb88b 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -8,7 +8,7 @@
 
 from frappe import throw, _
 import frappe.defaults
-
+from frappe.utils import getdate
 from erpnext.controllers.buying_controller import BuyingController
 from erpnext.accounts.utils import get_account_currency
 from frappe.desk.notifications import clear_doctype_notifications
@@ -59,7 +59,7 @@
 		pc_obj = frappe.get_doc('Purchase Common')
 		self.check_for_closed_status(pc_obj)
 		
-		if self.posting_date > nowdate():
+		if getdate(self.posting_date) > getdate(nowdate()):
 			throw(_("Posting Date cannot be future date"))
 		
 
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index a60e945..1a3c26c 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -31,7 +31,7 @@
 			item.update(get_bin_details(item.item_code, item.s_warehouse))
 
 	def validate(self):
-		self.pro_doc = None
+		self.pro_doc = frappe._dict()
 		if self.production_order:
 			self.pro_doc = frappe.get_doc('Production Order', self.production_order)
 
@@ -582,7 +582,7 @@
 
 	def set_production_order_details(self):
 		if not getattr(self, "pro_doc", None):
-			self.pro_doc = None
+			self.pro_doc = frappe._dict()
 
 		if self.production_order:
 			# common validations