From 23d35c6cca8e1df7fc7f9f6d7c2ae1a37360cde4 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 3 Mar 2026 08:25:42 +0530 Subject: [PATCH] refactor(test): make sales invoice deterministic --- .../doctype/sales_invoice/test_sales_invoice.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 2cb9c685203..1ece0dd5d11 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2127,16 +2127,19 @@ class TestSalesInvoice(ERPNextTestSuite): @ERPNextTestSuite.change_settings("Selling Settings", {"sales_update_frequency": "Each Transaction"}) def test_company_monthly_sales(self): - existing_current_month_sales = frappe.get_cached_value( - "Company", "_Test Company", "total_monthly_sales" - ) + from erpnext.setup.doctype.company.company import update_company_current_month_sales + + company = "_Test Company" + + update_company_current_month_sales(company) + existing_current_month_sales = frappe.db.get_value("Company", company, "total_monthly_sales") si = create_sales_invoice() - current_month_sales = frappe.get_cached_value("Company", "_Test Company", "total_monthly_sales") + current_month_sales = frappe.db.get_value("Company", company, "total_monthly_sales") self.assertEqual(current_month_sales, existing_current_month_sales + si.base_grand_total) si.cancel() - current_month_sales = frappe.get_cached_value("Company", "_Test Company", "total_monthly_sales") + current_month_sales = frappe.db.get_value("Company", company, "total_monthly_sales") self.assertEqual(current_month_sales, existing_current_month_sales) def test_rounding_adjustment(self):