Merge pull request #2463 from Steggur/develop

first is translation commit
diff --git a/.travis.yml b/.travis.yml
index c136aa0..45410d5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,8 +16,9 @@
   - sudo apt-get install mariadb-server mariadb-common libmariadbclient-dev
   - ./ci/fix-mariadb.sh
 
-  - wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-precise-amd64.deb
-  - sudo dpkg -i wkhtmltox-0.12.1_linux-precise-amd64.deb
+  - sudo apt-get install xfonts-75dpi xfonts-base -y
+  - wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2/wkhtmltox-0.12.2_linux-precise-amd64.deb
+  - sudo dpkg -i wkhtmltox-0.12.2_linux-precise-amd64.deb
   - CFLAGS=-O0 pip install git+https://github.com/frappe/frappe.git@develop
   - CFLAGS=-O0 pip install --editable .
 
diff --git a/README.md b/README.md
index b9d5a6e..efa3e33 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,31 @@
-# ERPNext - Open Source ERP for small, medium sized businesses [![Build Status](https://travis-ci.org/frappe/erpnext.png)](https://travis-ci.org/frappe/erpnext)
+# ERPNext - Open source ERP for small and medium-size business [![Build Status](https://travis-ci.org/frappe/erpnext.png)](https://travis-ci.org/frappe/erpnext)
 
 [https://erpnext.com](https://erpnext.com)
 
-Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Built on Python / MariaDB.
+Includes: Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Requires MariaDB.
 
-ERPNext is built on [frappe](https://github.com/frappe/frappe) Python Framework.
+ERPNext is built on the [Frappe](https://github.com/frappe/frappe) Framework, a full-stack web app framework in Python & Javascript.
 
-- [User Guide](http://erpnext.org/user-guide.html)
+- [User Guide](https://erpnext.com/user-guide)
 - [Getting Help](http://erpnext.org/getting-help.html)
-- [Developer Forum](http://groups.google.com/group/erpnext-developer-forum)
-- [User Forum](http://groups.google.com/group/erpnext-user-forum)
+- [Discussion Forum](https://discuss.frappe.io/)
 
 ---
 
-### Install
+### Full Install
 
-Use the bench, https://github.com/frappe/bench
+The Easy Way install script for bench will install all dependencies (e.g. MariaDB). See https://github.com/frappe/bench
 
-### Admin Login
+New passwords will be created for the ERPNext "Administrator" user, the MariaDB root user, and the frappe user (the script displays the passwords and saves them to ~/frappe_passwords.txt).
 
-1. go to "/login"
-1. Administrator user name: "Administrator"
-1. Administrator password: "admin"
+### Virtual Image
 
-### Download and Install
-
-##### Virtual Image:
+You can download a virtual image to run ERPNext in a virtual machine on your local system.
 
 - [ERPNext Download](http://erpnext.com/download)
 
+System and user credentials are listed on the download page.
+
 ---
 
 ## License
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index e8de3f4..f50f14b 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1 +1 @@
-__version__ = '4.12.0'
+__version__ = '4.18.1'
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 7195db8..3874ac2 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -3,7 +3,7 @@
 
 from __future__ import unicode_literals
 import frappe
-from frappe.utils import flt, cstr, cint, getdate, add_days, formatdate
+from frappe.utils import flt, cstr, cint, getdate
 from frappe import msgprint, throw, _
 from frappe.model.document import Document
 
@@ -176,15 +176,7 @@
 			frappe.throw(_("Due Date cannot be before Posting Date"))
 
 		elif credit_days is not None and diff > credit_days:
-			is_credit_controller = frappe.db.get_value("Accounts Settings", None,
-				"credit_controller") in frappe.user.get_roles()
-
-			if is_credit_controller:
-				msgprint(_("Note: Due Date exceeds the allowed credit days by {0} day(s)").format(
-					diff - credit_days))
-			else:
-				max_due_date = formatdate(add_days(posting_date, credit_days))
-				frappe.throw(_("Due Date cannot be after {0}").format(max_due_date))
+			msgprint(_("Note: Due Date exceeds the allowed credit days by {0} day(s)").format(diff - credit_days))
 
 	def validate_trash(self):
 		"""checks gl entries and if child exists"""
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.js b/erpnext/accounts/doctype/sales_invoice/pos.js
index d9ef6d8..e7cbcb7 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.js
+++ b/erpnext/accounts/doctype/sales_invoice/pos.js
@@ -492,7 +492,7 @@
 		});
 
 		me.refresh_delete_btn();
-		if(me.frm.doc[this.party]) {
+		if(me.frm.doc[this.party.toLowerCase()]) {
 			this.barcode.$input.focus();
 		} else {
 			this.party_field.$input.focus();
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index cc841e2..a50d69e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -225,8 +225,7 @@
 // Hide Fields
 // ------------
 cur_frm.cscript.hide_fields = function(doc) {
-	par_flds = ['project_name', 'due_date', 'is_opening', 'source', 'total_advance', 'gross_profit',
-	'gross_profit_percent', 'get_advances_received',
+	par_flds = ['project_name', 'due_date', 'is_opening', 'source', 'total_advance', 'get_advances_received',
 	'advance_adjustment_details', 'sales_partner', 'commission_rate',
 	'total_commission', 'advances', 'from_date', 'to_date'];
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 3dcf136..9f70c70 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -423,6 +423,15 @@
    "permlevel": 0
   }, 
   {
+   "fieldname": "other_charges_total_export", 
+   "fieldtype": "Currency", 
+   "label": "Total Taxes and Charges", 
+   "options": "currency", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "other_charges_total", 
    "fieldtype": "Currency", 
    "label": "Total Taxes and Charges (Company Currency)", 
@@ -439,23 +448,24 @@
    "permlevel": 0
   }, 
   {
-   "fieldname": "other_charges_total_export", 
-   "fieldtype": "Currency", 
-   "label": "Total Taxes and Charges", 
-   "options": "currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1
-  }, 
-  {
    "fieldname": "discount_amount", 
    "fieldtype": "Currency", 
    "label": "Discount Amount", 
-   "options": "Company:company:default_currency", 
+   "options": "currency", 
    "permlevel": 0, 
    "print_hide": 0
   }, 
   {
+   "fieldname": "base_discount_amount", 
+   "fieldtype": "Currency", 
+   "label": "Discount Amount (Company Currency)", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "totals", 
    "fieldtype": "Section Break", 
    "label": "Totals", 
@@ -569,27 +579,6 @@
    "read_only": 1
   }, 
   {
-   "fieldname": "gross_profit", 
-   "fieldtype": "Currency", 
-   "label": "Gross Profit", 
-   "oldfieldname": "gross_profit", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1
-  }, 
-  {
-   "fieldname": "gross_profit_percent", 
-   "fieldtype": "Float", 
-   "label": "Gross Profit (%)", 
-   "oldfieldname": "gross_profit_percent", 
-   "oldfieldtype": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1
-  }, 
-  {
    "fieldname": "advances", 
    "fieldtype": "Section Break", 
    "label": "Advances", 
@@ -1213,7 +1202,7 @@
  "icon": "icon-file-text", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2014-10-10 16:54:22.284284", 
+ "modified": "2015-01-12 17:34:36.353241", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice", 
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
index 7bde84f..d820c87 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
@@ -1,155 +1,156 @@
 {
- "autoname": "INVTD.######",
- "creation": "2013-04-24 11:39:32",
- "docstatus": 0,
- "doctype": "DocType",
+ "autoname": "INVTD.######", 
+ "creation": "2013-04-24 11:39:32", 
+ "docstatus": 0, 
+ "doctype": "DocType", 
  "fields": [
   {
-   "fieldname": "charge_type",
-   "fieldtype": "Select",
-   "in_list_view": 1,
-   "label": "Type",
-   "oldfieldname": "charge_type",
-   "oldfieldtype": "Select",
-   "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total",
-   "permlevel": 0,
+   "fieldname": "charge_type", 
+   "fieldtype": "Select", 
+   "in_list_view": 1, 
+   "label": "Type", 
+   "oldfieldname": "charge_type", 
+   "oldfieldtype": "Select", 
+   "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", 
+   "permlevel": 0, 
    "reqd": 1
-  },
+  }, 
   {
-   "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1",
-   "fieldname": "row_id",
-   "fieldtype": "Data",
-   "hidden": 0,
-   "label": "Reference Row #",
-   "oldfieldname": "row_id",
-   "oldfieldtype": "Data",
+   "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1", 
+   "fieldname": "row_id", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "label": "Reference Row #", 
+   "oldfieldname": "row_id", 
+   "oldfieldtype": "Data", 
    "permlevel": 0
-  },
+  }, 
   {
-   "fieldname": "description",
-   "fieldtype": "Small Text",
-   "in_list_view": 1,
-   "label": "Description",
-   "oldfieldname": "description",
-   "oldfieldtype": "Small Text",
-   "permlevel": 0,
-   "print_width": "300px",
-   "reqd": 1,
+   "fieldname": "description", 
+   "fieldtype": "Small Text", 
+   "in_list_view": 1, 
+   "label": "Description", 
+   "oldfieldname": "description", 
+   "oldfieldtype": "Small Text", 
+   "permlevel": 0, 
+   "print_width": "300px", 
+   "reqd": 1, 
    "width": "300px"
-  },
+  }, 
   {
-   "fieldname": "col_break_1",
-   "fieldtype": "Column Break",
-   "permlevel": 0,
+   "fieldname": "col_break_1", 
+   "fieldtype": "Column Break", 
+   "permlevel": 0, 
    "width": "50%"
-  },
+  }, 
   {
-   "fieldname": "account_head",
-   "fieldtype": "Link",
-   "in_list_view": 0,
-   "label": "Account Head",
-   "oldfieldname": "account_head",
-   "oldfieldtype": "Link",
-   "options": "Account",
-   "permlevel": 0,
-   "reqd": 1,
+   "fieldname": "account_head", 
+   "fieldtype": "Link", 
+   "in_list_view": 0, 
+   "label": "Account Head", 
+   "oldfieldname": "account_head", 
+   "oldfieldtype": "Link", 
+   "options": "Account", 
+   "permlevel": 0, 
+   "reqd": 1, 
    "search_index": 1
-  },
+  }, 
   {
-   "default": ":Company",
-   "fieldname": "cost_center",
-   "fieldtype": "Link",
-   "in_list_view": 0,
-   "label": "Cost Center",
-   "oldfieldname": "cost_center_other_charges",
-   "oldfieldtype": "Link",
-   "options": "Cost Center",
+   "default": ":Company", 
+   "fieldname": "cost_center", 
+   "fieldtype": "Link", 
+   "in_list_view": 0, 
+   "label": "Cost Center", 
+   "oldfieldname": "cost_center_other_charges", 
+   "oldfieldtype": "Link", 
+   "options": "Cost Center", 
    "permlevel": 0
-  },
+  }, 
   {
-   "fieldname": "rate",
-   "fieldtype": "Float",
-   "in_list_view": 1,
-   "label": "Rate",
-   "oldfieldname": "rate",
-   "oldfieldtype": "Currency",
-   "permlevel": 0,
+   "fieldname": "rate", 
+   "fieldtype": "Float", 
+   "in_list_view": 1, 
+   "label": "Rate", 
+   "oldfieldname": "rate", 
+   "oldfieldtype": "Currency", 
+   "permlevel": 0, 
    "reqd": 1
-  },
+  }, 
   {
-   "fieldname": "tax_amount",
-   "fieldtype": "Currency",
-   "in_list_view": 1,
-   "label": "Amount",
-   "oldfieldname": "tax_amount",
-   "oldfieldtype": "Currency",
-   "options": "Company:company:default_currency",
-   "permlevel": 0,
-   "read_only": 1,
+   "fieldname": "tax_amount", 
+   "fieldtype": "Currency", 
+   "in_list_view": 1, 
+   "label": "Amount", 
+   "oldfieldname": "tax_amount", 
+   "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "read_only": 1, 
    "reqd": 0
-  },
+  }, 
   {
-   "fieldname": "total",
-   "fieldtype": "Currency",
-   "label": "Total",
-   "oldfieldname": "total",
-   "oldfieldtype": "Currency",
-   "options": "Company:company:default_currency",
-   "permlevel": 0,
+   "fieldname": "total", 
+   "fieldtype": "Currency", 
+   "label": "Total", 
+   "oldfieldname": "total", 
+   "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
    "read_only": 1
-  },
+  }, 
   {
-   "allow_on_submit": 0,
-   "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",
-   "fieldname": "included_in_print_rate",
-   "fieldtype": "Check",
-   "label": "Is this Tax included in Basic Rate?",
-   "no_copy": 0,
-   "permlevel": 0,
-   "print_hide": 1,
-   "print_width": "150px",
-   "report_hide": 1,
+   "allow_on_submit": 0, 
+   "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", 
+   "fieldname": "included_in_print_rate", 
+   "fieldtype": "Check", 
+   "label": "Is this Tax included in Basic Rate?", 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "print_width": "150px", 
+   "report_hide": 1, 
    "width": "150px"
-  },
+  }, 
   {
-   "fieldname": "tax_amount_after_discount_amount",
-   "fieldtype": "Currency",
-   "hidden": 1,
-   "label": "Tax Amount After Discount Amount",
-   "options": "Company:company:default_currency",
-   "permlevel": 0,
+   "depends_on": "eval:parent.discount_amount", 
+   "fieldname": "tax_amount_after_discount_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "label": "Tax Amount After Discount Amount", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
    "read_only": 1
-  },
+  }, 
   {
-   "fieldname": "item_wise_tax_detail",
-   "fieldtype": "Small Text",
-   "hidden": 1,
-   "label": "Item Wise Tax Detail",
-   "oldfieldname": "item_wise_tax_detail",
-   "oldfieldtype": "Small Text",
-   "permlevel": 0,
+   "fieldname": "item_wise_tax_detail", 
+   "fieldtype": "Small Text", 
+   "hidden": 1, 
+   "label": "Item Wise Tax Detail", 
+   "oldfieldname": "item_wise_tax_detail", 
+   "oldfieldtype": "Small Text", 
+   "permlevel": 0, 
    "read_only": 1
-  },
+  }, 
   {
-   "fieldname": "parenttype",
-   "fieldtype": "Data",
-   "hidden": 1,
-   "in_filter": 1,
-   "label": "Parenttype",
-   "oldfieldname": "parenttype",
-   "oldfieldtype": "Data",
-   "permlevel": 0,
-   "print_hide": 1,
+   "fieldname": "parenttype", 
+   "fieldtype": "Data", 
+   "hidden": 1, 
+   "in_filter": 1, 
+   "label": "Parenttype", 
+   "oldfieldname": "parenttype", 
+   "oldfieldtype": "Data", 
+   "permlevel": 0, 
+   "print_hide": 1, 
    "search_index": 1
   }
- ],
- "hide_heading": 1,
- "idx": 1,
- "istable": 1,
- "modified": "2014-05-30 03:43:39.740638",
- "modified_by": "Administrator",
- "module": "Accounts",
- "name": "Sales Taxes and Charges",
- "owner": "Administrator",
+ ], 
+ "hide_heading": 1, 
+ "idx": 1, 
+ "istable": 1, 
+ "modified": "2014-12-10 12:26:41.222471", 
+ "modified_by": "Administrator", 
+ "module": "Accounts", 
+ "name": "Sales Taxes and Charges", 
+ "owner": "Administrator", 
  "permissions": []
-}
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
index d11bf29..f4e14b8 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
@@ -46,17 +46,17 @@
 		var new_val = flt(val)/flt(doc.conversion_rate);
 		return new_val;
 	}
-	
+
 	function print_hide(fieldname) {
 		var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
 		return doc_field.print_hide;
 	}
-	
+
 	out ='';
 	if (!doc.print_without_amount) {
 		var cl = doc.other_charges || [];
 
-		// outer table	
+		// outer table
 		var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
 
 		// main table
@@ -77,12 +77,12 @@
 
 		// Discount Amount
 		if(!print_hide('discount_amount') && doc.discount_amount)
-			out += make_row('Discount Amount', convert_rate(doc.discount_amount), 0);
+			out += make_row('Discount Amount', doc.discount_amount, 0);
 
 		// grand total
 		if(!print_hide('grand_total_export'))
 			out += make_row('Grand Total', doc.grand_total_export, 1);
-		
+
 		if(!print_hide('rounded_total_export'))
 			out += make_row('Rounded Total', doc.rounded_total_export, 1);
 
@@ -92,7 +92,7 @@
 			out += '<table><tr><td style="width:25%;"><b>In Words</b></td>';
 			out += '<td style="width:50%;">' + doc.in_words_export + '</td></tr>';
 		}
-		out += '</table></td></tr></table></div>';	 
+		out += '</table></td></tr></table></div>';
 	}
 	return out;
 }
@@ -139,14 +139,14 @@
 			"account_type": ["Tax", "Chargeable", "Income Account"],
 			"company": doc.company
 		}
-	}	
+	}
 }
 
 cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
 	return{
 		'company': doc.company,
 		'group_or_ledger': "Ledger"
-	}	
+	}
 }
 
 cur_frm.cscript.rate = function(doc, cdt, cdn) {
diff --git a/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json b/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json
index ce61fa1..5b4d2f8 100755
--- a/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json
+++ b/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json
@@ -3,9 +3,9 @@
  "doc_type": "Journal Voucher", 
  "docstatus": 0, 
  "doctype": "Print Format", 
- "html": "<div style=\"position: relative\">\n\n\t{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n<div class=\"page-break\">\n    {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n        and doc.set(\"select_print_heading\", _(\"Payment Advice\")) -%}{%- endif -%}\n    {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n{%- for label, value in (\n        (_(\"Voucher Date\"), frappe.utils.formatdate(doc.voucher_date)),\n        (_(\"Reference / Cheque No.\"), doc.cheque_no),\n        (_(\"Reference / Cheque Date\"), frappe.utils.formatdate(doc.cheque_date))\n    ) -%}\n    <div class=\"row\">\n        <div class=\"col-sm-4\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-sm-8\">{{ value }}</div>\n    </div>\n{%- endfor -%}\n\t<hr>\n\t<p>{{ _(\"This amount is in full / part settlement of the listed bills\") }}:</p>\n{%- for label, value in (\n         (_(\"Amount\"), \"<strong>\" + (doc.total_amount or \"\") + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n        (_(\"References\"), doc.remark)\n    ) -%}\n    <div class=\"row\">\n        <div class=\"col-sm-4\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-sm-8\">{{ value }}</div>\n    </div>\n    {%- endfor -%}\n    <hr>\n\t<div style=\"position: absolute; top: 14cm; left: 0cm;\">\n\t\tPrepared By</div>\n\t<div style=\"position: absolute; top: 14cm; left: 5.5cm;\">\n\t\tAuthorised Signatory</div>\n\t<div style=\"position: absolute; top: 14cm; left: 11cm;\">\n\t\tReceived Payment as Above</div>\n\t<div style=\"position: absolute; top: 16.4cm; left: 5.9cm;\">\n\t\t<strong>_____________</strong></div>\n\t<div style=\"position: absolute; top: 16.7cm; left: 6cm;\">\n\t\t<strong>A/C Payee</strong></div>\n\t<div style=\"position: absolute; top: 16.7cm; left: 5.9cm;\">\n\t\t<strong>_____________</strong></div>\n\t<div style=\"position: absolute; top: 16.9cm; left: 12cm;\">\n\t\t{{ frappe.utils.formatdate(doc.cheque_date) }}</div>\n\t<div style=\"position: absolute; top: 17.9cm; left: 1cm;\">\n\t\t{{ doc.pay_to_recd_from }}</div>\n\t<div style=\"position: absolute; top: 18.6cm; left: 1cm; width: 7cm;\">\n\t\t{{ doc.total_amount_in_words }}</div>\n\t<div style=\"position: absolute; top: 19.7cm; left: 12cm;\">\n\t\t{{ doc.total_amount }}</div>\n</div>", 
+ "html": "<div style=\"position: relative\">\n\n\t{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n<div class=\"page-break\">\n    {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n        and doc.set(\"select_print_heading\", _(\"Payment Advice\")) -%}{%- endif -%}\n    {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n{%- for label, value in (\n        (_(\"Voucher Date\"), frappe.utils.formatdate(doc.voucher_date)),\n        (_(\"Reference / Cheque No.\"), doc.cheque_no),\n        (_(\"Reference / Cheque Date\"), frappe.utils.formatdate(doc.cheque_date))\n    ) -%}\n    <div class=\"row\">\n        <div class=\"col-xs-4\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-xs-8\">{{ value }}</div>\n    </div>\n{%- endfor -%}\n\t<hr>\n\t<p>{{ _(\"This amount is in full / part settlement of the listed bills\") }}:</p>\n{%- for label, value in (\n         (_(\"Amount\"), \"<strong>\" + (doc.total_amount or \"\") + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n        (_(\"References\"), doc.remark)\n    ) -%}\n    <div class=\"row\">\n        <div class=\"col-xs-4\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-xs-8\">{{ value }}</div>\n    </div>\n    {%- endfor -%}\n    <hr>\n\t<div style=\"position: absolute; top: 14cm; left: 0cm;\">\n\t\tPrepared By</div>\n\t<div style=\"position: absolute; top: 14cm; left: 5.5cm;\">\n\t\tAuthorised Signatory</div>\n\t<div style=\"position: absolute; top: 14cm; left: 11cm;\">\n\t\tReceived Payment as Above</div>\n\t<div style=\"position: absolute; top: 16.4cm; left: 5.9cm;\">\n\t\t<strong>_____________</strong></div>\n\t<div style=\"position: absolute; top: 16.7cm; left: 6cm;\">\n\t\t<strong>A/C Payee</strong></div>\n\t<div style=\"position: absolute; top: 16.7cm; left: 5.9cm;\">\n\t\t<strong>_____________</strong></div>\n\t<div style=\"position: absolute; top: 16.9cm; left: 12cm;\">\n\t\t{{ frappe.utils.formatdate(doc.cheque_date) }}</div>\n\t<div style=\"position: absolute; top: 17.9cm; left: 1cm;\">\n\t\t{{ doc.pay_to_recd_from }}</div>\n\t<div style=\"position: absolute; top: 18.6cm; left: 1cm; width: 7cm;\">\n\t\t{{ doc.total_amount_in_words }}</div>\n\t<div style=\"position: absolute; top: 19.7cm; left: 12cm;\">\n\t\t{{ doc.total_amount }}</div>\n</div>", 
  "idx": 1, 
- "modified": "2014-09-09 03:27:13.708596", 
+ "modified": "2015-01-12 11:03:17.032512", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Cheque Printing Format", 
diff --git a/erpnext/accounts/print_format/credit_note/credit_note.json b/erpnext/accounts/print_format/credit_note/credit_note.json
index ac0de75..e6c9e8f 100644
--- a/erpnext/accounts/print_format/credit_note/credit_note.json
+++ b/erpnext/accounts/print_format/credit_note/credit_note.json
@@ -4,9 +4,9 @@
  "doc_type": "Journal Voucher", 
  "docstatus": 0, 
  "doctype": "Print Format", 
- "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n\n<div class=\"page-break\">\n    {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n        and doc.set(\"select_print_heading\", _(\"Credit Note\")) -%}{%- endif -%}\n    {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n    {%- for label, value in (\n        (_(\"Credit To\"), doc.pay_to_recd_from),\n        (_(\"Date\"), frappe.utils.formatdate(doc.voucher_date)),\n        (_(\"Amount\"), \"<strong>\" + frappe.utils.cstr(doc.total_amount) + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n        (_(\"Remarks\"), doc.remark)\n    ) -%}\n\n    <div class=\"row\">\n        <div class=\"col-sm-3\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-sm-9\">{{ value }}</div>\n    </div>\n\n    {%- endfor -%}\n\n    <hr>\n    <br>\n    <p class=\"strong\">\n        {{ _(\"For\") }} {{ doc.company }},<br>\n        <br>\n        <br>\n        <br>\n        {{ _(\"Authorized Signatory\") }}\n    </p>\n</div>\n\n\n", 
+ "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n\n<div class=\"page-break\">\n    {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n        and doc.set(\"select_print_heading\", _(\"Credit Note\")) -%}{%- endif -%}\n    {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n    {%- for label, value in (\n        (_(\"Credit To\"), doc.pay_to_recd_from),\n        (_(\"Date\"), frappe.utils.formatdate(doc.voucher_date)),\n        (_(\"Amount\"), \"<strong>\" + frappe.utils.cstr(doc.total_amount) + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n        (_(\"Remarks\"), doc.remark)\n    ) -%}\n\n    <div class=\"row\">\n        <div class=\"col-xs-3\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-xs-9\">{{ value }}</div>\n    </div>\n\n    {%- endfor -%}\n\n    <hr>\n    <br>\n    <p class=\"strong\">\n        {{ _(\"For\") }} {{ doc.company }},<br>\n        <br>\n        <br>\n        <br>\n        {{ _(\"Authorized Signatory\") }}\n    </p>\n</div>\n\n\n", 
  "idx": 2, 
- "modified": "2014-10-17 17:20:02.740340", 
+ "modified": "2015-01-12 11:02:25.716825", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Credit Note", 
diff --git a/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.json b/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.json
index 5c0a72a..310a4df 100755
--- a/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.json
+++ b/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.json
@@ -1,15 +1,15 @@
 {
- "creation": "2012-05-01 12:46:31", 
- "doc_type": "Journal Voucher", 
- "docstatus": 0, 
- "doctype": "Print Format", 
- "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n<div class=\"page-break\">\n    {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n        and doc.set(\"select_print_heading\", _(\"Payment Receipt Note\")) -%}{%- endif -%}\n    {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n    {%- for label, value in (\n        (_(\"Received On\"), frappe.utils.formatdate(doc.voucher_date)),\n        (_(\"Received From\"), doc.pay_to_recd_from),\n        (_(\"Amount\"), \"<strong>\" + doc.total_amount or 0 + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n        (_(\"Remarks\"), doc.remark)\n    ) -%}\n    <div class=\"row\">\n        <div class=\"col-sm-3\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-sm-9\">{{ value }}</div>\n    </div>\n\n    {%- endfor -%}\n\n    <hr>\n    <br>\n    <p class=\"strong\">\n        {{ _(\"For\") }} {{ doc.company }},<br>\n        <br>\n        <br>\n        <br>\n        {{ _(\"Authorized Signatory\") }}\n    </p>\n</div>\n\n", 
- "idx": 1, 
- "modified": "2014-11-04 11:25:57.560873", 
- "modified_by": "Administrator", 
- "module": "Accounts", 
- "name": "Payment Receipt Voucher", 
- "owner": "Administrator", 
- "print_format_type": "Server", 
+ "creation": "2012-05-01 12:46:31",
+ "doc_type": "Journal Voucher",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n<div class=\"page-break\">\n    {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n        and doc.set(\"select_print_heading\", _(\"Payment Receipt Note\")) -%}{%- endif -%}\n    {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n    {%- for label, value in (\n        (_(\"Received On\"), frappe.utils.formatdate(doc.voucher_date)),\n        (_(\"Received From\"), doc.pay_to_recd_from),\n        (_(\"Amount\"), \"<strong>\" + frappe.utils.cstr(doc.total_amount or 0) + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n        (_(\"Remarks\"), doc.remark)\n    ) -%}\n    <div class=\"row\">\n        <div class=\"col-xs-3\"><label class=\"text-right\">{{ label }}</label></div>\n        <div class=\"col-xs-9\">{{ value }}</div>\n    </div>\n\n    {%- endfor -%}\n\n    <hr>\n    <br>\n    <p class=\"strong\">\n        {{ _(\"For\") }} {{ doc.company }},<br>\n        <br>\n        <br>\n        <br>\n        {{ _(\"Authorized Signatory\") }}\n    </p>\n</div>\n\n",
+ "idx": 1,
+ "modified": "2015-01-16 11:03:22.893209",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Payment Receipt Voucher",
+ "owner": "Administrator",
+ "print_format_type": "Server",
  "standard": "Yes"
-}
\ No newline at end of file
+}
diff --git a/erpnext/accounts/print_format/pos_invoice/pos_invoice.json b/erpnext/accounts/print_format/pos_invoice/pos_invoice.json
index 83174b6..50b72d5 100644
--- a/erpnext/accounts/print_format/pos_invoice/pos_invoice.json
+++ b/erpnext/accounts/print_format/pos_invoice/pos_invoice.json
@@ -3,9 +3,9 @@
  "doc_type": "Sales Invoice", 
  "docstatus": 0, 
  "doctype": "Print Format", 
- "html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ doc.company }}<br>\n\t{{ doc.select_print_heading or _(\"Invoice\") }}<br>\n</p>\n<p>\n\t<b>{{ _(\"Receipt No\") }}:</b> {{ doc.name }}<br>\n\t<b>{{ _(\"Date\") }}:</b> {{ doc.get_formatted(\"posting_date\") }}<br>\n\t<b>{{ _(\"Customer\") }}:</b> {{ doc.customer_name }}\n</p>\n\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"60%\">{{ _(\"Item\") }}</b></th>\n\t\t\t<th width=\"10%\" class=\"text-right\">{{ _(\"Qty\") }}</th>\n\t\t\t<th width=\"30%\" class=\"text-right\">{{ _(\"Rate\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{%- for item in doc.entries -%}\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t<br>{{ item.item_name }}{%- endif -%}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ item.qty }}</td>\n\t\t\t<td class=\"text-right\">{{ item.amount }}</td>\n\t\t</tr>\n\t\t{%- endfor -%}\n\t</tbody>\n</table>\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ _(\"Net Total\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"net_total_export\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- for row in doc.other_charges -%}\n\t\t{%- if not row.included_in_print_rate -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t{%- endfor -%}\n\t\t{%- if doc.discount_amount -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t<b>{{ _(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"grand_total_export\") }}\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n{% if doc.get(\"other_charges\", filters={\"included_in_print_rate\": 1}) %}\n<hr>\n<p><b>Taxes Included:</b></p>\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t{%- for row in doc.other_charges -%}\n\t\t{%- if row.included_in_print_rate -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t</td>\n\t\t<tr>\n\t\t{%- endif -%}\n\t\t{%- endfor -%}\n\t</tbody>\n</table>\n{%- endif -%}\n<hr>\n<p>{{ doc.terms or \"\" }}</p>\n<p class=\"text-center\">{{ _(\"Thank you, please visit again.\") }}</p>", 
+ "html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ doc.company }}<br>\n\t{{ doc.select_print_heading or _(\"Invoice\") }}<br>\n</p>\n<p>\n\t<b>{{ _(\"Receipt No\") }}:</b> {{ doc.name }}<br>\n\t<b>{{ _(\"Date\") }}:</b> {{ doc.get_formatted(\"posting_date\") }}<br>\n\t<b>{{ _(\"Customer\") }}:</b> {{ doc.customer_name }}\n</p>\n\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"60%\">{{ _(\"Item\") }}</b></th>\n\t\t\t<th width=\"10%\" class=\"text-right\">{{ _(\"Qty\") }}</th>\n\t\t\t<th width=\"30%\" class=\"text-right\">{{ _(\"Rate\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{%- for item in doc.entries -%}\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t<br>{{ item.item_name }}{%- endif -%}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ item.qty }}</td>\n\t\t\t<td class=\"text-right\">{{ item.amount }}</td>\n\t\t</tr>\n\t\t{%- endfor -%}\n\t</tbody>\n</table>\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ _(\"Net Total\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"net_total_export\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- for row in doc.other_charges -%}\n\t\t{%- if not row.included_in_print_rate -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t{%- endfor -%}\n\t\t{%- if doc.discount_amount -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t<b>{{ _(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"grand_total_export\") }}\n\t\t\t</td>\n\t\t</tr>\n\t</tbody>\n</table>\n{% if doc.get(\"other_charges\", filters={\"included_in_print_rate\": 1}) %}\n<hr>\n<p><b>Taxes Included:</b></p>\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t{%- for row in doc.other_charges -%}\n\t\t{%- if row.included_in_print_rate -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t{{ row.description }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ row.get_formatted(\"tax_amount_after_discount_amount\", doc) }}\n\t\t\t</td>\n\t\t<tr>\n\t\t{%- endif -%}\n\t\t{%- endfor -%}\n\t</tbody>\n</table>\n{%- endif -%}\n<hr>\n<p>{{ doc.terms or \"\" }}</p>\n<p class=\"text-center\">{{ _(\"Thank you, please visit again.\") }}</p>", 
  "idx": 1, 
- "modified": "2014-07-22 02:08:26.603223", 
+ "modified": "2014-12-10 12:37:10.854370", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "POS Invoice", 
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 3dc81d1..a546799 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -13,17 +13,17 @@
 		self.age_as_on = getdate(nowdate()) \
 			if self.filters.report_date > getdate(nowdate()) \
 			else self.filters.report_date
-			
+
 	def run(self):
 		customer_naming_by = frappe.db.get_value("Selling Settings", None, "cust_master_name")
 		return self.get_columns(customer_naming_by), self.get_data(customer_naming_by)
-		
+
 	def get_columns(self, customer_naming_by):
 		columns = [
 			_("Posting Date") + ":Date:80", _("Account") + ":Link/Account:150",
 			_("Voucher Type") + "::110", _("Voucher No") + ":Dynamic Link/Voucher Type:120",
-			_("Due Date") + ":Date:80",  
-			_("Invoiced Amount") + ":Currency:100", _("Payment Received") + ":Currency:100", 
+			_("Due Date") + ":Date:80",
+			_("Invoiced Amount") + ":Currency:100", _("Payment Received") + ":Currency:100",
 			_("Outstanding Amount") + ":Currency:100", _("Age") + ":Int:50", "0-30:Currency:100",
 			"30-60:Currency:100", "60-90:Currency:100", _("90-Above") + ":Currency:100",
 			_("Customer") + ":Link/Customer:200"
@@ -69,27 +69,27 @@
 		# returns a distinct list
 		return list(set([(e.voucher_type, e.voucher_no) for e in self.get_gl_entries()
 			if getdate(e.posting_date) > report_date]))
-			
+
 	def get_entries_till(self, report_date):
 		# returns a generator
-		return (e for e in self.get_gl_entries() 
+		return (e for e in self.get_gl_entries()
 			if getdate(e.posting_date) <= report_date)
-			
+
 	def is_receivable(self, gle, future_vouchers):
 		return (
 			# advance
-			(not gle.against_voucher) or 
+			(not gle.against_voucher) or
 
 			# against sales order
 			(gle.against_voucher_type == "Sales Order") or
-			
+
 			# sales invoice
-			(gle.against_voucher==gle.voucher_no and gle.debit > 0) or 
-			
+			(gle.against_voucher==gle.voucher_no and gle.debit > 0) or
+
 			# entries adjusted with future vouchers
 			((gle.against_voucher_type, gle.against_voucher) in future_vouchers)
 		)
-			
+
 	def get_outstanding_amount(self, gle, report_date):
 		payment_received = 0.0
 		for e in self.get_gl_entries_for(gle.account, gle.voucher_type, gle.voucher_no):
@@ -97,7 +97,7 @@
 				payment_received += (flt(e.credit) - flt(e.debit))
 
 		return flt(gle.debit) - flt(gle.credit) - payment_received
-		
+
 	def get_customer(self, account):
 		return self.get_account_map().get(account, {}).get("customer") or ""
 
@@ -106,25 +106,25 @@
 
 	def get_territory(self, account):
 		return self.get_account_map().get(account, {}).get("territory") or ""
-		
+
 	def get_account_map(self):
 		if not hasattr(self, "account_map"):
-			self.account_map = dict(((r.name, r) for r in frappe.db.sql("""select 
+			self.account_map = dict(((r.name, r) for r in frappe.db.sql("""select
 				acc.name, cust.name as customer, cust.customer_name, cust.territory
-				from `tabAccount` acc left join `tabCustomer` cust 
+				from `tabAccount` acc left join `tabCustomer` cust
 				on cust.name=acc.master_name where acc.master_type="Customer" """, as_dict=True)))
-				
+
 		return self.account_map
-		
+
 	def get_due_date(self, gle):
 		if not hasattr(self, "invoice_due_date_map"):
 			# TODO can be restricted to posting date
 			self.invoice_due_date_map = dict(frappe.db.sql("""select name, due_date
 				from `tabSales Invoice` where docstatus=1"""))
-				
+
 		return gle.voucher_type == "Sales Invoice" \
 			and self.invoice_due_date_map.get(gle.voucher_no) or ""
-		
+
 	def get_gl_entries(self):
 		if not hasattr(self, "gl_entries"):
 			conditions, values = self.prepare_conditions()
@@ -132,15 +132,15 @@
 				where docstatus < 2 {0} order by posting_date, account""".format(conditions),
 				values, as_dict=True)
 		return self.gl_entries
-		
+
 	def prepare_conditions(self):
 		conditions = [""]
 		values = {}
-		
+
 		if self.filters.company:
 			conditions.append("company=%(company)s")
 			values["company"] = self.filters.company
-		
+
 		if self.filters.account:
 			conditions.append("account=%(account)s")
 			values["account"] = self.filters.account
@@ -149,11 +149,11 @@
 			if not account_map:
 				frappe.throw(_("No Customer Accounts found."))
 			else:
-				accounts_list = ['"{0}"'.format(ac) for ac in account_map]
+				accounts_list = ["'{0}'".format(frappe.db.escape(ac)) for ac in account_map]
 				conditions.append("account in ({0})".format(", ".join(accounts_list)))
-		
+
 		return " and ".join(conditions), values
-		
+
 	def get_gl_entries_for(self, account, against_voucher_type, against_voucher):
 		if not hasattr(self, "gl_entries_map"):
 			self.gl_entries_map = {}
@@ -163,7 +163,7 @@
 						.setdefault(gle.against_voucher_type, {})\
 						.setdefault(gle.against_voucher, [])\
 						.append(gle)
-		
+
 		return self.gl_entries_map.get(account, {})\
 			.get(against_voucher_type, {})\
 			.get(against_voucher, [])
@@ -176,15 +176,15 @@
 	outstanding_range = [0.0, 0.0, 0.0, 0.0]
 	if not (age_as_on and entry_date):
 		return [0] + outstanding_range
-		
+
 	age = (getdate(age_as_on) - getdate(entry_date)).days or 0
 	index = None
 	for i, days in enumerate([30, 60, 90]):
 		if age <= days:
 			index = i
 			break
-	
+
 	if index is None: index = 3
 	outstanding_range[index] = outstanding_amount
-	
+
 	return [age] + outstanding_range
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index c658cdd..0a05275 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -28,7 +28,7 @@
 		from `tabFiscal Year` where %s order by year_start_date desc""" % cond)
 
 	if not fy:
-		error_msg = _("""{0} {1} not in any Fiscal Year""").format(label, formatdate(date))
+		error_msg = _("""{0} {1} not in any Fiscal Year. For more details check {2}.""").format(label, formatdate(date), "https://erpnext.com/kb/accounts/fiscal-year-error")
 		if verbose: frappe.msgprint(error_msg)
 		raise FiscalYearError, error_msg
 
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index e21ff74..3011160 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -71,7 +71,7 @@
 	},
 
 	contact_person: function() {
-		this.supplier_address();
+		erpnext.utils.get_contact_details(this.frm);
 	},
 
 	buying_price_list: function() {
@@ -211,7 +211,8 @@
 		var tax_count = this.frm.tax_doclist.length;
 		this.frm.doc.grand_total = flt(tax_count ?
 			this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
-		this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate);
+		this.frm.doc.grand_total_import = flt(tax_count ?
+			flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total_import);
 
 		this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
 			precision("total_tax"));
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
index 9f3f2fc..74781a7 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.json
@@ -1,668 +1,668 @@
 {
- "allow_import": 1, 
- "autoname": "naming_series:", 
- "creation": "2013-05-21 16:16:45", 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Transaction", 
+ "allow_import": 1,
+ "autoname": "naming_series:",
+ "creation": "2013-05-21 16:16:45",
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Transaction",
  "fields": [
   {
-   "fieldname": "supplier_section", 
-   "fieldtype": "Section Break", 
-   "label": "Supplier", 
-   "options": "icon-user", 
+   "fieldname": "supplier_section",
+   "fieldtype": "Section Break",
+   "label": "Supplier",
+   "options": "icon-user",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "naming_series", 
-   "fieldtype": "Select", 
-   "label": "Series", 
-   "no_copy": 1, 
-   "oldfieldname": "naming_series", 
-   "oldfieldtype": "Select", 
-   "options": "SQTN-", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Series",
+   "no_copy": 1,
+   "oldfieldname": "naming_series",
+   "oldfieldtype": "Select",
+   "options": "SQTN-",
+   "permlevel": 0,
+   "print_hide": 1,
    "reqd": 1
-  }, 
+  },
   {
-   "description": "Supplier (vendor) name as entered in supplier master", 
-   "fieldname": "supplier", 
-   "fieldtype": "Link", 
-   "in_filter": 1, 
-   "label": "Supplier", 
-   "oldfieldname": "supplier", 
-   "oldfieldtype": "Link", 
-   "options": "Supplier", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "reqd": 1, 
+   "description": "Supplier (vendor) name as entered in supplier master",
+   "fieldname": "supplier",
+   "fieldtype": "Link",
+   "in_filter": 1,
+   "label": "Supplier",
+   "oldfieldname": "supplier",
+   "oldfieldtype": "Link",
+   "options": "Supplier",
+   "permlevel": 0,
+   "print_hide": 1,
+   "reqd": 1,
    "search_index": 1
-  }, 
+  },
   {
-   "fieldname": "supplier_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "in_list_view": 1, 
-   "label": "Name", 
-   "permlevel": 0, 
+   "fieldname": "supplier_name",
+   "fieldtype": "Data",
+   "hidden": 0,
+   "in_list_view": 1,
+   "label": "Name",
+   "permlevel": 0,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "address_display", 
-   "fieldtype": "Small Text", 
-   "hidden": 1, 
-   "label": "Address", 
-   "permlevel": 0, 
+   "fieldname": "address_display",
+   "fieldtype": "Small Text",
+   "hidden": 1,
+   "label": "Address",
+   "permlevel": 0,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "contact_display", 
-   "fieldtype": "Small Text", 
-   "hidden": 1, 
-   "label": "Contact", 
-   "permlevel": 0, 
+   "fieldname": "contact_display",
+   "fieldtype": "Small Text",
+   "hidden": 1,
+   "label": "Contact",
+   "permlevel": 0,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "contact_mobile", 
-   "fieldtype": "Small Text", 
-   "hidden": 1, 
-   "label": "Mobile No", 
-   "permlevel": 0, 
+   "fieldname": "contact_mobile",
+   "fieldtype": "Small Text",
+   "hidden": 1,
+   "label": "Mobile No",
+   "permlevel": 0,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "contact_email", 
-   "fieldtype": "Small Text", 
-   "hidden": 1, 
-   "label": "Contact Email", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "contact_email",
+   "fieldtype": "Small Text",
+   "hidden": 1,
+   "label": "Contact Email",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "column_break1", 
-   "fieldtype": "Column Break", 
-   "oldfieldtype": "Column Break", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_width": "50%", 
+   "fieldname": "column_break1",
+   "fieldtype": "Column Break",
+   "oldfieldtype": "Column Break",
+   "permlevel": 0,
+   "print_hide": 0,
+   "print_width": "50%",
    "width": "50%"
-  }, 
+  },
   {
-   "fieldname": "transaction_date", 
-   "fieldtype": "Date", 
-   "in_filter": 1, 
-   "label": "Date", 
-   "oldfieldname": "transaction_date", 
-   "oldfieldtype": "Date", 
-   "permlevel": 0, 
-   "reqd": 1, 
+   "fieldname": "transaction_date",
+   "fieldtype": "Date",
+   "in_filter": 1,
+   "label": "Date",
+   "oldfieldname": "transaction_date",
+   "oldfieldtype": "Date",
+   "permlevel": 0,
+   "reqd": 1,
    "search_index": 1
-  }, 
+  },
   {
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 1, 
-   "ignore_user_permissions": 1, 
-   "label": "Amended From", 
-   "no_copy": 1, 
-   "oldfieldname": "amended_from", 
-   "oldfieldtype": "Data", 
-   "options": "Supplier Quotation", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1, 
+   "fieldname": "amended_from",
+   "fieldtype": "Link",
+   "hidden": 1,
+   "ignore_user_permissions": 1,
+   "label": "Amended From",
+   "no_copy": 1,
+   "oldfieldname": "amended_from",
+   "oldfieldtype": "Data",
+   "options": "Supplier Quotation",
+   "permlevel": 0,
+   "print_hide": 1,
+   "read_only": 1,
    "report_hide": 0
-  }, 
+  },
   {
-   "description": "Select the relevant company name if you have multiple companies", 
-   "fieldname": "company", 
-   "fieldtype": "Link", 
-   "in_filter": 1, 
-   "label": "Company", 
-   "no_copy": 0, 
-   "oldfieldname": "company", 
-   "oldfieldtype": "Link", 
-   "options": "Company", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "reqd": 1, 
+   "description": "Select the relevant company name if you have multiple companies",
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "in_filter": 1,
+   "label": "Company",
+   "no_copy": 0,
+   "oldfieldname": "company",
+   "oldfieldtype": "Link",
+   "options": "Company",
+   "permlevel": 0,
+   "print_hide": 1,
+   "reqd": 1,
    "search_index": 1
-  }, 
+  },
   {
-   "fieldname": "currency_price_list", 
-   "fieldtype": "Section Break", 
-   "label": "Currency and Price List", 
-   "options": "icon-tag", 
+   "fieldname": "currency_price_list",
+   "fieldtype": "Section Break",
+   "label": "Currency and Price List",
+   "options": "icon-tag",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "currency", 
-   "fieldtype": "Link", 
-   "label": "Currency", 
-   "no_copy": 0, 
-   "oldfieldname": "currency", 
-   "oldfieldtype": "Select", 
-   "options": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "currency",
+   "fieldtype": "Link",
+   "label": "Currency",
+   "no_copy": 0,
+   "oldfieldname": "currency",
+   "oldfieldtype": "Select",
+   "options": "Currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "reqd": 1
-  }, 
+  },
   {
-   "description": "Rate at which supplier's currency is converted to company's base currency", 
-   "fieldname": "conversion_rate", 
-   "fieldtype": "Float", 
-   "hidden": 0, 
-   "label": "Exchange Rate", 
-   "no_copy": 1, 
-   "oldfieldname": "conversion_rate", 
-   "oldfieldtype": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "description": "Rate at which supplier's currency is converted to company's base currency",
+   "fieldname": "conversion_rate",
+   "fieldtype": "Float",
+   "hidden": 0,
+   "label": "Exchange Rate",
+   "no_copy": 0,
+   "oldfieldname": "conversion_rate",
+   "oldfieldtype": "Currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "reqd": 1
-  }, 
+  },
   {
-   "fieldname": "cb_price_list", 
-   "fieldtype": "Column Break", 
-   "permlevel": 0, 
-   "print_width": "50%", 
+   "fieldname": "cb_price_list",
+   "fieldtype": "Column Break",
+   "permlevel": 0,
+   "print_width": "50%",
    "width": "50%"
-  }, 
+  },
   {
-   "fieldname": "buying_price_list", 
-   "fieldtype": "Link", 
-   "label": "Price List", 
-   "options": "Price List", 
-   "permlevel": 0, 
+   "fieldname": "buying_price_list",
+   "fieldtype": "Link",
+   "label": "Price List",
+   "options": "Price List",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "depends_on": "buying_price_list", 
-   "fieldname": "price_list_currency", 
-   "fieldtype": "Link", 
-   "label": "Price List Currency", 
-   "options": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "depends_on": "buying_price_list",
+   "fieldname": "price_list_currency",
+   "fieldtype": "Link",
+   "label": "Price List Currency",
+   "options": "Currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "depends_on": "buying_price_list", 
-   "fieldname": "plc_conversion_rate", 
-   "fieldtype": "Float", 
-   "label": "Price List Exchange Rate", 
-   "permlevel": 0, 
+   "depends_on": "buying_price_list",
+   "fieldname": "plc_conversion_rate",
+   "fieldtype": "Float",
+   "label": "Price List Exchange Rate",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "ignore_pricing_rule", 
-   "fieldtype": "Check", 
-   "label": "Ignore Pricing Rule", 
-   "no_copy": 1, 
-   "permlevel": 1, 
+   "fieldname": "ignore_pricing_rule",
+   "fieldtype": "Check",
+   "label": "Ignore Pricing Rule",
+   "no_copy": 1,
+   "permlevel": 1,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "items", 
-   "fieldtype": "Section Break", 
-   "label": "Items", 
-   "oldfieldtype": "Section Break", 
-   "options": "icon-shopping-cart", 
+   "fieldname": "items",
+   "fieldtype": "Section Break",
+   "label": "Items",
+   "oldfieldtype": "Section Break",
+   "options": "icon-shopping-cart",
    "permlevel": 0
-  }, 
+  },
   {
-   "allow_on_submit": 1, 
-   "fieldname": "quotation_items", 
-   "fieldtype": "Table", 
-   "label": "Quotation Items", 
-   "no_copy": 0, 
-   "oldfieldname": "po_details", 
-   "oldfieldtype": "Table", 
-   "options": "Supplier Quotation Item", 
+   "allow_on_submit": 1,
+   "fieldname": "quotation_items",
+   "fieldtype": "Table",
+   "label": "Quotation Items",
+   "no_copy": 0,
+   "oldfieldname": "po_details",
+   "oldfieldtype": "Table",
+   "options": "Supplier Quotation Item",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "section_break_22", 
-   "fieldtype": "Section Break", 
+   "fieldname": "section_break_22",
+   "fieldtype": "Section Break",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "net_total", 
-   "fieldtype": "Currency", 
-   "label": "Net Total (Company Currency)", 
-   "no_copy": 1, 
-   "oldfieldname": "net_total", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1, 
+   "fieldname": "net_total",
+   "fieldtype": "Currency",
+   "label": "Net Total (Company Currency)",
+   "no_copy": 1,
+   "oldfieldname": "net_total",
+   "oldfieldtype": "Currency",
+   "options": "Company:company:default_currency",
+   "permlevel": 0,
+   "print_hide": 1,
+   "read_only": 1,
    "reqd": 0
-  }, 
+  },
   {
-   "fieldname": "column_break_24", 
-   "fieldtype": "Column Break", 
+   "fieldname": "column_break_24",
+   "fieldtype": "Column Break",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "net_total_import", 
-   "fieldtype": "Currency", 
-   "label": "Net Total", 
-   "no_copy": 0, 
-   "oldfieldname": "net_total_import", 
-   "oldfieldtype": "Currency", 
-   "options": "currency", 
-   "permlevel": 0, 
-   "print_hide": 0, 
+   "fieldname": "net_total_import",
+   "fieldtype": "Currency",
+   "label": "Net Total",
+   "no_copy": 0,
+   "oldfieldname": "net_total_import",
+   "oldfieldtype": "Currency",
+   "options": "currency",
+   "permlevel": 0,
+   "print_hide": 0,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "taxes", 
-   "fieldtype": "Section Break", 
-   "label": "Taxes and Charges", 
-   "oldfieldtype": "Section Break", 
-   "options": "icon-money", 
+   "fieldname": "taxes",
+   "fieldtype": "Section Break",
+   "label": "Taxes and Charges",
+   "oldfieldtype": "Section Break",
+   "options": "icon-money",
    "permlevel": 0
-  }, 
+  },
   {
-   "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.", 
-   "fieldname": "taxes_and_charges", 
-   "fieldtype": "Link", 
-   "label": "Taxes and Charges", 
-   "no_copy": 1, 
-   "oldfieldname": "purchase_other_charges", 
-   "oldfieldtype": "Link", 
-   "options": "Purchase Taxes and Charges Master", 
-   "permlevel": 0, 
+   "description": "If you have created a standard template in Purchase Taxes and Charges Master, select one and click on the button below.",
+   "fieldname": "taxes_and_charges",
+   "fieldtype": "Link",
+   "label": "Taxes and Charges",
+   "no_copy": 1,
+   "oldfieldname": "purchase_other_charges",
+   "oldfieldtype": "Link",
+   "options": "Purchase Taxes and Charges Master",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "other_charges", 
-   "fieldtype": "Table", 
-   "label": "Purchase Taxes and Charges", 
-   "no_copy": 0, 
-   "oldfieldname": "purchase_tax_details", 
-   "oldfieldtype": "Table", 
-   "options": "Purchase Taxes and Charges", 
+   "fieldname": "other_charges",
+   "fieldtype": "Table",
+   "label": "Purchase Taxes and Charges",
+   "no_copy": 0,
+   "oldfieldname": "purchase_tax_details",
+   "oldfieldtype": "Table",
+   "options": "Purchase Taxes and Charges",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "other_charges_calculation", 
-   "fieldtype": "HTML", 
-   "label": "Taxes and Charges Calculation", 
-   "no_copy": 1, 
-   "oldfieldtype": "HTML", 
-   "permlevel": 0, 
+   "fieldname": "other_charges_calculation",
+   "fieldtype": "HTML",
+   "label": "Taxes and Charges Calculation",
+   "no_copy": 1,
+   "oldfieldtype": "HTML",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "totals", 
-   "fieldtype": "Section Break", 
-   "label": "Totals", 
-   "oldfieldtype": "Section Break", 
-   "options": "icon-money", 
+   "fieldname": "totals",
+   "fieldtype": "Section Break",
+   "label": "Totals",
+   "oldfieldtype": "Section Break",
+   "options": "icon-money",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "other_charges_added", 
-   "fieldtype": "Currency", 
-   "label": "Taxes and Charges Added (Company Currency)", 
-   "no_copy": 0, 
-   "oldfieldname": "other_charges_added", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "other_charges_added",
+   "fieldtype": "Currency",
+   "label": "Taxes and Charges Added (Company Currency)",
+   "no_copy": 0,
+   "oldfieldname": "other_charges_added",
+   "oldfieldtype": "Currency",
+   "options": "Company:company:default_currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "other_charges_deducted", 
-   "fieldtype": "Currency", 
-   "label": "Taxes and Charges Deducted (Company Currency)", 
-   "no_copy": 0, 
-   "oldfieldname": "other_charges_deducted", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "other_charges_deducted",
+   "fieldtype": "Currency",
+   "label": "Taxes and Charges Deducted (Company Currency)",
+   "no_copy": 0,
+   "oldfieldname": "other_charges_deducted",
+   "oldfieldtype": "Currency",
+   "options": "Company:company:default_currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "total_tax", 
-   "fieldtype": "Currency", 
-   "label": "Total Tax (Company Currency)", 
-   "no_copy": 1, 
-   "oldfieldname": "total_tax", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "total_tax",
+   "fieldtype": "Currency",
+   "label": "Total Tax (Company Currency)",
+   "no_copy": 1,
+   "oldfieldname": "total_tax",
+   "oldfieldtype": "Currency",
+   "options": "Company:company:default_currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "grand_total", 
-   "fieldtype": "Currency", 
-   "label": "Grand Total (Company Currency)", 
-   "no_copy": 1, 
-   "oldfieldname": "grand_total", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "grand_total",
+   "fieldtype": "Currency",
+   "label": "Grand Total (Company Currency)",
+   "no_copy": 1,
+   "oldfieldname": "grand_total",
+   "oldfieldtype": "Currency",
+   "options": "Company:company:default_currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "rounded_total", 
-   "fieldtype": "Currency", 
-   "label": "Rounded Total (Company Currency)", 
-   "oldfieldname": "rounded_total", 
-   "oldfieldtype": "Currency", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "fieldname": "rounded_total",
+   "fieldtype": "Currency",
+   "label": "Rounded Total (Company Currency)",
+   "oldfieldname": "rounded_total",
+   "oldfieldtype": "Currency",
+   "options": "Company:company:default_currency",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "description": "In Words will be visible once you save the Purchase Order.", 
-   "fieldname": "in_words", 
-   "fieldtype": "Data", 
-   "label": "In Words (Company Currency)", 
-   "oldfieldname": "in_words", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "description": "In Words will be visible once you save the Purchase Order.",
+   "fieldname": "in_words",
+   "fieldtype": "Data",
+   "label": "In Words (Company Currency)",
+   "oldfieldname": "in_words",
+   "oldfieldtype": "Data",
+   "permlevel": 0,
+   "print_hide": 1,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "column_break4", 
-   "fieldtype": "Column Break", 
-   "oldfieldtype": "Column Break", 
-   "permlevel": 0, 
+   "fieldname": "column_break4",
+   "fieldtype": "Column Break",
+   "oldfieldtype": "Column Break",
+   "permlevel": 0,
    "print_hide": 0
-  }, 
+  },
   {
-   "fieldname": "other_charges_added_import", 
-   "fieldtype": "Currency", 
-   "label": "Taxes and Charges Added", 
-   "no_copy": 0, 
-   "oldfieldname": "other_charges_added_import", 
-   "oldfieldtype": "Currency", 
-   "options": "currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1, 
+   "fieldname": "other_charges_added_import",
+   "fieldtype": "Currency",
+   "label": "Taxes and Charges Added",
+   "no_copy": 0,
+   "oldfieldname": "other_charges_added_import",
+   "oldfieldtype": "Currency",
+   "options": "currency",
+   "permlevel": 0,
+   "print_hide": 1,
+   "read_only": 1,
    "report_hide": 0
-  }, 
+  },
   {
-   "fieldname": "other_charges_deducted_import", 
-   "fieldtype": "Currency", 
-   "label": "Taxes and Charges Deducted", 
-   "no_copy": 0, 
-   "oldfieldname": "other_charges_deducted_import", 
-   "oldfieldtype": "Currency", 
-   "options": "currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1, 
+   "fieldname": "other_charges_deducted_import",
+   "fieldtype": "Currency",
+   "label": "Taxes and Charges Deducted",
+   "no_copy": 0,
+   "oldfieldname": "other_charges_deducted_import",
+   "oldfieldtype": "Currency",
+   "options": "currency",
+   "permlevel": 0,
+   "print_hide": 1,
+   "read_only": 1,
    "report_hide": 0
-  }, 
+  },
   {
-   "fieldname": "grand_total_import", 
-   "fieldtype": "Currency", 
-   "in_list_view": 1, 
-   "label": "Grand Total", 
-   "no_copy": 0, 
-   "oldfieldname": "grand_total_import", 
-   "oldfieldtype": "Currency", 
-   "options": "currency", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "read_only": 1, 
+   "fieldname": "grand_total_import",
+   "fieldtype": "Currency",
+   "in_list_view": 1,
+   "label": "Grand Total",
+   "no_copy": 0,
+   "oldfieldname": "grand_total_import",
+   "oldfieldtype": "Currency",
+   "options": "currency",
+   "permlevel": 0,
+   "print_hide": 0,
+   "read_only": 1,
    "report_hide": 0
-  }, 
+  },
   {
-   "fieldname": "in_words_import", 
-   "fieldtype": "Data", 
-   "label": "In Words", 
-   "oldfieldname": "in_words_import", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "print_hide": 0, 
+   "fieldname": "in_words_import",
+   "fieldtype": "Data",
+   "label": "In Words",
+   "oldfieldname": "in_words_import",
+   "oldfieldtype": "Data",
+   "permlevel": 0,
+   "print_hide": 0,
    "read_only": 1
-  }, 
+  },
   {
-   "fieldname": "fold", 
-   "fieldtype": "Fold", 
+   "fieldname": "fold",
+   "fieldtype": "Fold",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "terms_section_break", 
-   "fieldtype": "Section Break", 
-   "label": "Terms and Conditions", 
-   "oldfieldtype": "Section Break", 
-   "options": "icon-legal", 
+   "fieldname": "terms_section_break",
+   "fieldtype": "Section Break",
+   "label": "Terms and Conditions",
+   "oldfieldtype": "Section Break",
+   "options": "icon-legal",
    "permlevel": 0
-  }, 
+  },
   {
-   "allow_on_submit": 1, 
-   "fieldname": "letter_head", 
-   "fieldtype": "Link", 
-   "label": "Letter Head", 
-   "oldfieldname": "letter_head", 
-   "oldfieldtype": "Select", 
-   "options": "Letter Head", 
-   "permlevel": 0, 
+   "allow_on_submit": 1,
+   "fieldname": "letter_head",
+   "fieldtype": "Link",
+   "label": "Letter Head",
+   "oldfieldname": "letter_head",
+   "oldfieldtype": "Select",
+   "options": "Letter Head",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "tc_name", 
-   "fieldtype": "Link", 
-   "label": "Terms", 
-   "oldfieldname": "tc_name", 
-   "oldfieldtype": "Link", 
-   "options": "Terms and Conditions", 
-   "permlevel": 0, 
+   "fieldname": "tc_name",
+   "fieldtype": "Link",
+   "label": "Terms",
+   "oldfieldname": "tc_name",
+   "oldfieldtype": "Link",
+   "options": "Terms and Conditions",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "get_terms", 
-   "fieldtype": "Button", 
-   "label": "Get Terms and Conditions", 
-   "oldfieldtype": "Button", 
+   "fieldname": "get_terms",
+   "fieldtype": "Button",
+   "label": "Get Terms and Conditions",
+   "oldfieldtype": "Button",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "terms", 
-   "fieldtype": "Text Editor", 
-   "label": "Terms and Conditions", 
-   "oldfieldname": "terms", 
-   "oldfieldtype": "Text Editor", 
+   "fieldname": "terms",
+   "fieldtype": "Text Editor",
+   "label": "Terms and Conditions",
+   "oldfieldname": "terms",
+   "oldfieldtype": "Text Editor",
    "permlevel": 0
-  }, 
+  },
   {
-   "depends_on": "supplier", 
-   "fieldname": "contact_section", 
-   "fieldtype": "Section Break", 
-   "label": "Contact Info", 
-   "options": "icon-bullhorn", 
+   "depends_on": "supplier",
+   "fieldname": "contact_section",
+   "fieldtype": "Section Break",
+   "label": "Contact Info",
+   "options": "icon-bullhorn",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "supplier_address", 
-   "fieldtype": "Link", 
-   "in_filter": 1, 
-   "label": "Supplier Address", 
-   "options": "Address", 
-   "permlevel": 0, 
+   "fieldname": "supplier_address",
+   "fieldtype": "Link",
+   "in_filter": 1,
+   "label": "Supplier Address",
+   "options": "Address",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "contact_person", 
-   "fieldtype": "Link", 
-   "in_filter": 1, 
-   "label": "Contact Person", 
-   "options": "Contact", 
-   "permlevel": 0, 
+   "fieldname": "contact_person",
+   "fieldtype": "Link",
+   "in_filter": 1,
+   "label": "Contact Person",
+   "options": "Contact",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "more_info", 
-   "fieldtype": "Section Break", 
-   "label": "More Info", 
-   "oldfieldtype": "Section Break", 
-   "options": "icon-file-text", 
+   "fieldname": "more_info",
+   "fieldtype": "Section Break",
+   "label": "More Info",
+   "oldfieldtype": "Section Break",
+   "options": "icon-file-text",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "status", 
-   "fieldtype": "Select", 
-   "in_filter": 1, 
-   "label": "Status", 
-   "no_copy": 1, 
-   "oldfieldname": "status", 
-   "oldfieldtype": "Select", 
-   "options": "\nDraft\nSubmitted\nStopped\nCancelled", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1, 
-   "reqd": 1, 
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "in_filter": 1,
+   "label": "Status",
+   "no_copy": 1,
+   "oldfieldname": "status",
+   "oldfieldtype": "Select",
+   "options": "\nDraft\nSubmitted\nStopped\nCancelled",
+   "permlevel": 0,
+   "print_hide": 1,
+   "read_only": 1,
+   "reqd": 1,
    "search_index": 1
-  }, 
+  },
   {
-   "default": "No", 
-   "fieldname": "is_subcontracted", 
-   "fieldtype": "Select", 
-   "label": "Is Subcontracted", 
-   "options": "\nYes\nNo", 
-   "permlevel": 0, 
+   "default": "No",
+   "fieldname": "is_subcontracted",
+   "fieldtype": "Select",
+   "label": "Is Subcontracted",
+   "options": "\nYes\nNo",
+   "permlevel": 0,
    "print_hide": 1
-  }, 
+  },
   {
-   "fieldname": "column_break_57", 
-   "fieldtype": "Column Break", 
+   "fieldname": "column_break_57",
+   "fieldtype": "Column Break",
    "permlevel": 0
-  }, 
+  },
   {
-   "fieldname": "fiscal_year", 
-   "fieldtype": "Link", 
-   "in_filter": 1, 
-   "label": "Fiscal Year", 
-   "no_copy": 0, 
-   "oldfieldname": "fiscal_year", 
-   "oldfieldtype": "Select", 
-   "options": "Fiscal Year", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "reqd": 1, 
+   "fieldname": "fiscal_year",
+   "fieldtype": "Link",
+   "in_filter": 1,
+   "label": "Fiscal Year",
+   "no_copy": 0,
+   "oldfieldname": "fiscal_year",
+   "oldfieldtype": "Select",
+   "options": "Fiscal Year",
+   "permlevel": 0,
+   "print_hide": 1,
+   "reqd": 1,
    "search_index": 1
-  }, 
+  },
   {
-   "allow_on_submit": 1, 
-   "fieldname": "select_print_heading", 
-   "fieldtype": "Link", 
-   "label": "Print Heading", 
-   "no_copy": 1, 
-   "oldfieldname": "select_print_heading", 
-   "oldfieldtype": "Link", 
-   "options": "Print Heading", 
-   "permlevel": 0, 
-   "print_hide": 1, 
+   "allow_on_submit": 1,
+   "fieldname": "select_print_heading",
+   "fieldtype": "Link",
+   "label": "Print Heading",
+   "no_copy": 1,
+   "oldfieldname": "select_print_heading",
+   "oldfieldtype": "Link",
+   "options": "Print Heading",
+   "permlevel": 0,
+   "print_hide": 1,
    "report_hide": 1
   }
- ], 
- "icon": "icon-shopping-cart", 
- "idx": 1, 
- "is_submittable": 1, 
- "modified": "2014-09-09 05:35:35.369734", 
- "modified_by": "Administrator", 
- "module": "Buying", 
- "name": "Supplier Quotation", 
- "owner": "Administrator", 
+ ],
+ "icon": "icon-shopping-cart",
+ "idx": 1,
+ "is_submittable": 1,
+ "modified": "2014-12-26 05:35:35.369734",
+ "modified_by": "Administrator",
+ "module": "Buying",
+ "name": "Supplier Quotation",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 1, 
-   "cancel": 1, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Manufacturing Manager", 
-   "submit": 1, 
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Manufacturing Manager",
+   "submit": 1,
    "write": 1
-  }, 
+  },
   {
-   "amend": 1, 
-   "cancel": 1, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Purchase Manager", 
-   "submit": 1, 
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Purchase Manager",
+   "submit": 1,
    "write": 1
-  }, 
+  },
   {
-   "amend": 1, 
-   "apply_user_permissions": 1, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 0, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Purchase User", 
-   "submit": 0, 
+   "amend": 1,
+   "apply_user_permissions": 1,
+   "cancel": 0,
+   "create": 1,
+   "delete": 0,
+   "email": 1,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Purchase User",
+   "submit": 0,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "apply_user_permissions": 1, 
-   "cancel": 0, 
-   "create": 0, 
-   "delete": 0, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Material User", 
-   "submit": 0, 
+   "amend": 0,
+   "apply_user_permissions": 1,
+   "cancel": 0,
+   "create": 0,
+   "delete": 0,
+   "email": 1,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Material User",
+   "submit": 0,
    "write": 0
-  }, 
+  },
   {
-   "amend": 0, 
-   "apply_user_permissions": 1, 
-   "cancel": 0, 
-   "create": 0, 
-   "delete": 0, 
-   "email": 1, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Supplier", 
-   "submit": 0, 
+   "amend": 0,
+   "apply_user_permissions": 1,
+   "cancel": 0,
+   "create": 0,
+   "delete": 0,
+   "email": 1,
+   "permlevel": 0,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Supplier",
+   "submit": 0,
    "write": 0
-  }, 
+  },
   {
-   "permlevel": 1, 
-   "read": 1, 
-   "role": "Purchase Manager", 
+   "permlevel": 1,
+   "read": 1,
+   "role": "Purchase Manager",
    "write": 1
   }
- ], 
- "read_only_onload": 1, 
- "search_fields": "status, transaction_date, supplier,grand_total", 
- "sort_field": "modified", 
+ ],
+ "read_only_onload": 1,
+ "search_fields": "status, transaction_date, supplier,grand_total",
+ "sort_field": "modified",
  "sort_order": "DESC"
-}
\ No newline at end of file
+}
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 49845f6..5219339 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -119,6 +119,10 @@
 							item.get(fieldname) is None and value is not None:
 								item.set(fieldname, value)
 
+						if fieldname == "cost_center" and item.meta.get_field("cost_center") \
+							and not item.get("cost_center") and value is not None:
+								item.set(fieldname, value)
+
 					if ret.get("pricing_rule"):
 						for field in ["base_price_list_rate", "price_list_rate",
 							"discount_percentage", "base_rate", "rate"]:
@@ -291,7 +295,7 @@
 			self.precision("tax_amount", tax))
 
 	def adjust_discount_amount_loss(self, tax):
-		discount_amount_loss = self.grand_total - flt(self.discount_amount) - tax.total
+		discount_amount_loss = self.grand_total - flt(self.base_discount_amount) - tax.total
 		tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
 			discount_amount_loss, self.precision("tax_amount", tax))
 		tax.total = flt(tax.total + discount_amount_loss, self.precision("total", tax))
@@ -467,7 +471,7 @@
 					max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
 
 					if total_billed_amt - max_allowed_amt > 0.01:
-						frappe.throw(_("Cannot overbill for Item {0} in row {0} more than {1}. To allow overbilling, please set in Stock Settings").format(item.item_code, item.idx, max_allowed_amt))
+						frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow overbilling, please set in Stock Settings").format(item.item_code, item.idx, max_allowed_amt))
 
 	def get_company_default(self, fieldname):
 		from erpnext.accounts.utils import get_company_default
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 1e6e65d..f7b5a87 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -111,7 +111,8 @@
 
 	def calculate_totals(self):
 		self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total)
-		self.grand_total_import = flt(self.grand_total / self.conversion_rate)
+		self.grand_total_import = flt(self.grand_total / self.conversion_rate) \
+			if self.tax_doclist else self.net_total_import
 
 		self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax"))
 
diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py
index fa7f275..1ec415c 100644
--- a/erpnext/controllers/recurring_document.py
+++ b/erpnext/controllers/recurring_document.py
@@ -124,10 +124,7 @@
 	frappe.sendmail(new_rv.notification_email_address,
 		subject=  _("New {0}: #{1}").format(new_rv.doctype, new_rv.name),
 		message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
-		attachments = [{
-			"fname": new_rv.name + ".pdf",
-			"fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True)
-		}])
+		attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name)])
 
 def notify_errors(doc, doctype, party, owner):
 	from frappe.utils.user import get_system_managers
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 6e93c30..4b0cd4e 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -233,16 +233,20 @@
 
 	def apply_discount_amount(self):
 		if self.discount_amount:
+			self.base_discount_amount = flt(self.discount_amount * self.conversion_rate, self.precision("base_discount_amount"))
+
 			grand_total_for_discount_amount = self.get_grand_total_for_discount_amount()
 
 			if grand_total_for_discount_amount:
 				# calculate item amount after Discount Amount
 				for item in self.item_doclist:
-					distributed_amount = flt(self.discount_amount) * item.base_amount / grand_total_for_discount_amount
+					distributed_amount = flt(self.base_discount_amount) * item.base_amount / grand_total_for_discount_amount
 					item.base_amount = flt(item.base_amount - distributed_amount, self.precision("base_amount", item))
 
 				self.discount_amount_applied = True
 				self._calculate_taxes_and_totals()
+		else:
+			self.base_discount_amount = 0
 
 	def get_grand_total_for_discount_amount(self):
 		actual_taxes_dict = {}
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 0a9adc0..1535575 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -167,7 +167,7 @@
 		else:
 			is_expense_account = frappe.db.get_value("Account",
 				item.get("expense_account"), "report_type")=="Profit and Loss"
-			if self.doctype not in ("Purchase Receipt", "Stock Reconciliation") and not is_expense_account:
+			if self.doctype not in ("Purchase Receipt", "Stock Reconciliation", "Stock Entry") and not is_expense_account:
 				frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account")
 					.format(item.get("expense_account")))
 			if is_expense_account and not item.get("cost_center"):
@@ -245,7 +245,7 @@
 	for entry in expected_gle:
 		for e in existing_gle:
 			if entry.account==e.account and entry.against_account==e.against_account \
-				and entry.cost_center==e.cost_center \
+				and (not entry.cost_center or not e.cost_center or entry.cost_center==e.cost_center) \
 				and (entry.debit != e.debit or entry.credit != e.credit):
 					matched = False
 					break
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 15f99a9..c72cefc 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.12.0"
+app_version = "4.18.1"
 
 error_report_email = "support@erpnext.com"
 
diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index ecaac4a..6605c30 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -33,7 +33,7 @@
 				cur_frm.set_intro(__("You are the Leave Approver for this record. Please Update the 'Status' and Save"));
 				cur_frm.toggle_enable("status", true);
 			} else {
-				cur_frm.set_intro(__("This Leave Application is pending approval. Only the Leave Apporver can update status."))
+				cur_frm.set_intro(__("This Leave Application is pending approval. Only the Leave Approver can update status."))
 				cur_frm.toggle_enable("status", false);
 				if(!doc.__islocal) {
 						cur_frm.frm_head.appframe.set_title_right("");
@@ -118,3 +118,18 @@
 }
 
 cur_frm.fields_dict.employee.get_query = erpnext.queries.employee;
+
+frappe.ui.form.on("Leave Application", "leave_approver", function(frm) {
+	frappe.call({
+		"method": "frappe.client.get",
+		args: {
+			doctype: "User",
+			name: frm.doc.leave_approver
+		},
+		callback: function (data) {
+			frappe.model.set_value(frm.doctype, frm.docname, "leave_approver_name",
+				data.message.first_name
+				+ (data.message.last_name ? (" " + data.message.last_name) : ""))
+		}
+	})
+})
diff --git a/erpnext/hr/doctype/leave_application/leave_application.json b/erpnext/hr/doctype/leave_application/leave_application.json
index 9e2ad53..8beed8b 100644
--- a/erpnext/hr/doctype/leave_application/leave_application.json
+++ b/erpnext/hr/doctype/leave_application/leave_application.json
@@ -25,6 +25,13 @@
    "permlevel": 0
   }, 
   {
+   "fieldname": "leave_approver_name", 
+   "fieldtype": "Read Only", 
+   "label": "Leave Approver Name", 
+   "permlevel": 0, 
+   "precision": ""
+  }, 
+  {
    "fieldname": "leave_type", 
    "fieldtype": "Link", 
    "ignore_user_permissions": 1, 
@@ -184,7 +191,7 @@
  "idx": 1, 
  "is_submittable": 1, 
  "max_attachments": 3, 
- "modified": "2014-09-09 05:35:31.531651", 
+ "modified": "2014-12-09 16:33:29.626849", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Leave Application", 
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index e6742bb..bac688b 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -204,14 +204,14 @@
 	tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
 		where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name
 		and h1.holiday_date between %s and %s""", (leave_app.employee, leave_app.from_date,
-			leave_app.to_date))
+			leave_app.to_date))[0][0]
 	# below line is needed. If an employee hasn't been assigned with any holiday list then above will return 0 rows.
 	if not tot_hol:
 		tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2
 			where h1.parent = h2.name and h1.holiday_date between %s and %s
 			and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s""",
-			(leave_app.from_date, leave_app.to_date, leave_app.fiscal_year))
-	return tot_hol and tot_hol[0][0] or 0
+			(leave_app.from_date, leave_app.to_date, leave_app.fiscal_year))[0][0]
+	return tot_hol
 
 @frappe.whitelist()
 def get_total_leave_days(leave_app):
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index f30fe02..f87a122 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -191,9 +191,6 @@
 		if receiver:
 			subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
 			sendmail([receiver], subject=subj, msg = _("Please see attachment"),
-				attachments=[{
-					"fname": self.name + ".pdf",
-					"fcontent": frappe.get_print_format(self.doctype, self.name, as_pdf = True)
-				}])
+				attachments=[frappe.attach_print(self.doctype, self.name, file_name=self.name)])
 		else:
 			msgprint(_("Company Email ID not found, hence mail not sent"))
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index cb96478..1b1dc62 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -83,6 +83,7 @@
 
 
 cur_frm.cscript.time_in_mins = cur_frm.cscript.hour_rate;
+cur_frm.cscript.fixed_cycle_cost = cur_frm.cscript.hour_rate;
 
 cur_frm.cscript.item_code = function(doc, cdt, cdn) {
 	get_bom_material_detail(doc, cdt, cdn);
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index e8a8682..8a19f41 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -8,6 +8,8 @@
 from frappe import _
 from frappe.model.document import Document
 
+from operator import itemgetter
+
 class BOM(Document):
 
 	def autoname(self):
@@ -57,6 +59,9 @@
 			last_purchase_rate, is_manufactured_item
 			from `tabItem` where name=%s""", item_code, as_dict = 1)
 
+		if not item:
+			frappe.throw(_("Item: {0} does not exist in the system").format(item_code))
+
 		return item
 
 	def validate_rm_item(self, item):
@@ -285,7 +290,10 @@
 				if not d.hour_rate:
 					d.hour_rate = flt(w[0])
 
-				fixed_cost += flt(w[1])
+				if d.fixed_cycle_cost == None:
+					d.fixed_cycle_cost= flt(w[1])
+
+				fixed_cost += d.fixed_cycle_cost
 
 			if d.hour_rate and d.time_in_mins:
 				d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60.0
@@ -354,7 +362,7 @@
 		"Add items to Flat BOM table"
 		frappe.db.sql("""delete from `tabBOM Explosion Item` where parent=%s""", self.name)
 		self.set('flat_bom_details', [])
-		for d in self.cur_exploded_items:
+		for d in sorted(self.cur_exploded_items, key=itemgetter(0)):
 			ch = self.append('flat_bom_details', {})
 			for i in self.cur_exploded_items[d].keys():
 				ch.set(i, self.cur_exploded_items[d][i])
diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.py b/erpnext/manufacturing/doctype/production_order/test_production_order.py
index a9975c1..59e56ef 100644
--- a/erpnext/manufacturing/doctype/production_order/test_production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/test_production_order.py
@@ -10,7 +10,7 @@
 from erpnext.stock.doctype.stock_entry import test_stock_entry
 
 class TestProductionOrder(unittest.TestCase):
-	def test_planned_qty(self):
+	def check_planned_qty(self):
 		set_perpetual_inventory(0)
 
 		planned0 = frappe.db.get_value("Bin", {"item_code": "_Test FG Item", "warehouse": "_Test Warehouse 1 - _TC"}, "planned_qty") or 0
@@ -27,11 +27,15 @@
 		s = frappe.get_doc(make_stock_entry(pro_doc.name, "Material Transfer", 4))
 		for d in s.get("mtn_details"):
 			d.s_warehouse = "Stores - _TC"
+		s.fiscal_year = "_Test Fiscal Year 2013"
+		s.posting_date = "2013-01-02"
 		s.insert()
 		s.submit()
 
 		# from wip to fg
 		s = frappe.get_doc(make_stock_entry(pro_doc.name, "Manufacture", 4))
+		s.fiscal_year = "_Test Fiscal Year 2013"
+		s.posting_date = "2013-01-03"
 		s.insert()
 		s.submit()
 
@@ -44,12 +48,14 @@
 
 	def test_over_production(self):
 		from erpnext.manufacturing.doctype.production_order.production_order import StockOverProductionError
-		pro_doc = self.test_planned_qty()
+		pro_doc = self.check_planned_qty()
 
 		test_stock_entry.make_stock_entry("_Test Item", None, "_Test Warehouse - _TC", 100, 100)
 		test_stock_entry.make_stock_entry("_Test Item Home Desktop 100", None, "_Test Warehouse - _TC", 100, 100)
 
 		s = frappe.get_doc(make_stock_entry(pro_doc.name, "Manufacture", 7))
+		s.fiscal_year = "_Test Fiscal Year 2013"
+		s.posting_date = "2013-01-04"
 		s.insert()
 
 		self.assertRaises(StockOverProductionError, s.submit)
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js
index e219215..f0616de 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js
@@ -24,6 +24,13 @@
 	}
 }
 
+cur_frm.cscript.raise_purchase_request = function(doc, cdt, cdn) {
+	return frappe.call({
+		method: "raise_purchase_request",
+		doc:doc
+	})
+}
+
 cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) {
 	return $c_obj(doc, 'validate_data', '', function(r, rt) {
 		if (!r['exc'])
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json
index bdfab41..c6ec1e2 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json
@@ -1,5 +1,5 @@
 {
- "creation": "2013-01-21 12:03:47.000000", 
+ "creation": "2013-01-21 12:03:47", 
  "default_print_format": "Standard", 
  "docstatus": 0, 
  "doctype": "DocType", 
@@ -20,6 +20,7 @@
   {
    "fieldname": "fg_item", 
    "fieldtype": "Link", 
+   "in_list_view": 1, 
    "label": "Filter based on item", 
    "options": "Item", 
    "permlevel": 0
@@ -27,6 +28,7 @@
   {
    "fieldname": "customer", 
    "fieldtype": "Link", 
+   "in_list_view": 1, 
    "label": "Filter based on customer", 
    "options": "Customer", 
    "permlevel": 0
@@ -34,6 +36,7 @@
   {
    "fieldname": "company", 
    "fieldtype": "Link", 
+   "in_list_view": 1, 
    "label": "Company", 
    "options": "Company", 
    "permlevel": 0, 
@@ -140,7 +143,7 @@
    "fieldname": "raise_purchase_request", 
    "fieldtype": "Button", 
    "label": "Create Material Requests", 
-   "options": "raise_purchase_request", 
+   "options": "", 
    "permlevel": 0
   }, 
   {
@@ -155,7 +158,7 @@
  "idx": 1, 
  "in_create": 1, 
  "issingle": 1, 
- "modified": "2013-12-20 19:23:25.000000", 
+ "modified": "2015-01-11 21:53:21.253556", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "Production Planning Tool", 
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 4c97581..7fda960 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -89,3 +89,5 @@
 erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions
 erpnext.patches.v4_2.update_requested_and_ordered_qty
 execute:frappe.delete_doc("DocType", "Contact Control")
+erpnext.patches.v4_2.recalculate_bom_costs
+erpnext.patches.v4_2.discount_amount
diff --git a/erpnext/patches/v4_1/fix_jv_remarks.py b/erpnext/patches/v4_1/fix_jv_remarks.py
index 3b2f342..99797e1 100644
--- a/erpnext/patches/v4_1/fix_jv_remarks.py
+++ b/erpnext/patches/v4_1/fix_jv_remarks.py
@@ -6,6 +6,7 @@
 
 def execute():
 	reference_date = guess_reference_date()
+	frappe.reload_doc('accounts', 'doctype', 'journal_voucher_detail')
 	for name in frappe.db.sql_list("""select name from `tabJournal Voucher`
 		where date(creation)>=%s""", reference_date):
 		jv = frappe.get_doc("Journal Voucher", name)
diff --git a/erpnext/patches/v4_2/discount_amount.py b/erpnext/patches/v4_2/discount_amount.py
new file mode 100644
index 0000000..3ce10ca
--- /dev/null
+++ b/erpnext/patches/v4_2/discount_amount.py
@@ -0,0 +1,12 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.modules import scrub, get_doctype_module
+
+def execute():
+	for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
+		frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
+		frappe.db.sql("""update `tab{0}` set base_discount_amount=discount_amount,
+			discount_amount=discount_amount/conversion_rate""".format(dt))
diff --git a/erpnext/patches/v4_2/recalculate_bom_costs.py b/erpnext/patches/v4_2/recalculate_bom_costs.py
new file mode 100644
index 0000000..37f0413
--- /dev/null
+++ b/erpnext/patches/v4_2/recalculate_bom_costs.py
@@ -0,0 +1,19 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
+	for d in frappe.db.sql("""select bom.name from `tabBOM` bom where bom.docstatus < 2 and
+		exists(select bom_op.name from `tabBOM Operation` bom_op where
+		bom.name = bom_op.parent and bom_op.fixed_cycle_cost IS NOT NULL)""", as_dict=1):
+		try:
+			bom = frappe.get_doc('BOM', d.name)
+			bom.ignore_validate_update_after_submit = True
+			bom.calculate_cost()
+			bom.save()
+			frappe.db.commit()
+		except:
+			frappe.db.rollback()
diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js
index 091836f..57b69cb 100644
--- a/erpnext/public/js/stock_analytics.js
+++ b/erpnext/public/js/stock_analytics.js
@@ -108,6 +108,7 @@
 			// otherwise, only reset values
 			$.each(this.data, function(i, d) {
 				me.reset_item_values(d);
+				d["closing_qty_value"] = 0;
 			});
 		}
 
diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js
index 3a12485..6d38b46 100644
--- a/erpnext/public/js/transaction.js
+++ b/erpnext/public/js/transaction.js
@@ -402,20 +402,32 @@
 	},
 
 	_set_values_for_item_list: function(children) {
+		var me = this;
+		var price_list_rate_changed = false;
 		$.each(children, function(i, d) {
+			var existing_pricing_rule = frappe.model.get_value(d.doctype, d.name, "pricing_rule");
 			$.each(d, function(k, v) {
 				if (["doctype", "name"].indexOf(k)===-1) {
+					if(k=="price_list_rate") {
+						if(flt(v) != flt(d.price_list_rate)) price_list_rate_changed = true;
+					}
 					frappe.model.set_value(d.doctype, d.name, k, v);
 				}
 			});
+			// if pricing rule set as blank from an existing value, apply price_list
+			if(!me.frm.doc.ignore_pricing_rule && existing_pricing_rule && !d.pricing_rule) {
+				me.apply_price_list(frappe.get_doc(d.doctype, d.name));
+			}
+
+			if(!price_list_rate_changed) me.calculate_taxes_and_totals();
 		});
 	},
 
-	apply_price_list: function() {
+	apply_price_list: function(item) {
 		var me = this;
 		return this.frm.call({
 			method: "erpnext.stock.get_item_details.apply_price_list",
-			args: {	args: this._get_args() },
+			args: {	args: this._get_args(item) },
 			callback: function(r) {
 				if (!r.exc) {
 					me.in_apply_price_list = true;
@@ -722,7 +734,7 @@
 	},
 
 	adjust_discount_amount_loss: function(tax) {
-		var discount_amount_loss = this.frm.doc.grand_total - flt(this.frm.doc.discount_amount) - tax.total;
+		var discount_amount_loss = this.frm.doc.grand_total - flt(this.frm.doc.base_discount_amount) - tax.total;
 		tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
 			discount_amount_loss, precision("tax_amount", tax));
 		tax.total = flt(tax.total + discount_amount_loss, precision("total", tax));
@@ -736,8 +748,7 @@
 			// distribute the tax amount proportionally to each item row
 			var actual = flt(tax.rate, precision("tax_amount", tax));
 			current_tax_amount = this.frm.doc.net_total ?
-				((item.base_amount / this.frm.doc.net_total) * actual) :
-				0.0;
+			((item.base_amount / this.frm.doc.net_total) * actual) : 0.0;
 
 		} else if(tax.charge_type == "On Net Total") {
 			current_tax_amount = (tax_rate / 100.0) * item.base_amount;
diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js
index af31d39..59acc10 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.js
+++ b/erpnext/selling/doctype/opportunity/opportunity.js
@@ -35,8 +35,6 @@
 			});
 		}
 
-		if(this.frm.doc.customer && !this.frm.doc.customer_name) cur_frm.cscript.customer(this.frm.doc);
-
 		this.setup_queries();
 	},
 
diff --git a/erpnext/selling/doctype/opportunity/opportunity.json b/erpnext/selling/doctype/opportunity/opportunity.json
index 17291ad..92defc2 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.json
+++ b/erpnext/selling/doctype/opportunity/opportunity.json
@@ -47,6 +47,7 @@
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Customer", 
+   "no_copy": 1, 
    "oldfieldname": "customer", 
    "oldfieldtype": "Link", 
    "options": "Customer", 
@@ -416,7 +417,7 @@
  "icon": "icon-info-sign", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2014-12-01 08:46:35.331148", 
+ "modified": "2014-12-19 10:49:20.695720", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Opportunity", 
diff --git a/erpnext/selling/doctype/opportunity/test_records.json b/erpnext/selling/doctype/opportunity/test_records.json
index 3970903..43ab55d 100644
--- a/erpnext/selling/doctype/opportunity/test_records.json
+++ b/erpnext/selling/doctype/opportunity/test_records.json
@@ -5,6 +5,8 @@
 		"enquiry_from": "Lead",
 		"enquiry_type": "Sales",
 		"lead": "_T-Lead-00001",
+		"transaction_date": "2013-12-12",
+		"fiscal_year": "_Test Fiscal Year 2013", 
 		"enquiry_details": [{
 			"item_name": "Test Item",
 			"description": "Some description"
diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json
index 5d960e9..9af5029 100644
--- a/erpnext/selling/doctype/quotation/quotation.json
+++ b/erpnext/selling/doctype/quotation/quotation.json
@@ -406,6 +406,15 @@
    "permlevel": 0
   }, 
   {
+   "fieldname": "other_charges_total_export", 
+   "fieldtype": "Currency", 
+   "label": "Taxes and Charges Total", 
+   "options": "currency", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "other_charges_total", 
    "fieldtype": "Currency", 
    "label": "Taxes and Charges Total (Company Currency)", 
@@ -422,22 +431,23 @@
    "permlevel": 0
   }, 
   {
-   "fieldname": "other_charges_total_export", 
-   "fieldtype": "Currency", 
-   "label": "Taxes and Charges Total", 
-   "options": "currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1
-  }, 
-  {
    "fieldname": "discount_amount", 
    "fieldtype": "Currency", 
    "label": "Discount Amount", 
-   "options": "Company:company:default_currency", 
+   "options": "currency", 
    "permlevel": 0
   }, 
   {
+   "fieldname": "base_discount_amount", 
+   "fieldtype": "Currency", 
+   "label": "Discount Amount (Company Currency)", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "totals", 
    "fieldtype": "Section Break", 
    "label": "Totals", 
@@ -832,7 +842,7 @@
  "idx": 1, 
  "is_submittable": 1, 
  "max_attachments": 1, 
- "modified": "2014-09-09 05:35:33.413559", 
+ "modified": "2015-01-12 16:57:14.706270", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Quotation", 
diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json
index 69693a7..4ffc603 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.json
+++ b/erpnext/selling/doctype/sales_order/sales_order.json
@@ -175,6 +175,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "label": "PO No", 
+   "no_copy": 0, 
    "oldfieldname": "po_no", 
    "oldfieldtype": "Data", 
    "permlevel": 0, 
@@ -420,11 +421,6 @@
    "read_only": 1
   }, 
   {
-   "fieldname": "column_break_46", 
-   "fieldtype": "Column Break", 
-   "permlevel": 0
-  }, 
-  {
    "fieldname": "other_charges_total", 
    "fieldtype": "Currency", 
    "label": "Taxes and Charges Total (Company Currency)", 
@@ -437,11 +433,27 @@
    "width": "150px"
   }, 
   {
+   "fieldname": "column_break_46", 
+   "fieldtype": "Column Break", 
+   "permlevel": 0
+  }, 
+  {
    "fieldname": "discount_amount", 
    "fieldtype": "Currency", 
    "label": "Discount Amount", 
+   "options": "currency", 
+   "permlevel": 0, 
+   "print_hide": 0
+  }, 
+  {
+   "fieldname": "base_discount_amount", 
+   "fieldtype": "Currency", 
+   "label": "Discount Amount (Company Currency)", 
    "options": "Company:company:default_currency", 
-   "permlevel": 0
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "read_only": 1
   }, 
   {
    "fieldname": "totals", 
@@ -490,14 +502,6 @@
    "width": "200px"
   }, 
   {
-   "fieldname": "advance_paid", 
-   "fieldtype": "Currency", 
-   "label": "Advance Paid", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1
-  }, 
-  {
    "fieldname": "column_break3", 
    "fieldtype": "Column Break", 
    "oldfieldtype": "Column Break", 
@@ -542,6 +546,15 @@
    "width": "200px"
   }, 
   {
+   "fieldname": "advance_paid", 
+   "fieldtype": "Currency", 
+   "label": "Advance Paid", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "view_details", 
    "fieldtype": "Fold", 
    "label": "View Details", 
@@ -1020,7 +1033,7 @@
  "idx": 1, 
  "is_submittable": 1, 
  "issingle": 0, 
- "modified": "2014-10-08 14:22:44.717108", 
+ "modified": "2015-01-12 15:16:51.611467", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Sales Order", 
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 8153d8d..604ac11 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -275,6 +275,14 @@
 @frappe.whitelist()
 def make_delivery_note(source_name, target_doc=None):
 	def set_missing_values(source, target):
+		if source.po_no:
+			if target.po_no:
+				target_po_no = target.po_no.split(", ")
+				target_po_no.append(source.po_no)
+				target.po_no = ", ".join(list(set(target_po_no))) if len(target_po_no) > 1 else target_po_no[0]
+			else:
+				target.po_no = source.po_no
+
 		target.ignore_pricing_rule = 1
 		target.run_method("set_missing_values")
 		target.run_method("calculate_taxes_and_totals")
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 783474c..3a01811 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -362,17 +362,22 @@
 		var distributed_amount = 0.0;
 
 		if (this.frm.doc.discount_amount) {
+			this.frm.set_value("base_discount_amount",
+				flt(this.frm.doc.discount_amount * this.frm.doc.conversion_rate, precision("base_discount_amount")))
+
 			var grand_total_for_discount_amount = this.get_grand_total_for_discount_amount();
 			// calculate item amount after Discount Amount
 			if (grand_total_for_discount_amount) {
 				$.each(this.frm.item_doclist, function(i, item) {
-					distributed_amount = flt(me.frm.doc.discount_amount) * item.base_amount / grand_total_for_discount_amount;
+					distributed_amount = flt(me.frm.doc.base_discount_amount) * item.base_amount / grand_total_for_discount_amount;
 					item.base_amount = flt(item.base_amount - distributed_amount, precision("base_amount", item));
 				});
 
 				this.discount_amount_applied = true;
 				this._calculate_taxes_and_totals();
 			}
+		} else {
+			this.frm.set_value("base_discount_amount", 0);
 		}
 	},
 
@@ -506,12 +511,12 @@
 				}
 			});
 		};
-		setup_field_label_map(["net_total", "other_charges_total", "grand_total",
+		setup_field_label_map(["net_total", "other_charges_total", "base_discount_amount", "grand_total",
 			"rounded_total", "in_words",
 			"outstanding_amount", "total_advance", "paid_amount", "write_off_amount"],
 			company_currency);
 
-		setup_field_label_map(["net_total_export", "other_charges_total_export", "grand_total_export",
+		setup_field_label_map(["net_total_export", "other_charges_total_export", "discount_amount", "grand_total_export",
 			"rounded_total_export", "in_words_export"], this.frm.doc.currency);
 
 		cur_frm.set_df_property("conversion_rate", "description", "1 " + this.frm.doc.currency
@@ -524,7 +529,7 @@
 
 		// toggle fields
 		this.frm.toggle_display(["conversion_rate", "net_total", "other_charges_total",
-			"grand_total", "rounded_total", "in_words"],
+			"grand_total", "rounded_total", "in_words", "base_discount_amount"],
 			this.frm.doc.currency != company_currency);
 
 		this.frm.toggle_display(["plc_conversion_rate", "price_list_currency"],
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js
index 939eae6..3252e8a 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.js
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.js
@@ -61,14 +61,27 @@
 				fields: [
 					{
 						"fieldname": "language", "label": __("Language"), "fieldtype": "Select",
-						options: ["english", "العربية", "deutsch", "ελληνικά", "español", "français", "हिंदी", "hrvatski",
-							"italiano", "nederlands", "polski", "português brasileiro", "português", "српски", "தமிழ்",
-							"ไทย", "中国(简体)", "中國(繁體)"],
-						reqd:1, "default": "english"
+						reqd:1
 					},
 				],
 				help: __("Welcome to ERPNext. Please select your language to begin the Setup Wizard."),
 				onload: function(slide) {
+					var me = this;
+
+					if (!this.language_list) {
+						frappe.call({
+							method: "erpnext.setup.page.setup_wizard.setup_wizard.load_languages",
+							callback: function(r) {
+								me.language_list = r.message;
+								slide.get_input("language")
+									.add_options(r.message)
+									.val("english");
+							}
+						})
+					} else {
+						slide.get_input("language").add_options(this.language_list);
+					}
+
 					slide.get_input("language").on("change", function() {
 						var lang = $(this).val() || "english";
 						frappe._messages = {};
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index c5e3f43..6e3c718 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -434,4 +434,6 @@
 	send_translations(m)
 	return lang
 
-
+@frappe.whitelist()
+def load_languages():
+	return sorted(get_lang_dict().keys())
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 4a957ff..c7a25d2 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -178,7 +178,7 @@
   {
    "fieldname": "po_no", 
    "fieldtype": "Data", 
-   "hidden": 1, 
+   "hidden": 0, 
    "label": "Customer's Purchase Order No", 
    "no_copy": 0, 
    "oldfieldname": "po_no", 
@@ -435,6 +435,15 @@
    "permlevel": 0
   }, 
   {
+   "fieldname": "other_charges_total_export", 
+   "fieldtype": "Currency", 
+   "label": "Taxes and Charges Total", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "other_charges_total", 
    "fieldtype": "Currency", 
    "label": "Taxes and Charges Total (Company Currency)", 
@@ -453,22 +462,23 @@
    "permlevel": 0
   }, 
   {
-   "fieldname": "other_charges_total_export", 
-   "fieldtype": "Currency", 
-   "label": "Taxes and Charges Total", 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1
-  }, 
-  {
    "fieldname": "discount_amount", 
    "fieldtype": "Currency", 
    "label": "Discount Amount", 
-   "options": "Company:company:default_currency", 
+   "options": "currency", 
    "permlevel": 0
   }, 
   {
+   "fieldname": "base_discount_amount", 
+   "fieldtype": "Currency", 
+   "label": "Discount Amount (Company Currency)", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "read_only": 1
+  }, 
+  {
    "fieldname": "totals", 
    "fieldtype": "Section Break", 
    "label": "Totals", 
@@ -1013,7 +1023,7 @@
  "idx": 1, 
  "in_create": 0, 
  "is_submittable": 1, 
- "modified": "2014-09-09 05:35:30.700911", 
+ "modified": "2015-01-12 16:56:39.975961", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Delivery Note", 
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index b8a3190..366e828 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -229,7 +229,7 @@
 			if not frappe.db.exists("Item", newdn):
 				frappe.throw(_("Item {0} does not exist").format(newdn))
 
-			field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"]
+			field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no", "is_manufactured_item"]
 			new_properties = [cstr(d) for d in frappe.db.get_value("Item", newdn, field_list)]
 			if new_properties != [cstr(self.get(fld)) for fld in field_list]:
 				frappe.throw(_("To merge, following properties must be same for both items")
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index 9263907..4ce940c 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -27,7 +27,7 @@
 		where item_code = %s and warehouse = %s""", (item, warehouse), as_dict = 1)
 	return det and det[0] or ''
 
-def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packing_list_idx):
+def update_packing_list_item(obj, packing_item_code, qty, warehouse, line):
 	bin = get_bin_qty(packing_item_code, warehouse)
 	item = get_packing_item_details(packing_item_code)
 
@@ -54,9 +54,7 @@
 		pi.warehouse = warehouse
 	if not pi.batch_no:
 		pi.batch_no = cstr(line.get("batch_no"))
-	pi.idx = packing_list_idx
 
-	packing_list_idx += 1
 
 
 def make_packing_list(obj, item_table_fieldname):
@@ -64,13 +62,11 @@
 
 	if obj.get("_action") and obj._action == "update_after_submit": return
 
-	packing_list_idx = 0
 	parent_items = []
 	for d in obj.get(item_table_fieldname):
 		if frappe.db.get_value("Sales BOM", {"new_item_code": d.item_code}):
 			for i in get_sales_bom_items(d.item_code):
-				update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty),
-					d.warehouse, d, packing_list_idx)
+				update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty), d.warehouse, d)
 
 			if [d.item_code, d.name] not in parent_items:
 				parent_items.append([d.item_code, d.name])
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 4f3480c..81a2f59 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -45,7 +45,6 @@
 		self.validate_warehouse(pro_obj)
 		self.validate_production_order()
 		self.get_stock_and_rate()
-		self.validate_incoming_rate()
 		self.validate_bom()
 		self.validate_finished_goods()
 		self.validate_return_reference_doc()
@@ -190,16 +189,10 @@
 					+ self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
 
 	def validate_valuation_rate(self):
-		if self.purpose in ["Manufacture", "Repack"]:
-			valuation_at_source, valuation_at_target = 0, 0
-			for d in self.get("mtn_details"):
-				if d.s_warehouse and not d.t_warehouse:
-					valuation_at_source += flt(d.amount)
-				if d.t_warehouse and not d.s_warehouse:
-					valuation_at_target += flt(d.amount)
+		for d in self.get('mtn_details'):
+			if d.t_warehouse:
+				self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
 
-			if valuation_at_target < valuation_at_source:
-				frappe.throw(_("Total valuation for manufactured or repacked item(s) can not be less than total valuation of raw materials"))
 
 	def set_total_amount(self):
 		self.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")])
@@ -241,7 +234,7 @@
 					incoming_rate = flt(self.get_incoming_rate(args), self.precision("incoming_rate", d))
 					if incoming_rate > 0:
 						d.incoming_rate = incoming_rate
-				d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
+				d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("amount", d))
 				if not d.t_warehouse:
 					raw_material_cost += flt(d.amount)
 
@@ -255,8 +248,9 @@
 						if d.bom_no:
 							bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1)
 							operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
-						d.incoming_rate = operation_cost_per_unit + (raw_material_cost + flt(self.total_fixed_cost)) / flt(d.transfer_qty)
-					d.amount = flt(d.transfer_qty) * flt(d.incoming_rate)
+						d.incoming_rate = flt(operation_cost_per_unit +
+							(raw_material_cost + flt(self.total_fixed_cost)) / flt(d.transfer_qty), self.precision("incoming_rate", d))
+					d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("transfer_qty", d))
 					break
 
 	def get_incoming_rate(self, args):
@@ -280,11 +274,6 @@
 
 		return incoming_rate
 
-	def validate_incoming_rate(self):
-		for d in self.get('mtn_details'):
-			if d.t_warehouse:
-				self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
-
 	def validate_bom(self):
 		for d in self.get('mtn_details'):
 			if d.bom_no and not frappe.db.sql("""select name from `tabBOM`
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index e010bd1..73f1d0a 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -936,6 +936,8 @@
 		"incoming_rate": incoming_rate,
 		"conversion_factor": 1.0
 	})
+	s.posting_date= "2013-01-01"
+	s.fiscal_year= "_Test Fiscal Year 2013"
 	s.insert()
 	s.submit()
 	return s
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 7fdd440..6202e94 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -39,8 +39,8 @@
 				(self.warehouse, self.item_code, self.batch_no))[0][0])
 
 			if batch_bal_after_transaction < 0:
-				frappe.throw(_("Negative balance in Batch {0} for Item {1} at Warehouse {2} on {3} {4}").format(\
-					batch_bal_after_transaction - self.actual_qty, self.item_code, self.warehouse,
+				frappe.throw(_("Negative balance {0} in Batch {1} for Item {2} at Warehouse {3} on {4} {5}")
+					.format(batch_bal_after_transaction - self.actual_qty, self.batch_no, self.item_code, self.warehouse,
 						formatdate(self.posting_date), self.posting_time))
 
 	def validate_mandatory(self):
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 530ab9a..9c85277 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -153,8 +153,8 @@
 				if row.valuation_rate in ("", None):
 					row.valuation_rate = previous_sle.get("valuation_rate")
 
-			# if row.qty and not row.valuation_rate:
-			# 	frappe.throw(_("Valuation Rate required for Item {0}").format(row.item_code))
+			if row.qty and not row.valuation_rate:
+				frappe.throw(_("Valuation Rate required for Item {0}").format(row.item_code))
 
 			self.insert_entries(row)
 
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index fffb52e..5145e0a 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe import _, throw
-from frappe.utils import flt, cint, add_days
+from frappe.utils import flt, cint, add_days, cstr
 import json
 from erpnext.accounts.doctype.pricing_rule.pricing_rule import get_pricing_rule_for_item
 from erpnext.setup.utils import get_exchange_rate
@@ -140,7 +140,7 @@
 
 		"item_code": item.name,
 		"item_name": item.item_name,
-		"description": item.description_html or item.description,
+		"description": cstr(item.description_html).strip() or cstr(item.description).strip(),
 		"warehouse": user_default_warehouse or args.warehouse or item.default_warehouse,
 		"income_account": (item.income_account
 			or args.income_account
diff --git a/erpnext/templates/print_formats/includes/taxes.html b/erpnext/templates/print_formats/includes/taxes.html
index bd1e709..61a78a3 100644
--- a/erpnext/templates/print_formats/includes/taxes.html
+++ b/erpnext/templates/print_formats/includes/taxes.html
@@ -7,7 +7,7 @@
 				<div class="col-xs-5 text-right">
 					<label>{{ charge.get_formatted("description") }}</label></div>
 				<div class="col-xs-7 text-right">
-					{{ frappe.format_value(charge.tax_amount / doc.conversion_rate,
+					{{ frappe.format_value(frappe.utils.flt(charge.tax_amount) / doc.conversion_rate,
 						table_meta.get_field("tax_amount"), doc, currency=doc.currency) }}
 				</div>
 			</div>
diff --git a/erpnext/translations/ar.csv b/erpnext/translations/ar.csv
index 54462f6..63ed806 100644
--- a/erpnext/translations/ar.csv
+++ b/erpnext/translations/ar.csv
@@ -85,7 +85,7 @@
 "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",قيد محاسبي المجمدة تصل إلى هذا التاريخ، لا أحد يمكن أن تفعل / تعديل إدخال باستثناء دور المحددة أدناه.

 Accounting journal entries.,المحاسبة إدخالات دفتر اليومية.

 Accounts,حسابات

-Accounts Browser,متصفح الحسابات 

+Accounts Browser,متصفح الحسابات

 Accounts Frozen Upto,حسابات مجمدة حتي

 Accounts Payable,ذمم دائنة

 Accounts Receivable,حسابات القبض

@@ -253,8 +253,8 @@
 Approving Role cannot be same as role the rule is Applicable To,الموافقة دور لا يمكن أن يكون نفس دور القاعدة تنطبق على

 Approving User,الموافقة العضو

 Approving User cannot be same as user the rule is Applicable To,الموافقة العضو لا يمكن أن يكون نفس المستخدم القاعدة تنطبق على

-Are you sure you want to STOP ,Are you sure you want to STOP 

-Are you sure you want to UNSTOP ,Are you sure you want to UNSTOP 

+Are you sure you want to STOP ,Are you sure you want to STOP

+Are you sure you want to UNSTOP ,Are you sure you want to UNSTOP

 Arrear Amount,متأخرات المبلغ

 "As Production Order can be made for this item, it must be a stock item.",كما يمكن أن يتم ترتيب الإنتاج لهذا البند، يجب أن يكون بند الأوراق المالية .

 As per Stock UOM,وفقا للأوراق UOM

@@ -283,7 +283,7 @@
 Auto Material Request,السيارات مادة طلب

 Auto-raise Material Request if quantity goes below re-order level in a warehouse,لصناعة السيارات في رفع طلب المواد إذا كمية يذهب دون مستوى إعادة الطلب في مستودع

 Automatically compose message on submission of transactions.,يؤلف تلقائيا رسالة على تقديم المعاملات.

-Automatically extract Job Applicants from a mail box ,Automatically extract Job Applicants from a mail box 

+Automatically extract Job Applicants from a mail box ,Automatically extract Job Applicants from a mail box

 Automatically extract Leads from a mail box e.g.,استخراج الشراء تلقائيا من صندوق البريد على سبيل المثال

 Automatically updated via Stock Entry of type Manufacture/Repack,تحديثها تلقائيا عن طريق إدخال الأسهم الصنع نوع / أعد حزم

 Automotive,السيارات

@@ -410,8 +410,8 @@
 "Buying must be checked, if Applicable For is selected as {0}",يجب أن يتم التحقق الشراء، إذا تم تحديد مطبق للك {0}

 C-Form,نموذج C-

 C-Form Applicable,C-نموذج قابل للتطبيق

-C-Form Invoice Detail, تفاصيل الفاتورة نموذج - س 

-C-Form No,رقم النموذج - س 

+C-Form Invoice Detail, تفاصيل الفاتورة نموذج - س

+C-Form No,رقم النموذج - س

 C-Form records,سجلات النموذج - س

 CENVAT Capital Goods,CENVAT السلع الرأسمالية

 CENVAT Edu Cess,CENVAT ايدو سيس

@@ -510,8 +510,8 @@
 Clearance Date not mentioned,إزالة التاريخ لم يرد ذكرها

 Clearance date cannot be before check date in row {0},تاريخ التخليص لا يمكن أن يكون قبل تاريخ الاختيار في الصف {0}

 Click on 'Make Sales Invoice' button to create a new Sales Invoice.,انقر على &#39;جعل مبيعات الفاتورة &quot;الزر لإنشاء فاتورة مبيعات جديدة.

-Click on a link to get options to expand get options ,Click on a link to get options to expand get options 

-Client,عميل	

+Click on a link to get options to expand get options ,Click on a link to get options to expand get options

+Client,عميل

 Close Balance Sheet and book Profit or Loss.,وثيقة الميزانية العمومية و كتاب الربح أو الخسارة .

 Closed,مغلق

 Closing (Cr),إغلاق (الكروم)

@@ -840,13 +840,13 @@
 Divorced,المطلقات

 Do Not Contact,عدم الاتصال

 Do not show any symbol like $ etc next to currencies.,لا تظهر أي رمز مثل $ الخ بجانب العملات.

-Do really want to unstop production order: ,Do really want to unstop production order: 

-Do you really want to STOP ,Do you really want to STOP 

+Do really want to unstop production order: ,Do really want to unstop production order:

+Do you really want to STOP ,Do you really want to STOP

 Do you really want to STOP this Material Request?,هل تريد حقا لوقف هذا طلب المواد ؟

 Do you really want to Submit all Salary Slip for month {0} and year {1},هل تريد حقا لتقديم كل زلة الرواتب ل شهر {0} و السنة {1}

-Do you really want to UNSTOP ,Do you really want to UNSTOP 

+Do you really want to UNSTOP ,Do you really want to UNSTOP

 Do you really want to UNSTOP this Material Request?,هل تريد حقا أن نزع السدادة هذا طلب المواد ؟

-Do you really want to stop production order: ,Do you really want to stop production order: 

+Do you really want to stop production order: ,Do you really want to stop production order:

 Doc Name,اسم الوثيقة

 Doc Type,نوع الوثيقة

 Document Description,وصف الوثيقة

@@ -898,7 +898,7 @@
 Email,البريد الإلكتروني

 Email Digest,البريد الإلكتروني دايجست

 Email Digest Settings,البريد الإلكتروني إعدادات دايجست

-Email Digest: ,Email Digest: 

+Email Digest: ,Email Digest:

 Email Id,البريد الإلكتروني معرف

 "Email Id where a job applicant will email e.g. ""jobs@example.com""",معرف البريد الإلكتروني حيث طالب العمل سوف البريد الإلكتروني على سبيل المثال &quot;jobs@example.com&quot;

 Email Notifications,إشعارات البريد الإلكتروني

@@ -958,7 +958,7 @@
 Entertainment & Leisure,الترفيه وترفيهية

 Entertainment Expenses,مصاريف الترفيه

 Entries,مقالات

-Entries against ,Entries against 

+Entries against ,Entries against

 Entries are not allowed against this Fiscal Year if the year is closed.,لا يسمح مقالات ضد السنة المالية الحالية إذا تم إغلاق السنة.

 Equity,إنصاف

 Error: {0} > {1},الخطأ: {0} > {1}

@@ -1573,7 +1573,7 @@
 Maintenance Visit {0} must be cancelled before cancelling this Sales Order,صيانة زيارة {0} يجب أن يتم إلغاء هذا الأمر قبل إلغاء المبيعات

 Maintenance start date can not be before delivery date for Serial No {0},صيانة تاريخ بداية لا يمكن أن يكون قبل تاريخ التسليم لل رقم المسلسل {0}

 Major/Optional Subjects,الرئيسية / اختياري الموضوعات

-Make ,Make 

+Make ,Make

 Make Accounting Entry For Every Stock Movement,جعل الدخول المحاسبة للحصول على كل حركة الأسهم

 Make Bank Voucher,جعل قسيمة البنك

 Make Credit Note,جعل الائتمان ملاحظة

@@ -1722,7 +1722,7 @@
 Net Weight of each Item,الوزن الصافي لكل بند

 Net pay cannot be negative,صافي الأجور لا يمكن أن تكون سلبية

 Never,أبدا

-New ,New 

+New ,New

 New Account,حساب جديد

 New Account Name,اسم الحساب الجديد

 New BOM,BOM جديدة

@@ -2448,7 +2448,7 @@
 Rounded Total,تقريب إجمالي

 Rounded Total (Company Currency),المشاركات تقريب (العملة الشركة)

 Row # ,الصف #

-Row # {0}: ,Row # {0}: 

+Row # {0}: ,Row # {0}:

 Row #{0}: Ordered qty can not less than item's minimum order qty (defined in item master).,الصف # {0}: الكمية المطلوبة لا يمكن أن أقل من الحد الأدنى الكمية النظام القطعة (المحددة في البند الرئيسي).

 Row #{0}: Please specify Serial No for Item {1},الصف # {0}: يرجى تحديد رقم التسلسلي للتاريخ {1}

 Row {0}: Account does not match with \						Purchase Invoice Credit To account,الصف {0}: الحساب لا يتطابق مع \ شراء فاتورة الائتمان لحساب

@@ -2750,7 +2750,7 @@
 Stock Analytics,الأسهم تحليلات

 Stock Assets,الموجودات الأسهم

 Stock Balance,الأسهم الرصيد

-Stock Entries already created for Production Order ,Stock Entries already created for Production Order 

+Stock Entries already created for Production Order ,Stock Entries already created for Production Order

 Stock Entry,الأسهم الدخول

 Stock Entry Detail,الأسهم إدخال التفاصيل

 Stock Expenses,مصاريف الأسهم

@@ -3300,24 +3300,24 @@
 {0} budget for Account {1} against Cost Center {2} will exceed by {3},{0} ميزانية الحساب {1} ضد مركز التكلفة {2} سيتجاوز التي كتبها {3}

 {0} can not be negative,{0} لا يمكن أن تكون سلبية

 {0} created,{0} خلق

-{0} does not belong to Company {1},{0} لا تنتمي إلى شركة {1}

+{0} does not belong to Company {1},{0} {لا تنتمي إلى شركة {1

 {0} entered twice in Item Tax,{0} دخلت مرتين في ضريبة المدينة

 {0} is an invalid email address in 'Notification Email Address',"{0} هو عنوان بريد إلكتروني غير صالح في ' عنوان البريد الإلكتروني إعلام """

 {0} is mandatory,{0} إلزامي

-{0} is mandatory for Item {1},{0} إلزامي القطعة ل {1}

+{0} is mandatory for Item {1},{0} {إلزامي القطعة ل {1

 {0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.,{0} إلزامي. ربما لا يتم إنشاء سجل سعر صرف العملة ل{1} إلى {2}.

 {0} is not a stock Item,{0} ليس الأسهم الإغلاق

 {0} is not a valid Batch Number for Item {1},{0} ليس رقم الدفعة صالحة لل تفاصيل {1}

-{0} is not a valid Leave Approver. Removing row #{1}.,{0} ليس صحيحا اترك الموافق. إزالة الصف # {1}.

+{0} is not a valid Leave Approver. Removing row #{1}.,{0} {ليس صحيحا اترك الموافق. إزالة الصف # {1.

 {0} is not a valid email id,{0} ليس معرف بريد إلكتروني صحيح

 {0} is now the default Fiscal Year. Please refresh your browser for the change to take effect.,{0} الآن الافتراضي السنة المالية. يرجى تحديث المتصفح ل التغيير نافذ المفعول .

 {0} is required,{0} مطلوب

 {0} must be a Purchased or Sub-Contracted Item in row {1},{0} يجب أن يكون البند شراؤها أو التعاقد الفرعي في الصف {1}

 {0} must be reduced by {1} or you should increase overflow tolerance,{0} يجب تخفيض كتبها {1} أو يجب زيادة الفائض التسامح

 {0} must have role 'Leave Approver',{0} يجب أن يكون دور ' اترك الموافق '

-{0} valid serial nos for Item {1},{0} غ المسلسل صالحة لل تفاصيل {1}

-{0} {1} against Bill {2} dated {3},{0} {1} ضد بيل {2} بتاريخ {3}

-{0} {1} against Invoice {2},{0} {1} ضد الفاتورة {2}

+{0} valid serial nos for Item {1},{0} {غ المسلسل صالحة لل تفاصيل {1

+{0} {1} against Bill {2} dated {3},{0} {1} {ضد بيل {2} بتاريخ {3

+{0} {1} against Invoice {2},{0} {1} {ضد الفاتورة {2

 {0} {1} has already been submitted,{0} {1} وقد تم بالفعل قدمت

 {0} {1} has been modified. Please refresh.,{0} {1} تم تعديل . يرجى تحديث.

 {0} {1} is not submitted,{0} {1} لا تقدم

diff --git a/erpnext/translations/el.csv b/erpnext/translations/el.csv
index ba119ba..dc5ff75 100644
--- a/erpnext/translations/el.csv
+++ b/erpnext/translations/el.csv
@@ -255,7 +255,7 @@
 Approving User,Έγκριση χρήστη

 Approving User cannot be same as user the rule is Applicable To,Την έγκριση του χρήστη δεν μπορεί να είναι ίδιο με το χρήστη ο κανόνας ισχύει για

 Are you sure you want to STOP ,Είσαστε σίγουροι πως θέλετε να σταματήσετε

-Are you sure you want to UNSTOP ,Are you sure you want to UNSTOP 

+Are you sure you want to UNSTOP ,Are you sure you want to UNSTOP

 Arrear Amount,Καθυστερήσεις Ποσό

 "As Production Order can be made for this item, it must be a stock item.","Όπως μπορεί να γίνει Παραγωγής παραγγελίας για το συγκεκριμένο προϊόν , θα πρέπει να είναι ένα στοιχείο υλικού."

 As per Stock UOM,Όπως ανά Διαθέσιμο UOM

@@ -284,7 +284,7 @@
 Auto Material Request,Αυτόματη Αίτηση Υλικό

 Auto-raise Material Request if quantity goes below re-order level in a warehouse,Auto-raise Αίτηση Υλικό εάν η ποσότητα πέσει κάτω εκ νέου για το επίπεδο σε μια αποθήκη

 Automatically compose message on submission of transactions.,Αυτόματη συνθέτουν το μήνυμα για την υποβολή των συναλλαγών .

-Automatically extract Job Applicants from a mail box ,Automatically extract Job Applicants from a mail box 

+Automatically extract Job Applicants from a mail box ,Automatically extract Job Applicants from a mail box

 Automatically extract Leads from a mail box e.g.,"Αυτόματη εξαγωγή οδηγεί από ένα κουτί αλληλογραφίας , π.χ."

 Automatically updated via Stock Entry of type Manufacture/Repack,Αυτόματη ενημέρωση μέσω είσοδο στα αποθέματα Κατασκευή Τύπος / Repack

 Automotive,Αυτοκίνητο

@@ -511,7 +511,7 @@
 Clearance Date not mentioned,Εκκαθάριση Ημερομηνία που δεν αναφέρονται

 Clearance date cannot be before check date in row {0},Ημερομηνία εκκαθάρισης δεν μπορεί να είναι πριν από την ημερομηνία άφιξης στη γραμμή {0}

 Click on 'Make Sales Invoice' button to create a new Sales Invoice.,Κάντε κλικ στο «Κάνε Πωλήσεις Τιμολόγιο» για να δημιουργηθεί μια νέα τιμολογίου πώλησης.

-Click on a link to get options to expand get options ,Click on a link to get options to expand get options 

+Click on a link to get options to expand get options ,Click on a link to get options to expand get options

 Client,Πελάτης

 Close Balance Sheet and book Profit or Loss.,Κλείσιμο Ισολογισμού και των Αποτελεσμάτων βιβλίο ή απώλεια .

 Closed,Κλειστό

@@ -841,13 +841,13 @@
 Divorced,Διαζευγμένος

 Do Not Contact,Μην Επικοινωνία

 Do not show any symbol like $ etc next to currencies.,Να μην εμφανίζεται κανένα σύμβολο όπως $ κλπ δίπλα σε νομίσματα.

-Do really want to unstop production order: ,Do really want to unstop production order: 

-Do you really want to STOP ,Do you really want to STOP 

+Do really want to unstop production order: ,Do really want to unstop production order:

+Do you really want to STOP ,Do you really want to STOP

 Do you really want to STOP this Material Request?,Θέλετε πραγματικά να σταματήσει αυτό το υλικό την Αίτηση Συμμετοχής;

 Do you really want to Submit all Salary Slip for month {0} and year {1},Θέλετε πραγματικά να υποβληθούν όλα τα Slip Μισθός για το μήνα {0} και {1 χρόνο }

-Do you really want to UNSTOP ,Do you really want to UNSTOP 

+Do you really want to UNSTOP ,Do you really want to UNSTOP

 Do you really want to UNSTOP this Material Request?,Θέλετε πραγματικά να ξεβουλώνω αυτό Υλικό Αίτηση Συμμετοχής;

-Do you really want to stop production order: ,Do you really want to stop production order: 

+Do you really want to stop production order: ,Do you really want to stop production order:

 Doc Name,Doc Name

 Doc Type,Doc Τύπος

 Document Description,Περιγραφή εγγράφου

@@ -899,7 +899,7 @@
 Email,Email

 Email Digest,Email Digest

 Email Digest Settings,Email Digest Ρυθμίσεις

-Email Digest: ,Email Digest: 

+Email Digest: ,Email Digest:

 Email Id,Id Email

 "Email Id where a job applicant will email e.g. ""jobs@example.com""","Email Id, όπου ένας υποψήφιος θα e-mail π.χ. &quot;jobs@example.com&quot;"

 Email Notifications,Ειδοποιήσεις μέσω ηλεκτρονικού ταχυδρομείου

@@ -959,7 +959,7 @@
 Entertainment & Leisure,Διασκέδαση & Leisure

 Entertainment Expenses,Έξοδα Ψυχαγωγία

 Entries,Καταχωρήσεις

-Entries against ,Entries against 

+Entries against ,Entries against

 Entries are not allowed against this Fiscal Year if the year is closed.,"Οι συμμετοχές δεν επιτρέπεται κατά το τρέχον οικονομικό έτος, εάν το έτος είναι κλειστή."

 Equity,δικαιοσύνη

 Error: {0} > {1},Σφάλμα : {0} > {1}

@@ -1574,7 +1574,7 @@
 Maintenance Visit {0} must be cancelled before cancelling this Sales Order,Συντήρηση Επίσκεψη {0} πρέπει να ακυρωθεί πριν από την ακύρωση αυτής της παραγγελίας πώλησης

 Maintenance start date can not be before delivery date for Serial No {0},Ημερομηνία έναρξης συντήρησης δεν μπορεί να είναι πριν από την ημερομηνία παράδοσης Αύξων αριθμός {0}

 Major/Optional Subjects,Σημαντικές / προαιρετικά μαθήματα

-Make ,Make 

+Make ,Make

 Make Accounting Entry For Every Stock Movement,Κάντε Λογιστική καταχώρηση για κάθε Κίνημα Χρηματιστήριο

 Make Bank Voucher,Κάντε Voucher Bank

 Make Credit Note,Κάντε Πιστωτικό Σημείωμα

@@ -1723,7 +1723,7 @@
 Net Weight of each Item,Καθαρό βάρος κάθε είδους

 Net pay cannot be negative,Καθαρή αμοιβή δεν μπορεί να είναι αρνητική

 Never,Ποτέ

-New ,New 

+New ,New

 New Account,Νέος λογαριασμός

 New Account Name,Νέο Όνομα λογαριασμού

 New BOM,Νέα BOM

@@ -2449,7 +2449,7 @@
 Rounded Total,Στρογγυλεμένες Σύνολο

 Rounded Total (Company Currency),Στρογγυλεμένες Σύνολο (νόμισμα της Εταιρείας)

 Row # ,Row #

-Row # {0}: ,Row # {0}: 

+Row # {0}: ,Row # {0}:

 Row #{0}: Ordered qty can not less than item's minimum order qty (defined in item master).,Σειρά # {0}: Διέταξε ποσότητα δεν μπορεί να μικρότερη από την ελάχιστη ποσότητα σειρά στοιχείου (όπως ορίζεται στο σημείο master).

 Row #{0}: Please specify Serial No for Item {1},Σειρά # {0}: Παρακαλείστε να προσδιορίσετε Αύξων αριθμός για τη θέση {1}

 Row {0}: Account does not match with \						Purchase Invoice Credit To account,Σειρά {0}: Ο λογαριασμός δεν ταιριάζει με \ τιμολογίου αγοράς πίστωση του λογαριασμού

@@ -3317,7 +3317,7 @@
 {0} must be reduced by {1} or you should increase overflow tolerance,{0} πρέπει να μειωθεί κατά {1} ή θα πρέπει να αυξήσει την ανοχή υπερχείλισης

 {0} must have role 'Leave Approver',{0} πρέπει να έχει ρόλο « Αφήστε Έγκρισης »

 {0} valid serial nos for Item {1},{0} έγκυρο σειριακό nos για τη θέση {1}

-{0} {1} against Bill {2} dated {3},{0} {1} εναντίον Bill {2} { 3 με ημερομηνία }

+{0} {1} against Bill {2} dated {3},{0} {1} εναντίον Bill {2} {3} με ημερομηνία

 {0} {1} against Invoice {2},{0} {1} κατά Τιμολόγιο {2}

 {0} {1} has already been submitted,{0} {1} έχει ήδη υποβληθεί

 {0} {1} has been modified. Please refresh.,{0} {1} έχει τροποποιηθεί . Παρακαλώ ανανεώσετε .

diff --git a/erpnext/translations/es.csv b/erpnext/translations/es.csv
index d6add66..f3a0cee 100644
--- a/erpnext/translations/es.csv
+++ b/erpnext/translations/es.csv
@@ -3322,7 +3322,7 @@
 {0} must be reduced by {1} or you should increase overflow tolerance,{0} debe reducirse en {1} o se debe aumentar la tolerancia de desbordamiento

 {0} must have role 'Leave Approver',{0} debe tener rol ' Dejar aprobador '

 {0} valid serial nos for Item {1},{0} nn serie válidos para el elemento {1}

-{0} {1} against Bill {2} dated {3},{0} {1} { 2 contra Bill } {3} de fecha

+{0} {1} against Bill {2} dated {3},{0} {1} {2} contra Bill {3} de fecha

 {0} {1} against Invoice {2},{0} {1} contra Factura {2}

 {0} {1} has already been submitted,{0} {1} ya ha sido presentado

 {0} {1} has been modified. Please refresh.,{0} {1} ha sido modificado. Por favor regenere .

diff --git a/erpnext/translations/fr.csv b/erpnext/translations/fr.csv
index 1d0484f..9480f0c 100644
--- a/erpnext/translations/fr.csv
+++ b/erpnext/translations/fr.csv
@@ -3318,7 +3318,7 @@
 {0} must be reduced by {1} or you should increase overflow tolerance,{0} doit être réduite par {1} ou vous devez augmenter la tolérance de dépassement

 {0} must have role 'Leave Approver',Nouveau Stock UDM est nécessaire

 {0} valid serial nos for Item {1},BOM {0} pour objet {1} à la ligne {2} est inactif ou non soumis

-{0} {1} against Bill {2} dated {3},S'il vous plaît entrer le titre !

+{0} {1} against Bill {2} dated {3},{0} {1} contre le projet de loi en date du {2} {3}

 {0} {1} against Invoice {2},investissements

 {0} {1} has already been submitted,"S'il vous plaît entrer » est sous-traitée "" comme Oui ou Non"

 {0} {1} has been modified. Please refresh.,Point ou Entrepôt à la ligne {0} ne correspond pas à la Demande de Matériel

diff --git a/erpnext/utilities/doctype/note/note.py b/erpnext/utilities/doctype/note/note.py
index 2db4137..08f56fe 100644
--- a/erpnext/utilities/doctype/note/note.py
+++ b/erpnext/utilities/doctype/note/note.py
@@ -27,7 +27,7 @@
 	return """(`tabNote`.public=1 or `tabNote`.owner="{user}" or exists (
 		select name from `tabNote User`
 			where `tabNote User`.parent=`tabNote`.name
-			and `tabNote User`.user="{user}"))""".format(user=user)
+			and `tabNote User`.user="{user}"))""".format(user=frappe.db.escape(user))
 
 def has_permission(doc, ptype, user):
 	if doc.public == 1 or user == "Administrator":
diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py
index b63493e..2985725 100644
--- a/erpnext/utilities/repost_stock.py
+++ b/erpnext/utilities/repost_stock.py
@@ -240,7 +240,7 @@
 				doc.validate()
 
 			doc.update_stock_ledger()
-			doc.make_gl_entries(repost_future_gle=False, allow_negative_stock=True)
+			doc.make_gl_entries(repost_future_gle=False)
 			frappe.db.commit()
 		except Exception, e:
 			print frappe.get_traceback()
diff --git a/setup.py b/setup.py
index 9bb8330..146361f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import os
 
-version = "4.12.0"
+version = "4.18.1"
 
 with open("requirements.txt", "r") as f:
 	install_requires = f.readlines()