refactor(test): make dunning deterministic

This commit is contained in:
ruthra kumar
2026-01-29 11:48:51 +05:30
parent 3a5869e525
commit c55628a55d
2 changed files with 48 additions and 15 deletions

View File

@@ -252,6 +252,7 @@ class ERPNextTestSuite(unittest.TestCase):
cls.make_brand()
cls.make_monthly_distribution()
cls.make_projects()
cls.make_dunning_type()
cls.update_selling_settings()
cls.update_stock_settings()
cls.update_system_settings()
@@ -3042,6 +3043,53 @@ class ERPNextTestSuite(unittest.TestCase):
else:
cls.brand.append(frappe.get_doc("Brand", {"Brand": x.get("brand")}))
@classmethod
def make_dunning_type(cls):
records = [
{
"doctype": "Dunning Type",
"dunning_type": "First Notice",
"company": cls.companies[0].name,
"is_default": 1,
"dunning_fee": 0,
"rate_of_interest": 0,
"income_account": "Sales - _TC",
"cost_center": "Main - _TC",
"dunning_letter_text": [
{
"language": "en",
"body_text": "We have still not received payment for our invoice",
"closing_text": "We kindly request that you pay the outstanding amount immediately, including interest and late fees.",
},
],
},
{
"doctype": "Dunning Type",
"dunning_type": "Second Notice",
"company": cls.companies[0].name,
"is_default": 0,
"dunning_fee": 10,
"rate_of_interest": 10,
"income_account": "Sales - _TC",
"cost_center": "Main - _TC",
"dunning_letter_text": [
{
"language": "en",
"body_text": "We have still not received payment for our invoice",
"closing_text": "We kindly request that you pay the outstanding amount immediately, including interest and late fees.",
},
],
},
]
cls.dunning_type = []
for x in records:
if not frappe.db.exists("Dunning Type", {"dunning_type": x.get("dunning_type")}):
cls.dunning_type.append(frappe.get_doc(x).insert())
else:
cls.dunning_type.append(
frappe.get_doc("Dunning Type", {"dunning_type": x.get("dunning_type")})
)
@contextmanager
def set_user(self, user: str):
try: