mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-24 17:18:30 +00:00
fix: Merge debit and credit in transaction currency while merging gle with similar head
(cherry picked from commit e43697d359)
This commit is contained in:
@@ -1766,6 +1766,49 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
|
|
||||||
self.assertTrue(gle)
|
self.assertTrue(gle)
|
||||||
|
|
||||||
|
def test_gle_in_transaction_currency(self):
|
||||||
|
# create multi currency sales invoice with 2 items with same income account
|
||||||
|
si = create_sales_invoice(
|
||||||
|
customer="_Test Customer USD",
|
||||||
|
debit_to="_Test Receivable USD - _TC",
|
||||||
|
currency="USD",
|
||||||
|
conversion_rate=50,
|
||||||
|
do_not_submit=True,
|
||||||
|
)
|
||||||
|
# add 2nd item with same income account
|
||||||
|
si.append(
|
||||||
|
"items",
|
||||||
|
{
|
||||||
|
"item_code": "_Test Item",
|
||||||
|
"qty": 1,
|
||||||
|
"rate": 80,
|
||||||
|
"income_account": "Sales - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
gl_entries = frappe.db.sql(
|
||||||
|
"""select transaction_currency, transaction_exchange_rate,
|
||||||
|
debit_in_transaction_currency, credit_in_transaction_currency
|
||||||
|
from `tabGL Entry`
|
||||||
|
where voucher_type='Sales Invoice' and voucher_no=%s and account = 'Sales - _TC'
|
||||||
|
order by account asc""",
|
||||||
|
si.name,
|
||||||
|
as_dict=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
expected_gle = {
|
||||||
|
"transaction_currency": "USD",
|
||||||
|
"transaction_exchange_rate": 50,
|
||||||
|
"debit_in_transaction_currency": 0,
|
||||||
|
"credit_in_transaction_currency": 180,
|
||||||
|
}
|
||||||
|
|
||||||
|
for gle in gl_entries:
|
||||||
|
for field in expected_gle:
|
||||||
|
self.assertEqual(expected_gle[field], gle[field])
|
||||||
|
|
||||||
def test_invoice_exchange_rate(self):
|
def test_invoice_exchange_rate(self):
|
||||||
si = create_sales_invoice(
|
si = create_sales_invoice(
|
||||||
customer="_Test Customer USD",
|
customer="_Test Customer USD",
|
||||||
|
|||||||
@@ -238,10 +238,16 @@ def merge_similar_entries(gl_map, precision=None):
|
|||||||
same_head.debit_in_account_currency = flt(same_head.debit_in_account_currency) + flt(
|
same_head.debit_in_account_currency = flt(same_head.debit_in_account_currency) + flt(
|
||||||
entry.debit_in_account_currency
|
entry.debit_in_account_currency
|
||||||
)
|
)
|
||||||
|
same_head.debit_in_transaction_currency = flt(same_head.debit_in_transaction_currency) + flt(
|
||||||
|
entry.debit_in_transaction_currency
|
||||||
|
)
|
||||||
same_head.credit = flt(same_head.credit) + flt(entry.credit)
|
same_head.credit = flt(same_head.credit) + flt(entry.credit)
|
||||||
same_head.credit_in_account_currency = flt(same_head.credit_in_account_currency) + flt(
|
same_head.credit_in_account_currency = flt(same_head.credit_in_account_currency) + flt(
|
||||||
entry.credit_in_account_currency
|
entry.credit_in_account_currency
|
||||||
)
|
)
|
||||||
|
same_head.credit_in_transaction_currency = flt(same_head.credit_in_transaction_currency) + flt(
|
||||||
|
entry.credit_in_transaction_currency
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
merged_gl_map.append(entry)
|
merged_gl_map.append(entry)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user