Skip to content

Commit

Permalink
fix(test): flaky test case in Payment terms report
Browse files Browse the repository at this point in the history
(cherry picked from commit 7fcd74e)
  • Loading branch information
ruthra-kumar authored and mergify[bot] committed Mar 11, 2023
1 parent 29c58b6 commit 69a5411
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -348,7 +355,7 @@ def test_04_due_date_filter(self):
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,
Expand All @@ -369,13 +376,15 @@ def test_04_due_date_filter(self):
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,
}
)
)
Expand All @@ -384,11 +393,11 @@ def test_04_due_date_filter(self):
{
"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,
Expand Down

0 comments on commit 69a5411

Please sign in to comment.