test: Added test for get_item_tax_template and get_item_tax_map

This commit is contained in:
Saif Ur Rehman 2019-01-09 11:24:30 +05:00
parent 380b4b0926
commit 091cfba5fc
4 changed files with 273 additions and 1 deletions

View File

@ -10,5 +10,65 @@
"tax_type": "_Test Account Excise Duty - _TC"
}
]
},
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 12",
"taxes": [
{
"doctype": "Item Tax Template Detail",
"parentfield": "taxes",
"tax_rate": 12,
"tax_type": "_Test Account Excise Duty - _TC"
}
]
},
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 15",
"taxes": [
{
"doctype": "Item Tax Template Detail",
"parentfield": "taxes",
"tax_rate": 15,
"tax_type": "_Test Account Excise Duty - _TC"
}
]
},
{
"doctype": "Item Tax Template",
"title": "_Test Account Excise Duty @ 20",
"taxes": [
{
"doctype": "Item Tax Template Detail",
"parentfield": "taxes",
"tax_rate": 20,
"tax_type": "_Test Account Excise Duty - _TC"
}
]
},
{
"doctype": "Item Tax Template",
"title": "_Test Item Tax Template 1",
"taxes": [
{
"doctype": "Item Tax Template Detail",
"parentfield": "taxes",
"tax_rate": 5,
"tax_type": "_Test Account Excise Duty - _TC"
},
{
"doctype": "Item Tax Template Detail",
"parentfield": "taxes",
"tax_rate": 10,
"tax_type": "_Test Account Education Cess - _TC"
},
{
"doctype": "Item Tax Template Detail",
"parentfield": "taxes",
"tax_rate": 15,
"tax_type": "_Test Account S&H Education Cess - _TC"
}
]
}
]

View File

@ -69,5 +69,39 @@
"is_group": 1,
"item_group_name": "_Test Item Group D",
"parent_item_group": "All Item Groups"
},
{
"doctype": "Item Group",
"is_group": 1,
"item_group_name": "_Test Item Group Tax Parent",
"parent_item_group": "All Item Groups",
"taxes": [
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Account Excise Duty @ 10",
"tax_category": ""
},
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Account Excise Duty @ 12",
"tax_category": "_Test Tax Category 1"
}
]
},
{
"doctype": "Item Group",
"is_group": 0,
"item_group_name": "_Test Item Group Tax Child Override",
"parent_item_group": "_Test Item Group Tax Parent",
"taxes": [
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Account Excise Duty @ 15",
"tax_category": ""
}
]
}
]

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import unittest
import frappe
import json
from frappe.test_runner import make_test_objects
from erpnext.controllers.item_variant import (create_variant, ItemVariantExistsError,
@ -76,7 +77,6 @@ class TestItem(unittest.TestCase):
"amount": 0.0,
"base_amount": 0.0,
"batch_no": None,
"item_tax_rate": '{}',
"uom": "_Test UOM",
"conversion_factor": 1.0,
}
@ -102,6 +102,68 @@ class TestItem(unittest.TestCase):
for key, value in iteritems(to_check):
self.assertEqual(value, details.get(key))
def test_item_tax_template(self):
expected_item_tax_template = [
{"item_code": "_Test Item With Item Tax Template", "tax_category": "",
"item_tax_template": "_Test Account Excise Duty @ 10"},
{"item_code": "_Test Item With Item Tax Template", "tax_category": "_Test Tax Category 1",
"item_tax_template": "_Test Account Excise Duty @ 12"},
{"item_code": "_Test Item With Item Tax Template", "tax_category": "_Test Tax Category 2",
"item_tax_template": None},
{"item_code": "_Test Item Inherit Group Item Tax Template 1", "tax_category": "",
"item_tax_template": "_Test Account Excise Duty @ 10"},
{"item_code": "_Test Item Inherit Group Item Tax Template 1", "tax_category": "_Test Tax Category 1",
"item_tax_template": "_Test Account Excise Duty @ 12"},
{"item_code": "_Test Item Inherit Group Item Tax Template 1", "tax_category": "_Test Tax Category 2",
"item_tax_template": None},
{"item_code": "_Test Item Inherit Group Item Tax Template 2", "tax_category": "",
"item_tax_template": "_Test Account Excise Duty @ 15"},
{"item_code": "_Test Item Inherit Group Item Tax Template 2", "tax_category": "_Test Tax Category 1",
"item_tax_template": "_Test Account Excise Duty @ 12"},
{"item_code": "_Test Item Inherit Group Item Tax Template 2", "tax_category": "_Test Tax Category 2",
"item_tax_template": None},
{"item_code": "_Test Item Override Group Item Tax Template", "tax_category": "",
"item_tax_template": "_Test Account Excise Duty @ 20"},
{"item_code": "_Test Item Override Group Item Tax Template", "tax_category": "_Test Tax Category 1",
"item_tax_template": "_Test Item Tax Template 1"},
{"item_code": "_Test Item Override Group Item Tax Template", "tax_category": "_Test Tax Category 2",
"item_tax_template": None},
]
expected_item_tax_map = {
None: {},
"_Test Account Excise Duty @ 10": {"_Test Account Excise Duty - _TC": 10},
"_Test Account Excise Duty @ 12": {"_Test Account Excise Duty - _TC": 12},
"_Test Account Excise Duty @ 15": {"_Test Account Excise Duty - _TC": 15},
"_Test Account Excise Duty @ 20": {"_Test Account Excise Duty - _TC": 20},
"_Test Item Tax Template 1": {"_Test Account Excise Duty - _TC": 5, "_Test Account Education Cess - _TC": 10,
"_Test Account S&H Education Cess - _TC": 15}
}
for data in expected_item_tax_template:
details = get_item_details({
"item_code": data['item_code'],
"tax_category": data['tax_category'],
"company": "_Test Company",
"price_list": "_Test Price List",
"currency": "_Test Currency",
"doctype": "Sales Order",
"conversion_rate": 1,
"price_list_currency": "_Test Currency",
"plc_conversion_rate": 1,
"order_type": "Sales",
"customer": "_Test Customer",
"conversion_factor": 1,
"price_list_uom_dependant": 1,
"ignore_pricing_rule": 1
})
self.assertEqual(details.item_tax_template, data['item_tax_template'])
self.assertEqual(json.loads(details.item_tax_rate), expected_item_tax_map[details.item_tax_template])
def test_item_attribute_change_after_variant(self):
frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1)

View File

@ -344,5 +344,121 @@
"stock_uom": "_Test UOM",
"show_in_website": 1,
"website_warehouse": "_Test Warehouse Group-C1 - _TC"
},
{
"description": "_Test Item With Item Tax Template",
"doctype": "Item",
"has_batch_no": 0,
"has_serial_no": 0,
"inspection_required": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item With Item Tax Template",
"item_group": "_Test Item Group",
"item_name": "_Test Item With Item Tax Template",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"buying_cost_center": "_Test Cost Center - _TC",
"selling_cost_center": "_Test Cost Center - _TC",
"income_account": "Sales - _TC"
}],
"taxes": [
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Account Excise Duty @ 10",
"tax_category": ""
},
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Account Excise Duty @ 12",
"tax_category": "_Test Tax Category 1"
}
]
},
{
"description": "_Test Item Inherit Group Item Tax Template 1",
"doctype": "Item",
"has_batch_no": 0,
"has_serial_no": 0,
"inspection_required": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item Inherit Group Item Tax Template 1",
"item_group": "_Test Item Group Tax Parent",
"item_name": "_Test Item Inherit Group Item Tax Template 1",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"buying_cost_center": "_Test Cost Center - _TC",
"selling_cost_center": "_Test Cost Center - _TC",
"income_account": "Sales - _TC"
}]
},
{
"description": "_Test Item Inherit Group Item Tax Template 2",
"doctype": "Item",
"has_batch_no": 0,
"has_serial_no": 0,
"inspection_required": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item Inherit Group Item Tax Template 2",
"item_group": "_Test Item Group Tax Child Override",
"item_name": "_Test Item Inherit Group Item Tax Template 2",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"buying_cost_center": "_Test Cost Center - _TC",
"selling_cost_center": "_Test Cost Center - _TC",
"income_account": "Sales - _TC"
}]
},
{
"description": "_Test Item Override Group Item Tax Template",
"doctype": "Item",
"has_batch_no": 0,
"has_serial_no": 0,
"inspection_required": 0,
"is_stock_item": 1,
"is_sub_contracted_item": 0,
"item_code": "_Test Item Override Group Item Tax Template",
"item_group": "_Test Item Group Tax Child Override",
"item_name": "_Test Item Override Group Item Tax Template",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"buying_cost_center": "_Test Cost Center - _TC",
"selling_cost_center": "_Test Cost Center - _TC",
"income_account": "Sales - _TC"
}],
"taxes": [
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Account Excise Duty @ 20",
"tax_category": ""
},
{
"doctype": "Item Tax",
"parentfield": "taxes",
"item_tax_template": "_Test Item Tax Template 1",
"tax_category": "_Test Tax Category 1"
}
]
}
]