mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 04:15:10 +00:00
fix: show amount for exchange gain or loss account
(cherry picked from commit 4f90f50eb2)
This commit is contained in:
@@ -204,7 +204,7 @@ def get_gl_entries(filters, accounting_dimensions):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if filters.get("presentation_currency"):
|
if filters.get("presentation_currency"):
|
||||||
return convert_to_presentation_currency(gl_entries, currency_map)
|
return convert_to_presentation_currency(gl_entries, currency_map, filters)
|
||||||
else:
|
else:
|
||||||
return gl_entries
|
return gl_entries
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ def get_rate_as_at(date, from_currency, to_currency):
|
|||||||
return rate
|
return rate
|
||||||
|
|
||||||
|
|
||||||
def convert_to_presentation_currency(gl_entries, currency_info):
|
def convert_to_presentation_currency(gl_entries, currency_info, filters=None):
|
||||||
"""
|
"""
|
||||||
Take a list of GL Entries and change the 'debit' and 'credit' values to currencies
|
Take a list of GL Entries and change the 'debit' and 'credit' values to currencies
|
||||||
in `currency_info`.
|
in `currency_info`.
|
||||||
@@ -99,6 +99,13 @@ def convert_to_presentation_currency(gl_entries, currency_info):
|
|||||||
company_currency = currency_info["company_currency"]
|
company_currency = currency_info["company_currency"]
|
||||||
|
|
||||||
account_currencies = list(set(entry["account_currency"] for entry in gl_entries))
|
account_currencies = list(set(entry["account_currency"] for entry in gl_entries))
|
||||||
|
exchange_gain_or_loss = False
|
||||||
|
|
||||||
|
if filters:
|
||||||
|
account_filter = filters.get("account")
|
||||||
|
gain_loss_account = frappe.db.get_value("Company", filters.company, "exchange_gain_loss_account")
|
||||||
|
|
||||||
|
exchange_gain_or_loss = len(account_filter) == 1 and account_filter[0] == gain_loss_account
|
||||||
|
|
||||||
for entry in gl_entries:
|
for entry in gl_entries:
|
||||||
debit = flt(entry["debit"])
|
debit = flt(entry["debit"])
|
||||||
@@ -107,7 +114,11 @@ def convert_to_presentation_currency(gl_entries, currency_info):
|
|||||||
credit_in_account_currency = flt(entry["credit_in_account_currency"])
|
credit_in_account_currency = flt(entry["credit_in_account_currency"])
|
||||||
account_currency = entry["account_currency"]
|
account_currency = entry["account_currency"]
|
||||||
|
|
||||||
if len(account_currencies) == 1 and account_currency == presentation_currency:
|
if (
|
||||||
|
len(account_currencies) == 1
|
||||||
|
and account_currency == presentation_currency
|
||||||
|
and not exchange_gain_or_loss
|
||||||
|
):
|
||||||
entry["debit"] = debit_in_account_currency
|
entry["debit"] = debit_in_account_currency
|
||||||
entry["credit"] = credit_in_account_currency
|
entry["credit"] = credit_in_account_currency
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user