Merge pull request #22635 from deepeshgarg007/item_tax_test
fix(travis): Item Tax template test
This commit is contained in:
commit
8cdf33f618
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax Template",
|
"doctype": "Item Tax Template",
|
||||||
"title": "_Test Account Excise Duty @ 10",
|
"title": "_Test Account Excise Duty @ 10",
|
||||||
|
"company": "_Test Company",
|
||||||
"taxes": [
|
"taxes": [
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax Template Detail",
|
"doctype": "Item Tax Template Detail",
|
||||||
@ -14,6 +15,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax Template",
|
"doctype": "Item Tax Template",
|
||||||
"title": "_Test Account Excise Duty @ 12",
|
"title": "_Test Account Excise Duty @ 12",
|
||||||
|
"company": "_Test Company",
|
||||||
"taxes": [
|
"taxes": [
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax Template Detail",
|
"doctype": "Item Tax Template Detail",
|
||||||
@ -26,6 +28,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax Template",
|
"doctype": "Item Tax Template",
|
||||||
"title": "_Test Account Excise Duty @ 15",
|
"title": "_Test Account Excise Duty @ 15",
|
||||||
|
"company": "_Test Company",
|
||||||
"taxes": [
|
"taxes": [
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax Template Detail",
|
"doctype": "Item Tax Template Detail",
|
||||||
@ -38,6 +41,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax Template",
|
"doctype": "Item Tax Template",
|
||||||
"title": "_Test Account Excise Duty @ 20",
|
"title": "_Test Account Excise Duty @ 20",
|
||||||
|
"company": "_Test Company",
|
||||||
"taxes": [
|
"taxes": [
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax Template Detail",
|
"doctype": "Item Tax Template Detail",
|
||||||
@ -50,6 +54,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax Template",
|
"doctype": "Item Tax Template",
|
||||||
"title": "_Test Item Tax Template 1",
|
"title": "_Test Item Tax Template 1",
|
||||||
|
"company": "_Test Company",
|
||||||
"taxes": [
|
"taxes": [
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax Template Detail",
|
"doctype": "Item Tax Template Detail",
|
||||||
|
@ -13,13 +13,11 @@ class TestMapper(unittest.TestCase):
|
|||||||
'''Test mapping of multiple source docs on a single target doc'''
|
'''Test mapping of multiple source docs on a single target doc'''
|
||||||
|
|
||||||
make_test_records("Item")
|
make_test_records("Item")
|
||||||
items = frappe.get_all("Item", fields = ["name", "item_code"], filters = {'is_sales_item': 1, 'has_variants': 0, 'disabled': 0})
|
items = ['_Test Item', '_Test Item 2', '_Test FG Item']
|
||||||
customers = frappe.get_all("Customer")
|
|
||||||
if items and customers:
|
|
||||||
# Make source docs (quotations) and a target doc (sales order)
|
# Make source docs (quotations) and a target doc (sales order)
|
||||||
customer = random.choice(customers).name
|
qtn1, item_list_1 = self.make_quotation(items, '_Test Customer')
|
||||||
qtn1, item_list_1 = self.make_quotation(items, customer)
|
qtn2, item_list_2 = self.make_quotation(items, '_Test Customer')
|
||||||
qtn2, item_list_2 = self.make_quotation(items, customer)
|
|
||||||
so, item_list_3 = self.make_sales_order()
|
so, item_list_3 = self.make_sales_order()
|
||||||
|
|
||||||
# Map source docs to target with corresponding mapper method
|
# Map source docs to target with corresponding mapper method
|
||||||
@ -28,18 +26,12 @@ class TestMapper(unittest.TestCase):
|
|||||||
|
|
||||||
# Assert that all inserted items are present in updated sales order
|
# Assert that all inserted items are present in updated sales order
|
||||||
src_items = item_list_1 + item_list_2 + item_list_3
|
src_items = item_list_1 + item_list_2 + item_list_3
|
||||||
self.assertEqual(set([d.item_code for d in src_items]),
|
self.assertEqual(set([d for d in src_items]),
|
||||||
set([d.item_code for d in updated_so.items]))
|
set([d.item_code for d in updated_so.items]))
|
||||||
|
|
||||||
def get_random_items(self, items, limit):
|
|
||||||
'''Get a number of random items from a list of given items'''
|
|
||||||
random_items = []
|
|
||||||
for i in range(0, limit):
|
|
||||||
random_items.append(random.choice(items))
|
|
||||||
return random_items
|
|
||||||
|
|
||||||
def make_quotation(self, items, customer):
|
def make_quotation(self, item_list, customer):
|
||||||
item_list = self.get_random_items(items, 3)
|
|
||||||
qtn = frappe.get_doc({
|
qtn = frappe.get_doc({
|
||||||
"doctype": "Quotation",
|
"doctype": "Quotation",
|
||||||
"quotation_to": "Customer",
|
"quotation_to": "Customer",
|
||||||
@ -49,7 +41,7 @@ class TestMapper(unittest.TestCase):
|
|||||||
"valid_till" : add_months(nowdate(), 1)
|
"valid_till" : add_months(nowdate(), 1)
|
||||||
})
|
})
|
||||||
for item in item_list:
|
for item in item_list:
|
||||||
qtn.append("items", {"qty": "2", "item_code": item.item_code})
|
qtn.append("items", {"qty": "2", "item_code": item})
|
||||||
|
|
||||||
qtn.submit()
|
qtn.submit()
|
||||||
return qtn, item_list
|
return qtn, item_list
|
||||||
@ -60,7 +52,7 @@ class TestMapper(unittest.TestCase):
|
|||||||
"base_rate": 100.0,
|
"base_rate": 100.0,
|
||||||
"description": "CPU",
|
"description": "CPU",
|
||||||
"doctype": "Sales Order Item",
|
"doctype": "Sales Order Item",
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
"item_code": "_Test Item",
|
||||||
"item_name": "CPU",
|
"item_name": "CPU",
|
||||||
"parentfield": "items",
|
"parentfield": "items",
|
||||||
"qty": 10.0,
|
"qty": 10.0,
|
||||||
@ -72,4 +64,4 @@ class TestMapper(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
so = frappe.get_doc(frappe.get_test_records('Sales Order')[0])
|
so = frappe.get_doc(frappe.get_test_records('Sales Order')[0])
|
||||||
so.insert(ignore_permissions=True)
|
so.insert(ignore_permissions=True)
|
||||||
return so, [item]
|
return so, [item.item_code]
|
||||||
|
@ -30,6 +30,7 @@ class TestTaxes(unittest.TestCase):
|
|||||||
self.item_tax_template = frappe.get_doc({
|
self.item_tax_template = frappe.get_doc({
|
||||||
'doctype': 'Item Tax Template',
|
'doctype': 'Item Tax Template',
|
||||||
'title': uuid4(),
|
'title': uuid4(),
|
||||||
|
'company': self.company.name,
|
||||||
'taxes': [
|
'taxes': [
|
||||||
{
|
{
|
||||||
'tax_type': self.account.name,
|
'tax_type': self.account.name,
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
"base_rate": 100.0,
|
"base_rate": 100.0,
|
||||||
"description": "CPU",
|
"description": "CPU",
|
||||||
"doctype": "Sales Order Item",
|
"doctype": "Sales Order Item",
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
"item_code": "_Test Item",
|
||||||
"item_name": "CPU",
|
"item_name": "_Test Item 1",
|
||||||
"delivery_date": "2013-02-23",
|
"delivery_date": "2013-02-23",
|
||||||
"parentfield": "items",
|
"parentfield": "items",
|
||||||
"qty": 10.0,
|
"qty": 10.0,
|
||||||
|
@ -92,8 +92,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax",
|
"doctype": "Item Tax",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
"item_tax_template": "_Test Account Excise Duty @ 10",
|
"item_tax_template": "_Test Account Excise Duty @ 10"
|
||||||
"tax_category": ""
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stock_uom": "_Test UOM 1"
|
"stock_uom": "_Test UOM 1"
|
||||||
@ -371,8 +370,7 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax",
|
"doctype": "Item Tax",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
"item_tax_template": "_Test Account Excise Duty @ 10",
|
"item_tax_template": "_Test Account Excise Duty @ 10"
|
||||||
"tax_category": ""
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax",
|
"doctype": "Item Tax",
|
||||||
@ -451,14 +449,13 @@
|
|||||||
{
|
{
|
||||||
"doctype": "Item Tax",
|
"doctype": "Item Tax",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
"item_tax_template": "_Test Account Excise Duty @ 20",
|
"item_tax_template": "_Test Account Excise Duty @ 20"
|
||||||
"tax_category": ""
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Item Tax",
|
"doctype": "Item Tax",
|
||||||
"parentfield": "taxes",
|
"parentfield": "taxes",
|
||||||
"item_tax_template": "_Test Item Tax Template 1",
|
"tax_category": "_Test Tax Category 1",
|
||||||
"tax_category": "_Test Tax Category 1"
|
"item_tax_template": "_Test Item Tax Template 1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user