Merge pull request #4413 from nabinhait/bank_transfer_exchange_rate

Bank transfer exchange rate and account balance in COA
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 1d96984..4220bc7 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
 from __future__ import unicode_literals
-__version__ = '6.12.1'
+__version__ = '6.12.2'
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index c540582..ec22483 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -350,7 +350,7 @@
 			elif frappe.db.get_value("Account", d.account, "account_type") in ["Bank", "Cash"]:
 				total_amount += (d.debit_in_account_currency or d.credit_in_account_currency)
 				bank_account_currency = d.account_currency
-				
+
 		self.set_total_amount(total_amount, bank_account_currency)
 
 	def set_total_amount(self, amt, currency):
@@ -743,6 +743,11 @@
 		"exchange_rate": get_exchange_rate(account, account_details.account_currency,
 			company, debit=debit, credit=credit, exchange_rate=exchange_rate)
 	}
+
+	# un-set party if not party type
+	if not party_type:
+		grid_values["party"] = ""
+
 	return grid_values
 
 @frappe.whitelist()
diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
index 348c444..9277da5 100644
--- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
+++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
@@ -10,7 +10,7 @@
  "fields": [
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "fieldname": "account", 
    "fieldtype": "Link", 
@@ -334,7 +334,7 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "fieldname": "debit_in_account_currency", 
    "fieldtype": "Currency", 
@@ -359,7 +359,7 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "fieldname": "debit", 
    "fieldtype": "Currency", 
@@ -408,7 +408,7 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "fieldname": "credit_in_account_currency", 
    "fieldtype": "Currency", 
@@ -433,7 +433,7 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "fieldname": "credit", 
    "fieldtype": "Currency", 
@@ -614,7 +614,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2015-11-24 02:36:05.804010", 
+ "modified": "2015-12-02 04:14:37.571883", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Journal Entry Account", 
diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.js b/erpnext/accounts/doctype/tax_rule/tax_rule.js
index 4b059dc..4c35370 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.js
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.js
@@ -4,19 +4,26 @@
 cur_frm.add_fetch("customer", "customer_group", "customer_group" );
 cur_frm.add_fetch("supplier", "supplier_type", "supplier_type" );
 
-cur_frm.toggle_reqd("sales_tax_template", cur_frm.doc.tax_type=="Sales");
-cur_frm.toggle_reqd("purchase_tax_template", cur_frm.doc.tax_type=="Purchase");
-
+frappe.ui.form.on("Tax Rule", "tax_type", function(frm) {
+	frm.toggle_reqd("sales_tax_template", frm.doc.tax_type=="Sales");
+	frm.toggle_reqd("purchase_tax_template", frm.doc.tax_type=="Purchase");
+})
 
 frappe.ui.form.on("Tax Rule", "onload", function(frm) {
-	if(frm.doc.__islocal){
+	if(frm.doc.__islocal) {
 		frm.set_value("use_for_shopping_cart", 1);
 	}
 })
 
+frappe.ui.form.on("Tax Rule", "refresh", function(frm) {
+	frappe.ui.form.trigger("Tax Rule", "tax_type");
+})
+
 frappe.ui.form.on("Tax Rule", "use_for_shopping_cart", function(frm) {
-	if(!frm.doc.use_for_shopping_cart && (frappe.get_list("Tax Rule", {"use_for_shopping_cart":1}).length == 0)){
-		frappe.model.get_value("Shopping Cart Settings", "Shopping Cart Settings", "enabled", function(docfield) {
+	if(!frm.doc.use_for_shopping_cart && 
+			(frappe.get_list("Tax Rule", {"use_for_shopping_cart":1}).length == 0)) {
+		frappe.model.get_value("Shopping Cart Settings", "Shopping Cart Settings", 
+				"enabled", function(docfield) {
 			if(docfield.enabled){
 				frm.set_value("use_for_shopping_cart", 1);
 				frappe.throw(__("Shopping Cart is enabled"));
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index f4d24d8..bb68978 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -7,7 +7,7 @@
 app_description = """ERP made simple"""
 app_icon = "icon-th"
 app_color = "#e74c3c"
-app_version = "6.12.1"
+app_version = "6.12.2"
 app_email = "info@erpnext.com"
 app_license = "GNU General Public License (v3)"
 source_link = "https://github.com/frappe/erpnext"
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 88d1402..ea7c96e 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -29,10 +29,15 @@
 
 	def check_sal_struct(self):
 		m = get_month_details(self.fiscal_year, self.month)
+		
+		joining_date, relieving_date = frappe.db.get_value("Employee", self.employee, 
+			["date_of_joining", "relieving_date"])
+		
 		struct = frappe.db.sql("""select name from `tabSalary Structure`
 			where employee=%s and is_active = 'Yes'
-			and from_date <= %s and (to_date is null or to_date >= %s)""",
-			(self.employee, m.month_start_date, m.month_end_date))
+			and (from_date <= %s or from_date <= %s) 
+			and (to_date is null or to_date >= %s or to_date >= %s)""",
+			(self.employee, m.month_start_date, joining_date, m.month_end_date, relieving_date))
 
 		if not struct:
 			msgprint(_("No active Salary Structure found for employee {0} and the month")
diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py
index 1acd8de..126acfc 100644
--- a/erpnext/patches/v4_4/make_email_accounts.py
+++ b/erpnext/patches/v4_4/make_email_accounts.py
@@ -35,7 +35,7 @@
 			"enable_incoming": "sync_support_mails",
 			"email_id": "mail_login",
 			"password": "mail_password",
-			"pop3_server": "mail_server",
+			"email_server": "mail_server",
 			"use_ssl": "use_ssl",
 			"signature": "support_signature",
 			"enable_auto_reply": "send_autoreply",
@@ -59,7 +59,7 @@
 				"enable_incoming": "extract_emails",
 				"email_id": "username",
 				"password": "password",
-				"pop3_server": "host",
+				"email_server": "host",
 				"use_ssl": "use_ssl",
 			}
 
diff --git a/erpnext/patches/v6_8/move_drop_ship_to_po_items.py b/erpnext/patches/v6_8/move_drop_ship_to_po_items.py
index 1c2a57a..06d158e 100644
--- a/erpnext/patches/v6_8/move_drop_ship_to_po_items.py
+++ b/erpnext/patches/v6_8/move_drop_ship_to_po_items.py
@@ -4,6 +4,9 @@
 	frappe.reload_doctype("Purchase Order")
 	frappe.reload_doctype("Purchase Order Item")
 
+	if not frappe.db.has_column("Purchase Order", "delivered_by_supplier"):
+		return
+
 	for po in frappe.get_all("Purchase Order", filters={"delivered_by_supplier": 1}, fields=["name"]):
 		purchase_order = frappe.get_doc("Purchase Order", po)
 
diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py
index bfab79f..dff05bc 100644
--- a/erpnext/utilities/doctype/contact/contact.py
+++ b/erpnext/utilities/doctype/contact/contact.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import cstr
+from frappe import _
 
 from erpnext.controllers.status_updater import StatusUpdater
 
@@ -61,6 +62,10 @@
 @frappe.whitelist()
 def invite_user(contact):
 	contact = frappe.get_doc("Contact", contact)
+
+	if not contact.email_id:
+		frappe.throw(_("Please set Email ID"))
+
 	if contact.has_permission("write"):
 		user = frappe.get_doc({
 			"doctype": "User",
diff --git a/setup.py b/setup.py
index 8ef1565..ffaee6b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 from setuptools import setup, find_packages
 
-version = "6.12.1"
+version = "6.12.2"
 
 with open("requirements.txt", "r") as f:
 	install_requires = f.readlines()