From 06d18ca03c318a1f852b1277ce9c0d5f7372c5da Mon Sep 17 00:00:00 2001 From: ljain112 Date: Thu, 3 Jul 2025 13:11:37 +0530 Subject: [PATCH 1/3] chore: fix flaky test in Tax Withholding Details --- .../test_tax_withholding_details.py | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py index c869a808bc..30a5df3fcb 100644 --- a/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/test_tax_withholding_details.py @@ -67,11 +67,12 @@ class TestTaxWithholdingDetails(AccountsTestMixin, IntegrationTestCase): mid_year = add_to_date(fiscal_year[1], months=6) tds_doc = frappe.get_doc("Tax Withholding Category", "TDS - 3") tds_doc.rates[0].to_date = mid_year + from_date = add_to_date(mid_year, days=1) tds_doc.append( "rates", { "tax_withholding_rate": 20, - "from_date": add_to_date(mid_year, days=1), + "from_date": from_date, "to_date": fiscal_year[2], "single_threshold": 1, "cumulative_threshold": 1, @@ -81,21 +82,18 @@ class TestTaxWithholdingDetails(AccountsTestMixin, IntegrationTestCase): tds_doc.save() inv_1 = make_purchase_invoice( - rate=1000, posting_date=fiscal_year[1], do_not_submit=True, do_not_save=True - ) # @dokos: 1st invoice must be posted at the beginning of the year - inv_1.set_posting_time = 1 # @dokos + rate=1000, posting_date=add_to_date(fiscal_year[1], days=1), do_not_save=True, do_not_submit=True + ) + inv_1.set_posting_time = 1 inv_1.apply_tds = 1 - inv_1.tax_withholding_category = "TDS - 3" - inv_1.save() # @dokos + inv_1.tax_withholding_category = tds_doc.name + inv_1.save() inv_1.submit() - inv_2 = make_purchase_invoice( - rate=1000, do_not_submit=True, posting_date=add_to_date(mid_year, days=1), do_not_save=True - ) + inv_2 = make_purchase_invoice(rate=1000, posting_date=from_date, do_not_save=True, do_not_submit=True) inv_2.set_posting_time = 1 - - inv_1.apply_tds = 1 - inv_2.tax_withholding_category = "TDS - 3" + inv_2.apply_tds = 1 + inv_2.tax_withholding_category = tds_doc.name inv_2.save() inv_2.submit() -- GitLab From 7ec710fc8ebccaf7bd04af0f5bc477da6f011ce8 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Thu, 3 Jul 2025 13:34:33 +0530 Subject: [PATCH 2/3] fix: sort tax withhodling details report by section code and transaction date --- .../report/tax_withholding_details/tax_withholding_details.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py index 02dec9686c..d801237774 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -121,7 +121,7 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_ ) out.append(row) - out.sort(key=lambda x: x["section_code"]) + out.sort(key=lambda x: (x["section_code"], x["transaction_date"])) return out -- GitLab From 1e320afa635e839760f76720f99082302aca014f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 3 Jul 2025 11:57:08 +0530 Subject: [PATCH 3/3] fix(test): flaky budget test case --- erpnext/accounts/doctype/budget/test_budget.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py index 58527ba768..2189ed4ef7 100644 --- a/erpnext/accounts/doctype/budget/test_budget.py +++ b/erpnext/accounts/doctype/budget/test_budget.py @@ -113,6 +113,10 @@ class TestBudget(ERPNextTestSuite): frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop") frappe.db.set_value("Budget", budget.name, "fiscal_year", fiscal_year) + accumulated_limit = get_accumulated_monthly_budget( + budget.monthly_distribution, nowdate(), budget.fiscal_year, budget.accounts[0].budget_amount + ) + mr = frappe.get_doc( { "doctype": "Material Request", @@ -126,7 +130,7 @@ class TestBudget(ERPNextTestSuite): "uom": "_Test UOM", "warehouse": "_Test Warehouse - _TC", "schedule_date": nowdate(), - "rate": 20000 * getdate().month, # type: ignore @dokos + "rate": accumulated_limit + 1, "expense_account": "_Test Account Cost for Goods Sold - _TC", "cost_center": "_Test Cost Center - _TC", } -- GitLab