[fix] Mapping from Payment Tool
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 1a90aab..b99d377 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -28,7 +28,7 @@
 		self.validate_entries_for_advance()
 		self.validate_multi_currency()
 		self.set_amounts_in_company_currency()
-		self.validate_debit_and_credit()
+		self.validate_total_debit_and_credit()
 		self.validate_against_jv()
 		self.validate_reference_doc()
 		self.set_against_account()
@@ -252,7 +252,13 @@
 			if flt(d.debit > 0): d.against_account = ", ".join(list(set(accounts_credited)))
 			if flt(d.credit > 0): d.against_account = ", ".join(list(set(accounts_debited)))
 
-	def validate_debit_and_credit(self):
+	def validate_total_debit_and_credit(self):
+		self.set_total_debit_credit()
+		if self.difference:
+			frappe.throw(_("Total Debit must be equal to Total Credit. The difference is {0}")
+				.format(self.difference))
+				
+	def set_total_debit_credit(self):
 		self.total_debit, self.total_credit, self.difference = 0, 0, 0
 		for d in self.get("accounts"):
 			if d.debit and d.credit:
@@ -264,10 +270,6 @@
 		self.difference = flt(self.total_debit, self.precision("total_debit")) - \
 			flt(self.total_credit, self.precision("total_credit"))
 
-		if self.difference:
-			frappe.throw(_("Total Debit must be equal to Total Credit. The difference is {0}")
-				.format(self.difference))
-
 	def validate_multi_currency(self):
 		alternate_currency = []
 		for d in self.get("accounts"):
@@ -404,7 +406,7 @@
 					blank_row.debit_in_account_currency = abs(diff)
 					blank_row.debit = abs(diff)
 
-			self.validate_debit_and_credit()
+			self.validate_total_debit_and_credit()
 
 	def get_outstanding_invoices(self):
 		self.set('accounts', [])
@@ -432,7 +434,7 @@
 		elif self.write_off_based_on == 'Accounts Payable':
 			jd2.credit = total
 
-		self.validate_debit_and_credit()
+		self.validate_total_debit_and_credit()
 
 
 	def get_values(self):
@@ -601,7 +603,7 @@
 		"account_type": frappe.db.get_value("Account", args.get("party_account"), "account_type"),
 		"account_currency": args.get("party_account_currency") or \
 			get_account_currency(args.get("party_account")),
-		"account_balance": get_balance_on(args.get("party_account")),
+		"balance": get_balance_on(args.get("party_account")),
 		"party_balance": get_balance_on(party=args.get("party"), party_type=args.get("party_type")),
 		"exchange_rate": exchange_rate,
 		args.get("amount_field_party"): args.get("amount"),
@@ -630,6 +632,7 @@
 			jv.multi_currency = 1
 
 	jv.set_amounts_in_company_currency()
+	jv.set_total_debit_credit()
 
 	return jv.as_dict()
 
diff --git a/erpnext/accounts/doctype/payment_tool/payment_tool.py b/erpnext/accounts/doctype/payment_tool/payment_tool.py
index aa7b127..d6629b6 100644
--- a/erpnext/accounts/doctype/payment_tool/payment_tool.py
+++ b/erpnext/accounts/doctype/payment_tool/payment_tool.py
@@ -8,6 +8,7 @@
 from frappe.model.document import Document
 import json
 from erpnext.accounts.utils import get_account_currency
+from erpnext.accounts.doctype.journal_entry.journal_entry import get_exchange_rate
 
 class PaymentTool(Document):
 	def make_journal_entry(self):
@@ -19,7 +20,15 @@
 		jv.company = self.company
 		jv.cheque_no = self.reference_no
 		jv.cheque_date = self.reference_date
-
+		
+		party_account_currency, party_account_type = frappe.db.get_value("Account", self.party_account, 
+			["account_currency", "account_type"])
+		
+		bank_account_currency, bank_account_type = None, None
+		if self.payment_account:
+			bank_account_currency, bank_account_type = frappe.db.get_value("Account", self.payment_account, 
+				["account_currency", "account_type"])
+		
 		if not self.total_payment_amount:
 			frappe.throw(_("Please enter Payment Amount in atleast one row"))
 
@@ -27,27 +36,56 @@
 			if not frappe.db.get_value(v.against_voucher_type, {"name": v.against_voucher_no}):
 				frappe.throw(_("Row {0}: {1} is not a valid {2}").format(v.idx, v.against_voucher_no,
 					v.against_voucher_type))
-
+			
 			if v.payment_amount:
+				exchange_rate = get_exchange_rate(self.party_account, party_account_currency,
+					self.company, v.against_voucher_type, v.against_voucher_no)
+				
 				d1 = jv.append("accounts")
 				d1.account = self.party_account
 				d1.party_type = self.party_type
 				d1.party = self.party
+				d1.account_currency = party_account_currency
+				d1.account_type = party_account_type
 				d1.balance = get_balance_on(self.party_account)
+				d1.party_balance = get_balance_on(party=self.party, party_type=self.party_type)
+				d1.exchange_rate = exchange_rate
 				d1.set("debit_in_account_currency" if self.received_or_paid=="Paid" \
 					else "credit_in_account_currency", flt(v.payment_amount))
-				d1.set("reference_type", v.against_voucher_type)
-				d1.set("reference_name", v.against_voucher_no)
-				d1.set('is_advance', 'Yes' if v.against_voucher_type in ['Sales Order', 'Purchase Order'] else 'No')
-				total_payment_amount = flt(total_payment_amount) + \
-					flt(d1.debit_in_account_currency) - flt(d1.credit_in_account_currency)
+				d1.reference_type = v.against_voucher_type
+				d1.reference_name = v.against_voucher_no
+				d1.is_advance = 'Yes' \
+					if v.against_voucher_type in ['Sales Order', 'Purchase Order'] else 'No'
+					
+				amount = flt(d1.debit_in_account_currency) - flt(d1.credit_in_account_currency)
+				if bank_account_currency == party_account_currency:
+					total_payment_amount += amount
+				else:
+					total_payment_amount += amount*exchange_rate
 
 		d2 = jv.append("accounts")
-		d2.account = self.payment_account
-		d2.set('debit_in_account_currency' if total_payment_amount < 0 \
-			else 'credit_in_account_currency', abs(total_payment_amount))
 		if self.payment_account:
-			d2.balance = get_balance_on(self.payment_account)
+			bank_account_currency, bank_account_type = frappe.db.get_value("Account", self.payment_account, 
+				["account_currency", "account_type"])
+				
+			d2.account = self.payment_account
+			d2.account_currency = bank_account_currency
+			d2.account_type = bank_account_type
+			d2.exchange_rate = get_exchange_rate(self.payment_account, self.company)
+			d2.account_balance = get_balance_on(self.payment_account)
+		
+		amount_field_bank = 'debit_in_account_currency' if total_payment_amount < 0 \
+			else 'credit_in_account_currency'
+		
+		d2.set(amount_field_bank, abs(total_payment_amount))
+		
+		company_currency = frappe.db.get_value("Company", self.company, "default_currency")
+		if party_account_currency != company_currency or \
+			(bank_account_currency and bank_account_currency != company_currency):
+				jv.multi_currency = 1
+			
+		jv.set_amounts_in_company_currency()
+		jv.set_total_debit_credit()
 
 		return jv.as_dict()