mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
refactor(test): flaky tax rule testsuite
- Make Sales Stage preset
This commit is contained in:
@@ -431,9 +431,9 @@ def add_market_segments():
|
|||||||
make_records(records)
|
make_records(records)
|
||||||
|
|
||||||
|
|
||||||
def add_sale_stages():
|
def get_sale_stages():
|
||||||
# Sale Stages
|
# Sale Stages
|
||||||
records = [
|
return [
|
||||||
{"doctype": "Sales Stage", "stage_name": _("Prospecting")},
|
{"doctype": "Sales Stage", "stage_name": _("Prospecting")},
|
||||||
{"doctype": "Sales Stage", "stage_name": _("Qualification")},
|
{"doctype": "Sales Stage", "stage_name": _("Qualification")},
|
||||||
{"doctype": "Sales Stage", "stage_name": _("Needs Analysis")},
|
{"doctype": "Sales Stage", "stage_name": _("Needs Analysis")},
|
||||||
@@ -443,6 +443,10 @@ def add_sale_stages():
|
|||||||
{"doctype": "Sales Stage", "stage_name": _("Proposal/Price Quote")},
|
{"doctype": "Sales Stage", "stage_name": _("Proposal/Price Quote")},
|
||||||
{"doctype": "Sales Stage", "stage_name": _("Negotiation/Review")},
|
{"doctype": "Sales Stage", "stage_name": _("Negotiation/Review")},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def add_sale_stages():
|
||||||
|
records = get_sale_stages()
|
||||||
for sales_stage in records:
|
for sales_stage in records:
|
||||||
frappe.get_doc(sales_stage).db_insert()
|
frappe.get_doc(sales_stage).db_insert()
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,11 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
def make_presets(cls):
|
def make_presets(cls):
|
||||||
from frappe.desk.page.setup_wizard.install_fixtures import update_genders, update_salutations
|
from frappe.desk.page.setup_wizard.install_fixtures import update_genders, update_salutations
|
||||||
|
|
||||||
from erpnext.setup.setup_wizard.operations.install_fixtures import add_uom_data, get_preset_records
|
from erpnext.setup.setup_wizard.operations.install_fixtures import (
|
||||||
|
add_uom_data,
|
||||||
|
get_preset_records,
|
||||||
|
get_sale_stages,
|
||||||
|
)
|
||||||
|
|
||||||
update_genders()
|
update_genders()
|
||||||
update_salutations()
|
update_salutations()
|
||||||
@@ -187,6 +191,10 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
doc.insert()
|
doc.insert()
|
||||||
|
|
||||||
add_uom_data()
|
add_uom_data()
|
||||||
|
# add sale stages
|
||||||
|
for sales_stage in get_sale_stages():
|
||||||
|
if not frappe.db.exists("Sales Stage", {"stage_name": sales_stage.get("stage_name")}):
|
||||||
|
frappe.get_doc(sales_stage).insert()
|
||||||
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
@@ -218,6 +226,7 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
cls.make_location()
|
cls.make_location()
|
||||||
cls.make_price_list()
|
cls.make_price_list()
|
||||||
cls.make_shareholder()
|
cls.make_shareholder()
|
||||||
|
cls.make_sales_taxes_template()
|
||||||
cls.update_selling_settings()
|
cls.update_selling_settings()
|
||||||
cls.update_stock_settings()
|
cls.update_stock_settings()
|
||||||
cls.update_system_settings()
|
cls.update_system_settings()
|
||||||
@@ -2252,6 +2261,235 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
frappe.get_doc("Shareholder", {"title": x.get("title"), "company": x.get("company")})
|
frappe.get_doc("Shareholder", {"title": x.get("title"), "company": x.get("company")})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def make_sales_taxes_template(cls):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "VAT",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 6,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Service Tax - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "Service Tax",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 6.36,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "_Test Sales Taxes and Charges Template",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Shipping Charges - _TC",
|
||||||
|
"charge_type": "Actual",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "Shipping Charges",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"tax_amount": 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Customs Duty - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "Customs Duty",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 10,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Excise Duty - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "Excise Duty",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Education Cess - _TC",
|
||||||
|
"charge_type": "On Previous Row Amount",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "Education Cess",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 2,
|
||||||
|
"row_id": 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account S&H Education Cess - _TC",
|
||||||
|
"charge_type": "On Previous Row Amount",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "S&H Education Cess",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 1,
|
||||||
|
"row_id": 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account CST - _TC",
|
||||||
|
"charge_type": "On Previous Row Total",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "CST",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 2,
|
||||||
|
"row_id": 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "VAT",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 12.5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Discount - _TC",
|
||||||
|
"charge_type": "On Previous Row Total",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"description": "Discount",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": -10,
|
||||||
|
"row_id": 7,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "_Test India Tax Master",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "VAT",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Service Tax - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "Service Tax",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 4,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "_Test Sales Taxes and Charges Template - Rest of the World",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "VAT",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Service Tax - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "Service Tax",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 4,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "_Test Sales Taxes and Charges Template 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "VAT",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account_head": "_Test Account Service Tax - _TC",
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"description": "Service Tax",
|
||||||
|
"doctype": "Sales Taxes and Charges",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"parentfield": "taxes",
|
||||||
|
"rate": 4,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "_Test Sales Taxes and Charges Template 2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"title": "_Test Tax 1",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"charge_type": "Actual",
|
||||||
|
"account_head": "Sales Expenses - _TC",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"description": "Test Shopping cart taxes with Tax Rule",
|
||||||
|
"tax_amount": 1000,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
|
"title": "_Test Tax 2",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"taxes": [
|
||||||
|
{
|
||||||
|
"charge_type": "Actual",
|
||||||
|
"account_head": "Sales Expenses - _TC",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"description": "Test Shopping cart taxes with Tax Rule",
|
||||||
|
"tax_amount": 200,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
cls.sales_taxes_and_template = []
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists(
|
||||||
|
"Sales Taxes and Charges Template", {"title": x.get("title"), "company": x.get("company")}
|
||||||
|
):
|
||||||
|
cls.sales_taxes_and_template.append(frappe.get_doc(x).insert())
|
||||||
|
else:
|
||||||
|
cls.sales_taxes_and_template.append(
|
||||||
|
frappe.get_doc(
|
||||||
|
"Sales Taxes and Charges Template",
|
||||||
|
{"title": x.get("title"), "company": x.get("company")},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@ERPNextTestSuite.registerAs(staticmethod)
|
@ERPNextTestSuite.registerAs(staticmethod)
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|||||||
Reference in New Issue
Block a user