test: currency inheritance on child accounts
This commit is contained in:
parent
abe691c03d
commit
f6ea8fd8d7
@ -5,10 +5,13 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.test_runner import make_test_records
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.account import merge_account, update_account_number
|
from erpnext.accounts.doctype.account.account import merge_account, update_account_number
|
||||||
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account
|
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account
|
||||||
|
|
||||||
|
test_dependencies = ["Company"]
|
||||||
|
|
||||||
|
|
||||||
class TestAccount(unittest.TestCase):
|
class TestAccount(unittest.TestCase):
|
||||||
def test_rename_account(self):
|
def test_rename_account(self):
|
||||||
@ -188,6 +191,58 @@ class TestAccount(unittest.TestCase):
|
|||||||
frappe.delete_doc("Account", "1234 - Test Rename Sync Account - _TC4")
|
frappe.delete_doc("Account", "1234 - Test Rename Sync Account - _TC4")
|
||||||
frappe.delete_doc("Account", "1234 - Test Rename Sync Account - _TC5")
|
frappe.delete_doc("Account", "1234 - Test Rename Sync Account - _TC5")
|
||||||
|
|
||||||
|
def test_account_currency_sync(self):
|
||||||
|
"""
|
||||||
|
In a parent->child company setup, child should inherit parent account currency if explicitly specified.
|
||||||
|
"""
|
||||||
|
|
||||||
|
make_test_records("Company")
|
||||||
|
|
||||||
|
frappe.local.flags.pop("ignore_root_company_validation", None)
|
||||||
|
|
||||||
|
def create_bank_account():
|
||||||
|
acc = frappe.new_doc("Account")
|
||||||
|
acc.account_name = "_Test Bank JPY"
|
||||||
|
|
||||||
|
acc.parent_account = "Temporary Accounts - _TC6"
|
||||||
|
acc.company = "_Test Company 6"
|
||||||
|
return acc
|
||||||
|
|
||||||
|
acc = create_bank_account()
|
||||||
|
# Explicitly set currency
|
||||||
|
acc.account_currency = "JPY"
|
||||||
|
acc.insert()
|
||||||
|
self.assertTrue(
|
||||||
|
frappe.db.exists(
|
||||||
|
{
|
||||||
|
"doctype": "Account",
|
||||||
|
"account_name": "_Test Bank JPY",
|
||||||
|
"account_currency": "JPY",
|
||||||
|
"company": "_Test Company 7",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.delete_doc("Account", "_Test Bank JPY - _TC6")
|
||||||
|
frappe.delete_doc("Account", "_Test Bank JPY - _TC7")
|
||||||
|
|
||||||
|
acc = create_bank_account()
|
||||||
|
# default currency is used
|
||||||
|
acc.insert()
|
||||||
|
self.assertTrue(
|
||||||
|
frappe.db.exists(
|
||||||
|
{
|
||||||
|
"doctype": "Account",
|
||||||
|
"account_name": "_Test Bank JPY",
|
||||||
|
"account_currency": "USD",
|
||||||
|
"company": "_Test Company 7",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.delete_doc("Account", "_Test Bank JPY - _TC6")
|
||||||
|
frappe.delete_doc("Account", "_Test Bank JPY - _TC7")
|
||||||
|
|
||||||
def test_child_company_account_rename_sync(self):
|
def test_child_company_account_rename_sync(self):
|
||||||
frappe.local.flags.pop("ignore_root_company_validation", None)
|
frappe.local.flags.pop("ignore_root_company_validation", None)
|
||||||
|
|
||||||
|
@ -80,5 +80,30 @@
|
|||||||
"chart_of_accounts": "Standard",
|
"chart_of_accounts": "Standard",
|
||||||
"enable_perpetual_inventory": 1,
|
"enable_perpetual_inventory": 1,
|
||||||
"default_holiday_list": "_Test Holiday List"
|
"default_holiday_list": "_Test Holiday List"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"abbr": "_TC6",
|
||||||
|
"company_name": "_Test Company 6",
|
||||||
|
"is_group": 1,
|
||||||
|
"country": "India",
|
||||||
|
"default_currency": "INR",
|
||||||
|
"doctype": "Company",
|
||||||
|
"domain": "Manufacturing",
|
||||||
|
"chart_of_accounts": "Standard",
|
||||||
|
"default_holiday_list": "_Test Holiday List",
|
||||||
|
"enable_perpetual_inventory": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"abbr": "_TC7",
|
||||||
|
"company_name": "_Test Company 7",
|
||||||
|
"parent_company": "_Test Company 6",
|
||||||
|
"is_group": 1,
|
||||||
|
"country": "United States",
|
||||||
|
"default_currency": "USD",
|
||||||
|
"doctype": "Company",
|
||||||
|
"domain": "Manufacturing",
|
||||||
|
"chart_of_accounts": "Standard",
|
||||||
|
"default_holiday_list": "_Test Holiday List",
|
||||||
|
"enable_perpetual_inventory": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user