rounding off fixes and conversion fix (#15140)
This commit is contained in:
parent
338dfcfb63
commit
3523b779aa
@ -865,7 +865,7 @@ class SalesInvoice(SellingController):
|
||||
self.get_gl_dict({
|
||||
"account": round_off_account,
|
||||
"against": self.customer,
|
||||
"credit_in_account_currency": self.rounding_adjustment,
|
||||
"credit_in_account_currency": self.base_rounding_adjustment,
|
||||
"credit": self.base_rounding_adjustment,
|
||||
"cost_center": round_off_cost_center,
|
||||
}
|
||||
|
@ -139,11 +139,21 @@ def round_off_debit_credit(gl_map):
|
||||
|
||||
def make_round_off_gle(gl_map, debit_credit_diff):
|
||||
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(gl_map[0].company)
|
||||
|
||||
round_off_account_exists = False
|
||||
round_off_gle = frappe._dict()
|
||||
for k in ["voucher_type", "voucher_no", "company",
|
||||
"posting_date", "remarks", "is_opening"]:
|
||||
round_off_gle[k] = gl_map[0][k]
|
||||
for d in gl_map:
|
||||
if d.account == round_off_account:
|
||||
round_off_gle = d
|
||||
if d.debit_in_account_currency:
|
||||
debit_credit_diff -= flt(d.debit_in_account_currency)
|
||||
else:
|
||||
debit_credit_diff += flt(d.credit_in_account_currency)
|
||||
round_off_account_exists = True
|
||||
|
||||
if not round_off_gle:
|
||||
for k in ["voucher_type", "voucher_no", "company",
|
||||
"posting_date", "remarks", "is_opening"]:
|
||||
round_off_gle[k] = gl_map[0][k]
|
||||
|
||||
round_off_gle.update({
|
||||
"account": round_off_account,
|
||||
@ -158,7 +168,8 @@ def make_round_off_gle(gl_map, debit_credit_diff):
|
||||
"against_voucher": None
|
||||
})
|
||||
|
||||
gl_map.append(round_off_gle)
|
||||
if not round_off_account_exists:
|
||||
gl_map.append(round_off_gle)
|
||||
|
||||
def get_round_off_account_and_cost_center(company):
|
||||
round_off_account, round_off_cost_center = frappe.get_cached_value('Company', company,
|
||||
|
@ -89,12 +89,11 @@ def set_account_currency(filters):
|
||||
account_currency = gle_currency
|
||||
else:
|
||||
account_currency = (None if filters.party_type in ["Employee", "Student", "Shareholder", "Member"] else
|
||||
frappe.db.get_value(filters.party_type, filters.party, "default_currency"))
|
||||
frappe.db.get_value(filters.party_type, filters.party[0], "default_currency"))
|
||||
|
||||
filters["account_currency"] = account_currency or filters.company_currency
|
||||
|
||||
if filters.account_currency != filters.company_currency:
|
||||
filters["show_in_account_currency"] = 1
|
||||
filters.presentation_currency = filters.account_currency
|
||||
|
||||
return filters
|
||||
|
||||
@ -294,15 +293,6 @@ def get_result_as_list(data, filters):
|
||||
balance = get_balance(d, balance, 'debit', 'credit')
|
||||
d['balance'] = balance
|
||||
|
||||
if filters.get("show_in_account_currency"):
|
||||
balance_in_account_currency = get_balance(d, balance_in_account_currency,
|
||||
'debit_in_account_currency', 'credit_in_account_currency')
|
||||
d['balance_in_account_currency'] = balance_in_account_currency
|
||||
else:
|
||||
d['debit_in_account_currency'] = d.get('debit', 0)
|
||||
d['credit_in_account_currency'] = d.get('credit', 0)
|
||||
d['balance_in_account_currency'] = d.get('balance')
|
||||
|
||||
d['account_currency'] = filters.account_currency
|
||||
d['bill_no'] = inv_details.get(d.get('against_voucher'), '')
|
||||
|
||||
|
@ -2,7 +2,7 @@ import frappe
|
||||
from erpnext import get_company_currency, get_default_company
|
||||
from erpnext.setup.utils import get_exchange_rate
|
||||
from erpnext.accounts.doctype.fiscal_year.fiscal_year import get_from_and_to_date
|
||||
from frappe.utils import cint, get_datetime_str, formatdate
|
||||
from frappe.utils import cint, get_datetime_str, formatdate, flt
|
||||
|
||||
__exchange_rates = {}
|
||||
P_OR_L_ACCOUNTS = list(
|
||||
@ -49,7 +49,7 @@ def convert(value, from_, to, date):
|
||||
:return: Result of converting `value`
|
||||
"""
|
||||
rate = get_rate_as_at(date, from_, to)
|
||||
converted_value = value / (rate or 1)
|
||||
converted_value = flt(value) / (rate or 1)
|
||||
return converted_value
|
||||
|
||||
|
||||
@ -97,17 +97,16 @@ def convert_to_presentation_currency(gl_entries, currency_info):
|
||||
|
||||
for entry in gl_entries:
|
||||
account = entry['account']
|
||||
debit = cint(entry['debit'])
|
||||
credit = cint(entry['credit'])
|
||||
debit_in_account_currency = cint(entry['debit_in_account_currency'])
|
||||
credit_in_account_currency = cint(entry['credit_in_account_currency'])
|
||||
debit = flt(entry['debit'])
|
||||
credit = flt(entry['credit'])
|
||||
debit_in_account_currency = flt(entry['debit_in_account_currency'])
|
||||
credit_in_account_currency = flt(entry['credit_in_account_currency'])
|
||||
account_currency = entry['account_currency']
|
||||
|
||||
if account_currency != presentation_currency or (account_currency == presentation_currency and not is_p_or_l_account(account)):
|
||||
value = debit or credit
|
||||
|
||||
date = currency_info['report_date'] if not is_p_or_l_account(account) else entry['posting_date']
|
||||
|
||||
converted_value = convert(value, presentation_currency, company_currency, date)
|
||||
|
||||
if entry.get('debit'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user