mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-27 07:01:13 +01:00
refactor(test): make sales payment summary deterministic
This commit is contained in:
@@ -13,20 +13,6 @@ from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestSalesPaymentSummary(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
create_records()
|
||||
pes = frappe.get_all("Payment Entry")
|
||||
jes = frappe.get_all("Journal Entry")
|
||||
sis = frappe.get_all("Sales Invoice")
|
||||
for pe in pes:
|
||||
frappe.db.set_value("Payment Entry", pe.name, "docstatus", 2)
|
||||
for je in jes:
|
||||
frappe.db.set_value("Journal Entry", je.name, "docstatus", 2)
|
||||
for si in sis:
|
||||
frappe.db.set_value("Sales Invoice", si.name, "docstatus", 2)
|
||||
|
||||
def test_get_mode_of_payments(self):
|
||||
filters = get_filters()
|
||||
|
||||
@@ -92,6 +78,7 @@ class TestSalesPaymentSummary(ERPNextTestSuite):
|
||||
mopd = get_mode_of_payment_details(filters)
|
||||
|
||||
mopd_values = next(iter(mopd.values()))
|
||||
cc_init_amount = 0
|
||||
for mopd_value in mopd_values:
|
||||
if mopd_value[0] == "Credit Card":
|
||||
cc_init_amount = mopd_value[1]
|
||||
@@ -108,6 +95,7 @@ class TestSalesPaymentSummary(ERPNextTestSuite):
|
||||
|
||||
mopd = get_mode_of_payment_details(filters)
|
||||
mopd_values = next(iter(mopd.values()))
|
||||
cc_final_amount = 0
|
||||
for mopd_value in mopd_values:
|
||||
if mopd_value[0] == "Credit Card":
|
||||
cc_final_amount = mopd_value[1]
|
||||
@@ -145,41 +133,3 @@ def create_sales_invoice_record(qty=1):
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def create_records():
|
||||
if frappe.db.exists("Customer", "Prestiga-Biz"):
|
||||
return
|
||||
|
||||
# customer
|
||||
frappe.get_doc(
|
||||
{
|
||||
"customer_group": "_Test Customer Group",
|
||||
"customer_name": "Prestiga-Biz",
|
||||
"customer_type": "Company",
|
||||
"doctype": "Customer",
|
||||
"territory": "_Test Territory",
|
||||
}
|
||||
).insert()
|
||||
|
||||
# item
|
||||
item = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Item",
|
||||
"item_code": "Consulting",
|
||||
"item_name": "Consulting",
|
||||
"item_group": "All Item Groups",
|
||||
"company": "_Test Company",
|
||||
"is_stock_item": 0,
|
||||
}
|
||||
).insert()
|
||||
|
||||
# item price
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Item Price",
|
||||
"price_list": "Standard Selling",
|
||||
"item_code": item.item_code,
|
||||
"price_list_rate": 10000,
|
||||
}
|
||||
).insert()
|
||||
|
||||
@@ -2312,6 +2312,15 @@ class ERPNextTestSuite(unittest.TestCase):
|
||||
"item_group": "All Item Groups",
|
||||
"stock_uom": "Nos",
|
||||
},
|
||||
{
|
||||
"doctype": "Item",
|
||||
"item_code": "Consulting",
|
||||
"item_name": "Consulting",
|
||||
"is_stock_item": 0,
|
||||
"item_group": "All Item Groups",
|
||||
"stock_uom": "Nos",
|
||||
"company": "_Test Company",
|
||||
},
|
||||
]
|
||||
cls.item = []
|
||||
for x in records:
|
||||
@@ -2509,6 +2518,13 @@ class ERPNextTestSuite(unittest.TestCase):
|
||||
"represents_company": cls.companies[6].name,
|
||||
"companies": [{"company": cls.companies[6].name}],
|
||||
},
|
||||
{
|
||||
"customer_group": "_Test Customer Group",
|
||||
"customer_name": "Prestiga-Biz",
|
||||
"customer_type": "Company",
|
||||
"doctype": "Customer",
|
||||
"territory": "_Test Territory",
|
||||
},
|
||||
]
|
||||
cls.customer = []
|
||||
for x in records:
|
||||
@@ -2991,6 +3007,12 @@ class ERPNextTestSuite(unittest.TestCase):
|
||||
"item_code": "Loyal Item",
|
||||
"price_list_rate": 10000,
|
||||
},
|
||||
{
|
||||
"doctype": "Item Price",
|
||||
"item_code": "Consulting",
|
||||
"price_list": "Standard Selling",
|
||||
"price_list_rate": 10000,
|
||||
},
|
||||
]
|
||||
cls.item_price = []
|
||||
for x in records:
|
||||
|
||||
Reference in New Issue
Block a user