Merge pull request #4832 from revant/patch-1
Need to use set_balance_in_account_currency
This commit is contained in:
commit
7209cff29a
@ -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
|
||||
|
||||
@ -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, 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))
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user