mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
refactor(test): make dunning deterministic
This commit is contained in:
@@ -8,9 +8,6 @@ from frappe.utils import add_days, nowdate, today
|
|||||||
|
|
||||||
from erpnext import get_default_cost_center
|
from erpnext import get_default_cost_center
|
||||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import (
|
|
||||||
unlink_payment_on_cancel_of_invoice,
|
|
||||||
)
|
|
||||||
from erpnext.accounts.doctype.sales_invoice.sales_invoice import (
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice import (
|
||||||
create_dunning as create_dunning_from_sales_invoice,
|
create_dunning as create_dunning_from_sales_invoice,
|
||||||
)
|
)
|
||||||
@@ -21,18 +18,6 @@ from erpnext.tests.utils import ERPNextTestSuite
|
|||||||
|
|
||||||
|
|
||||||
class TestDunning(ERPNextTestSuite):
|
class TestDunning(ERPNextTestSuite):
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
super().setUpClass()
|
|
||||||
create_dunning_type("First Notice", fee=0.0, interest=0.0, is_default=1)
|
|
||||||
create_dunning_type("Second Notice", fee=10.0, interest=10.0, is_default=0)
|
|
||||||
unlink_payment_on_cancel_of_invoice()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
unlink_payment_on_cancel_of_invoice(0)
|
|
||||||
super().tearDownClass()
|
|
||||||
|
|
||||||
def test_dunning_without_fees(self):
|
def test_dunning_without_fees(self):
|
||||||
dunning = create_dunning(overdue_days=20)
|
dunning = create_dunning(overdue_days=20)
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
cls.make_brand()
|
cls.make_brand()
|
||||||
cls.make_monthly_distribution()
|
cls.make_monthly_distribution()
|
||||||
cls.make_projects()
|
cls.make_projects()
|
||||||
|
cls.make_dunning_type()
|
||||||
cls.update_selling_settings()
|
cls.update_selling_settings()
|
||||||
cls.update_stock_settings()
|
cls.update_stock_settings()
|
||||||
cls.update_system_settings()
|
cls.update_system_settings()
|
||||||
@@ -3042,6 +3043,53 @@ class ERPNextTestSuite(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
cls.brand.append(frappe.get_doc("Brand", {"Brand": x.get("brand")}))
|
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
|
@contextmanager
|
||||||
def set_user(self, user: str):
|
def set_user(self, user: str):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user