mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 13:49:13 +00:00
style: format code with black
This commit is contained in:
@@ -9,7 +9,6 @@ from erpnext.accounts.report.general_ledger.general_ledger import execute
|
||||
|
||||
|
||||
class TestGeneralLedger(FrappeTestCase):
|
||||
|
||||
def test_foreign_account_balance_after_exchange_rate_revaluation(self):
|
||||
"""
|
||||
Checks the correctness of balance after exchange rate revaluation
|
||||
@@ -17,18 +16,20 @@ class TestGeneralLedger(FrappeTestCase):
|
||||
# create a new account with USD currency
|
||||
account_name = "Test USD Account for Revalutation"
|
||||
company = "_Test Company"
|
||||
account = frappe.get_doc({
|
||||
"account_name": account_name,
|
||||
"is_group": 0,
|
||||
"company": company,
|
||||
"root_type": "Asset",
|
||||
"report_type": "Balance Sheet",
|
||||
"account_currency": "USD",
|
||||
"inter_company_account": 0,
|
||||
"parent_account": "Bank Accounts - _TC",
|
||||
"account_type": "Bank",
|
||||
"doctype": "Account"
|
||||
})
|
||||
account = frappe.get_doc(
|
||||
{
|
||||
"account_name": account_name,
|
||||
"is_group": 0,
|
||||
"company": company,
|
||||
"root_type": "Asset",
|
||||
"report_type": "Balance Sheet",
|
||||
"account_currency": "USD",
|
||||
"inter_company_account": 0,
|
||||
"parent_account": "Bank Accounts - _TC",
|
||||
"account_type": "Bank",
|
||||
"doctype": "Account",
|
||||
}
|
||||
)
|
||||
account.insert(ignore_if_duplicate=True)
|
||||
# create a JV to debit 1000 USD at 75 exchange rate
|
||||
jv = frappe.new_doc("Journal Entry")
|
||||
@@ -36,21 +37,24 @@ class TestGeneralLedger(FrappeTestCase):
|
||||
jv.company = company
|
||||
jv.multi_currency = 1
|
||||
jv.cost_center = "_Test Cost Center - _TC"
|
||||
jv.set("accounts", [
|
||||
{
|
||||
"account": account.name,
|
||||
"debit_in_account_currency": 1000,
|
||||
"credit_in_account_currency": 0,
|
||||
"exchange_rate": 75,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
{
|
||||
"account": "Cash - _TC",
|
||||
"debit_in_account_currency": 0,
|
||||
"credit_in_account_currency": 75000,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
])
|
||||
jv.set(
|
||||
"accounts",
|
||||
[
|
||||
{
|
||||
"account": account.name,
|
||||
"debit_in_account_currency": 1000,
|
||||
"credit_in_account_currency": 0,
|
||||
"exchange_rate": 75,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
{
|
||||
"account": "Cash - _TC",
|
||||
"debit_in_account_currency": 0,
|
||||
"credit_in_account_currency": 75000,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
],
|
||||
)
|
||||
jv.save()
|
||||
jv.submit()
|
||||
# create a JV to credit 900 USD at 100 exchange rate
|
||||
@@ -59,21 +63,24 @@ class TestGeneralLedger(FrappeTestCase):
|
||||
jv.company = company
|
||||
jv.multi_currency = 1
|
||||
jv.cost_center = "_Test Cost Center - _TC"
|
||||
jv.set("accounts", [
|
||||
{
|
||||
"account": account.name,
|
||||
"debit_in_account_currency": 0,
|
||||
"credit_in_account_currency": 900,
|
||||
"exchange_rate": 100,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
{
|
||||
"account": "Cash - _TC",
|
||||
"debit_in_account_currency": 90000,
|
||||
"credit_in_account_currency": 0,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
])
|
||||
jv.set(
|
||||
"accounts",
|
||||
[
|
||||
{
|
||||
"account": account.name,
|
||||
"debit_in_account_currency": 0,
|
||||
"credit_in_account_currency": 900,
|
||||
"exchange_rate": 100,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
{
|
||||
"account": "Cash - _TC",
|
||||
"debit_in_account_currency": 90000,
|
||||
"credit_in_account_currency": 0,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
},
|
||||
],
|
||||
)
|
||||
jv.save()
|
||||
jv.submit()
|
||||
|
||||
@@ -81,22 +88,27 @@ class TestGeneralLedger(FrappeTestCase):
|
||||
revaluation = frappe.new_doc("Exchange Rate Revaluation")
|
||||
revaluation.posting_date = today()
|
||||
revaluation.company = company
|
||||
revaluation.set("accounts", [
|
||||
{
|
||||
"account": account.name,
|
||||
"account_currency": "USD",
|
||||
"new_exchange_rate": 77,
|
||||
"new_balance_in_base_currency": 7700,
|
||||
"balance_in_base_currency": -15000,
|
||||
"balance_in_account_currency": 100,
|
||||
"current_exchange_rate": -150
|
||||
}
|
||||
])
|
||||
revaluation.set(
|
||||
"accounts",
|
||||
[
|
||||
{
|
||||
"account": account.name,
|
||||
"account_currency": "USD",
|
||||
"new_exchange_rate": 77,
|
||||
"new_balance_in_base_currency": 7700,
|
||||
"balance_in_base_currency": -15000,
|
||||
"balance_in_account_currency": 100,
|
||||
"current_exchange_rate": -150,
|
||||
}
|
||||
],
|
||||
)
|
||||
revaluation.save()
|
||||
revaluation.submit()
|
||||
|
||||
# post journal entry to revaluate
|
||||
frappe.db.set_value('Company', company, "unrealized_exchange_gain_loss_account", "_Test Exchange Gain/Loss - _TC")
|
||||
frappe.db.set_value(
|
||||
"Company", company, "unrealized_exchange_gain_loss_account", "_Test Exchange Gain/Loss - _TC"
|
||||
)
|
||||
revaluation_jv = revaluation.make_jv_entry()
|
||||
revaluation_jv = frappe.get_doc(revaluation_jv)
|
||||
revaluation_jv.cost_center = "_Test Cost Center - _TC"
|
||||
@@ -112,18 +124,24 @@ class TestGeneralLedger(FrappeTestCase):
|
||||
from `tabGL Entry`
|
||||
where account = %s
|
||||
group by account
|
||||
""", account.name)
|
||||
""",
|
||||
account.name,
|
||||
)
|
||||
|
||||
self.assertEqual(balance[0][0], 100)
|
||||
|
||||
# check if general ledger shows correct balance
|
||||
columns, data = execute(frappe._dict({
|
||||
"company": company,
|
||||
"from_date": today(),
|
||||
"to_date": today(),
|
||||
"account": [account.name],
|
||||
"group_by": "Group by Voucher (Consolidated)",
|
||||
}))
|
||||
columns, data = execute(
|
||||
frappe._dict(
|
||||
{
|
||||
"company": company,
|
||||
"from_date": today(),
|
||||
"to_date": today(),
|
||||
"account": [account.name],
|
||||
"group_by": "Group by Voucher (Consolidated)",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(data[1]["account"], account.name)
|
||||
self.assertEqual(data[1]["debit"], 1000)
|
||||
@@ -131,4 +149,4 @@ class TestGeneralLedger(FrappeTestCase):
|
||||
self.assertEqual(data[2]["debit"], 0)
|
||||
self.assertEqual(data[2]["credit"], 900)
|
||||
self.assertEqual(data[3]["debit"], 100)
|
||||
self.assertEqual(data[3]["credit"], 100)
|
||||
self.assertEqual(data[3]["credit"], 100)
|
||||
|
||||
Reference in New Issue
Block a user