Apply Tax Rule based on Customer Selection in Sales / Purchase Transactions
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 4f49bc0..313544f 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -43,6 +43,7 @@
 	set_contact_details(out, party, party_type)
 	set_other_values(out, party, party_type)
 	set_price_list(out, party, party_type, price_list)
+	out["taxes_and_charges"] = set_taxes(party.name, party_type, posting_date, company, out)
 
 	if not out.get("currency"):
 		out["currency"] = currency
@@ -99,7 +100,7 @@
 		out[f] = party.get(f)
 
 	# fields prepended with default in Customer doctype
-	for f in ['currency', 'taxes_and_charges'] \
+	for f in ['currency'] \
 		+ (['sales_partner', 'commission_rate'] if party_type=="Customer" else []):
 		if party.get("default_" + f):
 			out[f] = party.get("default_" + f)
@@ -274,4 +275,21 @@
 				msgprint(_("Note: Due / Reference Date exceeds allowed customer credit days by {0} day(s)")
 					.format(date_diff(due_date, default_due_date)))
 			else:
-				frappe.throw(_("Due / Reference Date cannot be after {0}").format(formatdate(default_due_date)))
\ No newline at end of file
+				frappe.throw(_("Due / Reference Date cannot be after {0}").format(formatdate(default_due_date)))
+				
+def set_taxes(party, party_type, posting_date, company, out):
+	print "posting_date", posting_date
+	from erpnext.accounts.doctype.tax_rule.tax_rule import get_tax_template, get_party_details
+	args = {
+		party_type: 		party,
+		"customer_group":	out.customer_group,
+		"supplier_type":	out.supplier_type,
+		"company":			company
+	}
+	args.update(get_party_details(party, party_type))
+	if party_type=="Customer":
+		args.update({"tax_type": "Sales"})
+	else:
+		args.update({"tax_type": "Purchase"})
+		
+	return get_tax_template(posting_date, args)
\ No newline at end of file