test: test_party_details_tax_category
This commit is contained in:
parent
bbd1e47758
commit
502f15ba1b
@ -6,5 +6,9 @@
|
||||
{
|
||||
"doctype": "Tax Category",
|
||||
"title": "_Test Tax Category 2"
|
||||
},
|
||||
{
|
||||
"doctype": "Tax Category",
|
||||
"title": "_Test Tax Category 3"
|
||||
}
|
||||
]
|
||||
|
@ -39,5 +39,11 @@
|
||||
"company": "_Test Company",
|
||||
"account": "_Test Payable USD - _TC"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"doctype": "Supplier",
|
||||
"supplier_name": "_Test Supplier With Tax Category",
|
||||
"supplier_group": "_Test Supplier Group",
|
||||
"tax_category": "_Test Tax Category 1"
|
||||
}
|
||||
]
|
||||
|
@ -90,3 +90,33 @@ class TestSupplier(unittest.TestCase):
|
||||
supplier.country = 'Greece'
|
||||
supplier.save()
|
||||
self.assertEqual(supplier.country, "Greece")
|
||||
|
||||
def test_party_details_tax_category(self):
|
||||
from erpnext.accounts.party import get_party_details
|
||||
|
||||
frappe.delete_doc_if_exists("Address", "_Test Address With Tax Category-Billing")
|
||||
|
||||
# Tax Category without Address
|
||||
details = get_party_details("_Test Supplier With Tax Category", party_type="Supplier")
|
||||
self.assertEqual(details.tax_category, "_Test Tax Category 1")
|
||||
|
||||
address = frappe.get_doc(dict(
|
||||
doctype='Address',
|
||||
address_title='_Test Address With Tax Category',
|
||||
tax_category='_Test Tax Category 2',
|
||||
address_type='Billing',
|
||||
address_line1='Station Road',
|
||||
city='_Test City',
|
||||
country='India',
|
||||
links=[dict(
|
||||
link_doctype='Supplier',
|
||||
link_name='_Test Supplier With Tax Category'
|
||||
)]
|
||||
)).insert()
|
||||
|
||||
# Tax Category with Address
|
||||
details = get_party_details("_Test Supplier With Tax Category", party_type="Supplier")
|
||||
self.assertEqual(details.tax_category, "_Test Tax Category 2")
|
||||
|
||||
# Rollback
|
||||
address.delete()
|
||||
|
@ -56,6 +56,64 @@ class TestCustomer(unittest.TestCase):
|
||||
for key, value in iteritems(to_check):
|
||||
self.assertEqual(value, details.get(key))
|
||||
|
||||
def test_party_details_tax_category(self):
|
||||
from erpnext.accounts.party import get_party_details
|
||||
|
||||
frappe.delete_doc_if_exists("Address", "_Test Address With Tax Category-Billing")
|
||||
frappe.delete_doc_if_exists("Address", "_Test Address With Tax Category-Shipping")
|
||||
|
||||
# Tax Category without Address
|
||||
details = get_party_details("_Test Customer With Tax Category")
|
||||
self.assertEqual(details.tax_category, "_Test Tax Category 1")
|
||||
|
||||
billing_address = frappe.get_doc(dict(
|
||||
doctype='Address',
|
||||
address_title='_Test Address With Tax Category',
|
||||
tax_category='_Test Tax Category 2',
|
||||
address_type='Billing',
|
||||
address_line1='Station Road',
|
||||
city='_Test City',
|
||||
country='India',
|
||||
links=[dict(
|
||||
link_doctype='Customer',
|
||||
link_name='_Test Customer With Tax Category'
|
||||
)]
|
||||
)).insert()
|
||||
shipping_address = frappe.get_doc(dict(
|
||||
doctype='Address',
|
||||
address_title='_Test Address With Tax Category',
|
||||
tax_category='_Test Tax Category 3',
|
||||
address_type='Shipping',
|
||||
address_line1='Station Road',
|
||||
city='_Test City',
|
||||
country='India',
|
||||
links=[dict(
|
||||
link_doctype='Customer',
|
||||
link_name='_Test Customer With Tax Category'
|
||||
)]
|
||||
)).insert()
|
||||
|
||||
settings = frappe.get_single("Accounts Settings")
|
||||
rollback_setting = settings.determine_address_tax_category_from
|
||||
|
||||
# Tax Category from Billing Address
|
||||
settings.determine_address_tax_category_from = "Billing Address"
|
||||
settings.save()
|
||||
details = get_party_details("_Test Customer With Tax Category")
|
||||
self.assertEqual(details.tax_category, "_Test Tax Category 2")
|
||||
|
||||
# Tax Category from Shipping Address
|
||||
settings.determine_address_tax_category_from = "Shipping Address"
|
||||
settings.save()
|
||||
details = get_party_details("_Test Customer With Tax Category")
|
||||
self.assertEqual(details.tax_category, "_Test Tax Category 3")
|
||||
|
||||
# Rollback
|
||||
settings.determine_address_tax_category_from = rollback_setting
|
||||
settings.save()
|
||||
billing_address.delete()
|
||||
shipping_address.delete()
|
||||
|
||||
def test_rename(self):
|
||||
# delete communication linked to these 2 customers
|
||||
for name in ("_Test Customer 1", "_Test Customer 1 Renamed"):
|
||||
|
@ -51,5 +51,13 @@
|
||||
"company": "_Test Company",
|
||||
"account": "_Test Receivable USD - _TC"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"customer_group": "_Test Customer Group",
|
||||
"customer_name": "_Test Customer With Tax Category",
|
||||
"customer_type": "Individual",
|
||||
"doctype": "Customer",
|
||||
"territory": "_Test Territory",
|
||||
"tax_category": "_Test Tax Category 1"
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user