[fix] Journal Entry: init debit/credit in account currency
This commit is contained in:
parent
e1a1c8ac31
commit
c07489a096
@ -298,8 +298,11 @@ class JournalEntry(AccountsController):
|
||||
|
||||
def set_amounts_in_company_currency(self):
|
||||
for d in self.get("accounts"):
|
||||
d.debit = flt(flt(d.debit_in_account_currency)*flt(d.exchange_rate), d.precision("debit"))
|
||||
d.credit = flt(flt(d.credit_in_account_currency)*flt(d.exchange_rate), d.precision("credit"))
|
||||
d.debit_in_account_currency = flt(d.debit_in_account_currency, d.precision("debit_in_account_currency"))
|
||||
d.credit_in_account_currency = flt(d.credit_in_account_currency, d.precision("credit_in_account_currency"))
|
||||
|
||||
d.debit = flt(d.debit_in_account_currency * flt(d.exchange_rate), d.precision("debit"))
|
||||
d.credit = flt(d.credit_in_account_currency * flt(d.exchange_rate), d.precision("credit"))
|
||||
|
||||
def set_exchange_rate(self):
|
||||
for d in self.get("accounts"):
|
||||
@ -361,10 +364,10 @@ class JournalEntry(AccountsController):
|
||||
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
|
||||
|
||||
|
||||
if not self.pay_to_recd_from:
|
||||
total_amount = 0
|
||||
|
||||
|
||||
self.set_total_amount(total_amount, bank_account_currency)
|
||||
|
||||
def set_total_amount(self, amt, currency):
|
||||
@ -526,7 +529,7 @@ def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None, a
|
||||
if not account:
|
||||
account = frappe.db.get_value("Account",
|
||||
{"company": company, "account_type": "Bank", "is_group": 0})
|
||||
|
||||
|
||||
elif voucher_type=="Cash Entry":
|
||||
account = frappe.db.get_value("Company", company, "default_cash_account")
|
||||
if not account:
|
||||
@ -645,7 +648,7 @@ def get_payment_entry(ref_doc, args):
|
||||
})
|
||||
|
||||
bank_row = je.append("accounts")
|
||||
|
||||
|
||||
#make it bank_details
|
||||
bank_account = get_default_bank_cash_account(ref_doc.company, "Bank Entry", account=args.get("bank_account"))
|
||||
if bank_account:
|
||||
@ -667,7 +670,7 @@ def get_payment_entry(ref_doc, args):
|
||||
|
||||
je.set_amounts_in_company_currency()
|
||||
je.set_total_debit_credit()
|
||||
|
||||
|
||||
return je if args.get("journal_entry") else je.as_dict()
|
||||
|
||||
@frappe.whitelist()
|
||||
|
Loading…
Reference in New Issue
Block a user