Merge branch 'develop' into fix_flaky_test_in_payment_terms_report
diff --git a/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py b/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py
index 525ae8e..58516f6 100644
--- a/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py
+++ b/erpnext/selling/report/payment_terms_status_for_sales_order/test_payment_terms_status_for_sales_order.py
@@ -2,7 +2,7 @@
import frappe
from frappe.tests.utils import FrappeTestCase
-from frappe.utils import add_days, nowdate
+from frappe.utils import add_days, add_months, nowdate
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
@@ -15,9 +15,16 @@
class TestPaymentTermsStatusForSalesOrder(FrappeTestCase):
+ def setUp(self):
+ self.cleanup_old_entries()
+
def tearDown(self):
frappe.db.rollback()
+ def cleanup_old_entries(self):
+ frappe.db.delete("Sales Invoice", filters={"company": "_Test Company"})
+ frappe.db.delete("Sales Order", filters={"company": "_Test Company"})
+
def create_payment_terms_template(self):
# create template for 50-50 payments
template = None
@@ -348,7 +355,7 @@
item = create_item(item_code="_Test Excavator 1", is_stock_item=0)
transaction_date = nowdate()
so = make_sales_order(
- transaction_date=add_days(transaction_date, -30),
+ transaction_date=add_months(transaction_date, -1),
delivery_date=add_days(transaction_date, -15),
item=item.item_code,
qty=10,
@@ -369,13 +376,15 @@
sinv.items[0].qty = 6
sinv.insert()
sinv.submit()
+
+ first_due_date = add_days(add_months(transaction_date, -1), 15)
columns, data, message, chart = execute(
frappe._dict(
{
"company": "_Test Company",
"item": item.item_code,
- "from_due_date": add_days(transaction_date, -30),
- "to_due_date": add_days(transaction_date, -15),
+ "from_due_date": add_months(transaction_date, -1),
+ "to_due_date": first_due_date,
}
)
)
@@ -384,11 +393,11 @@
{
"name": so.name,
"customer": so.customer,
- "submitted": datetime.date.fromisoformat(add_days(transaction_date, -30)),
+ "submitted": datetime.date.fromisoformat(add_months(transaction_date, -1)),
"status": "Completed",
"payment_term": None,
"description": "_Test 50-50",
- "due_date": datetime.date.fromisoformat(add_days(transaction_date, -15)),
+ "due_date": datetime.date.fromisoformat(first_due_date),
"invoice_portion": 50.0,
"currency": "INR",
"base_payment_amount": 500000.0,