From 5da941b82c2492825a2a482e8dcf66b67d3892a6 Mon Sep 17 00:00:00 2001
From: Revant Nandgaonkar <revant@users.noreply.github.com>
Date: Thu, 18 Feb 2016 16:02:05 +0530
Subject: [PATCH 1/2] Need to use set_balance_in_account_currency

https://github.com/revant/drop_ship/commit/b9ad5178e4f75a73be9f7b36a1b3d691c8937746
needed to make GL Entry
---
 erpnext/controllers/accounts_controller.py | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 9916613875..6a8c8aab26 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -252,23 +252,6 @@ class AccountsController(TransactionBase):
 			frappe.throw(_("Account {0} is invalid. Account Currency must be {1}")
 				.format(account, _(" or ").join(valid_currency)))
 
-	def set_balance_in_account_currency(self, gl_dict, account_currency=None):
-		if (not self.get("conversion_rate") and account_currency!=self.company_currency):
-				frappe.throw(_("Account: {0} with currency: {1} can not be selected")
-					.format(gl_dict.account, account_currency))
-
-		gl_dict["account_currency"] = self.company_currency if account_currency==self.company_currency \
-			else account_currency
-
-		# set debit/credit in account currency if not provided
-		if flt(gl_dict.debit) and not flt(gl_dict.debit_in_account_currency):
-			gl_dict.debit_in_account_currency = gl_dict.debit if account_currency==self.company_currency \
-				else flt(gl_dict.debit / (self.get("conversion_rate")), 2)
-
-		if flt(gl_dict.credit) and not flt(gl_dict.credit_in_account_currency):
-			gl_dict.credit_in_account_currency = gl_dict.credit if account_currency==self.company_currency \
-				else flt(gl_dict.credit / (self.get("conversion_rate")), 2)
-
 	def clear_unallocated_advances(self, childtype, parentfield):
 		self.set(parentfield, self.get(parentfield, {"allocated_amount": ["not in", [0, None, ""]]}))
 
@@ -541,3 +524,20 @@ def validate_inclusive_tax(tax, doc):
 			_on_previous_row_error("1 - %d" % (tax.row_id,))
 		elif tax.get("category") == "Valuation":
 			frappe.throw(_("Valuation type charges can not marked as Inclusive"))
+
+def set_balance_in_account_currency(gl_dict, conversion_rate=None, company_currency=None, account_currency=None):
+	if (not conversion_rate) and (account_currency!=company_currency):
+			frappe.throw(_("Account: {0} with currency: {1} can not be selected")
+				.format(gl_dict.account, account_currency))
+
+	gl_dict["account_currency"] = company_currency if account_currency==company_currency \
+		else account_currency
+
+	# set debit/credit in account currency if not provided
+	if flt(gl_dict.debit) and not flt(gl_dict.debit_in_account_currency):
+		gl_dict.debit_in_account_currency = gl_dict.debit if account_currency==company_currency \
+			else flt(gl_dict.debit / conversion_rate, 2)
+
+	if flt(gl_dict.credit) and not flt(gl_dict.credit_in_account_currency):
+		gl_dict.credit_in_account_currency = gl_dict.credit if account_currency==company_currency \
+			else flt(gl_dict.credit / conversion_rate, 2)

From 78a62fe1237732571023c76e4dfe3dce76b9619a Mon Sep 17 00:00:00 2001
From: Revant Nandgaonkar <revant@users.noreply.github.com>
Date: Thu, 18 Feb 2016 16:48:35 +0530
Subject: [PATCH 2/2] change args of set_balance_in_account_currency

https://github.com/frappe/erpnext/pull/4832
---
 erpnext/controllers/accounts_controller.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 6a8c8aab26..e27c55ac45 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -239,7 +239,7 @@ class AccountsController(TransactionBase):
 
 		if self.doctype not in ["Journal Entry", "Period Closing Voucher"]:
 			self.validate_account_currency(gl_dict.account, account_currency)
-			self.set_balance_in_account_currency(gl_dict, account_currency)
+			set_balance_in_account_currency(gl_dict, account_currency, self.conversion_rate, self.company_currency)
 
 		return gl_dict
 
@@ -525,7 +525,7 @@ def validate_inclusive_tax(tax, doc):
 		elif tax.get("category") == "Valuation":
 			frappe.throw(_("Valuation type charges can not marked as Inclusive"))
 
-def set_balance_in_account_currency(gl_dict, conversion_rate=None, company_currency=None, account_currency=None):
+def set_balance_in_account_currency(gl_dict, account_currency=None, conversion_rate=None, company_currency=None):
 	if (not conversion_rate) and (account_currency!=company_currency):
 			frappe.throw(_("Account: {0} with currency: {1} can not be selected")
 				.format(gl_dict.account, account_currency))
