test(Item): test_item_defaults

This commit is contained in:
Saif Ur Rehman 2019-02-02 02:43:44 +05:00
parent c8b61007b0
commit 00aaa48779
3 changed files with 68 additions and 0 deletions

View File

@ -129,6 +129,8 @@ def _make_test_records(verbose):
["_Test Write Off", "Indirect Expenses", 0, None, None],
["_Test Exchange Gain/Loss", "Indirect Expenses", 0, None, None],
["_Test Account Sales", "Direct Income", 0, None, None],
# related to Account Inventory Integration
["_Test Account Stock In Hand", "Current Assets", 0, None, None],

View File

@ -2,5 +2,16 @@
{
"brand": "_Test Brand",
"doctype": "Brand"
},
{
"brand": "_Test Brand With Item Defaults",
"doctype": "Brand",
"brand_defaults": [{
"company": "_Test Company",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"income_account": "_Test Account Sales - _TC",
"buying_cost_center": "_Test Cost Center - _TC",
"selling_cost_center": "_Test Cost Center - _TC"
}]
}
]

View File

@ -102,6 +102,61 @@ class TestItem(unittest.TestCase):
for key, value in iteritems(to_check):
self.assertEqual(value, details.get(key))
def test_item_defaults(self):
frappe.delete_doc_if_exists("Item", "Test Item With Defaults", force=1)
make_item("Test Item With Defaults", {
"item_group": "_Test Item Group",
"brand": "_Test Brand With Item Defaults",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse 2 - _TC", # no override
"expense_account": "_Test Account Stock Expenses - _TC", # override brand default
"buying_cost_center": "_Test Write Off Cost Center - _TC", # override item group default
}]
})
sales_item_check = {
"item_code": "Test Item With Defaults",
"warehouse": "_Test Warehouse 2 - _TC", # from item
"income_account": "_Test Account Sales - _TC", # from brand
"expense_account": "_Test Account Stock Expenses - _TC", # from item
"cost_center": "_Test Cost Center 2 - _TC", # from item group
}
sales_item_details = get_item_details({
"item_code": "Test Item With Defaults",
"company": "_Test Company",
"price_list": "_Test Price List",
"currency": "_Test Currency",
"doctype": "Sales Invoice",
"conversion_rate": 1,
"price_list_currency": "_Test Currency",
"plc_conversion_rate": 1,
"customer": "_Test Customer",
})
for key, value in iteritems(sales_item_check):
self.assertEqual(value, sales_item_details.get(key))
purchase_item_check = {
"item_code": "Test Item With Defaults",
"warehouse": "_Test Warehouse 2 - _TC", # from item
"expense_account": "_Test Account Stock Expenses - _TC", # from item
"income_account": "_Test Account Sales - _TC", # from brand
"cost_center": "_Test Write Off Cost Center - _TC" # from item
}
purchase_item_details = get_item_details({
"item_code": "Test Item With Defaults",
"company": "_Test Company",
"price_list": "_Test Price List",
"currency": "_Test Currency",
"doctype": "Purchase Invoice",
"conversion_rate": 1,
"price_list_currency": "_Test Currency",
"plc_conversion_rate": 1,
"supplier": "_Test Supplier",
})
for key, value in iteritems(purchase_item_check):
self.assertEqual(value, purchase_item_details.get(key))
def test_item_attribute_change_after_variant(self):
frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1)