mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-19 23:05:12 +00:00
fix: do not validate if conversion rate is 1 for different currency
(cherry picked from commit e8a66d03bc)
# Conflicts:
# erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
This commit is contained in:
@@ -1773,16 +1773,60 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
|
|
||||||
self.assertTrue(gle)
|
self.assertTrue(gle)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
def test_invoice_exchange_rate(self):
|
def test_invoice_exchange_rate(self):
|
||||||
|
=======
|
||||||
|
def test_gle_in_transaction_currency(self):
|
||||||
|
# create multi currency sales invoice with 2 items with same income account
|
||||||
|
>>>>>>> e8a66d03bc (fix: do not validate if conversion rate is 1 for different currency)
|
||||||
si = create_sales_invoice(
|
si = create_sales_invoice(
|
||||||
customer="_Test Customer USD",
|
customer="_Test Customer USD",
|
||||||
debit_to="_Test Receivable USD - _TC",
|
debit_to="_Test Receivable USD - _TC",
|
||||||
currency="USD",
|
currency="USD",
|
||||||
|
<<<<<<< HEAD
|
||||||
conversion_rate=1,
|
conversion_rate=1,
|
||||||
do_not_save=1,
|
do_not_save=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, si.save)
|
self.assertRaises(frappe.ValidationError, si.save)
|
||||||
|
=======
|
||||||
|
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])
|
||||||
|
>>>>>>> e8a66d03bc (fix: do not validate if conversion rate is 1 for different currency)
|
||||||
|
|
||||||
def test_invalid_currency(self):
|
def test_invalid_currency(self):
|
||||||
# Customer currency = USD
|
# Customer currency = USD
|
||||||
|
|||||||
@@ -2459,12 +2459,17 @@ class AccountsController(TransactionBase):
|
|||||||
default_currency = erpnext.get_company_currency(self.company)
|
default_currency = erpnext.get_company_currency(self.company)
|
||||||
if not default_currency:
|
if not default_currency:
|
||||||
throw(_("Please enter default currency in Company Master"))
|
throw(_("Please enter default currency in Company Master"))
|
||||||
if (
|
|
||||||
(self.currency == default_currency and flt(self.conversion_rate) != 1.00)
|
if not self.conversion_rate:
|
||||||
or not self.conversion_rate
|
throw(_("Conversion rate cannot be 0"))
|
||||||
or (self.currency != default_currency and flt(self.conversion_rate) == 1.00)
|
|
||||||
):
|
if self.currency == default_currency and flt(self.conversion_rate) != 1.00:
|
||||||
throw(_("Conversion rate cannot be 0 or 1"))
|
throw(_("Conversion rate must be 1.00 if document currency is same as company currency"))
|
||||||
|
|
||||||
|
if self.currency != default_currency and flt(self.conversion_rate) == 1.00:
|
||||||
|
frappe.msgprint(
|
||||||
|
_("Conversion rate is 1.00, but document currency is different from company currency")
|
||||||
|
)
|
||||||
|
|
||||||
def check_finance_books(self, item, asset):
|
def check_finance_books(self, item, asset):
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user