From 70142d147e29943d5e655a049acc1d4a0c6ca8d3 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 29 Jun 2026 16:29:46 +0530 Subject: [PATCH] fix(selling): break last-sales-amount ties deterministically in Inactive Customers get_last_sales_amt ordered by the sales date DESC only; same-date documents made the reported Last Order Amount engine-dependent. Add name DESC tiebreaker. --- erpnext/selling/report/inactive_customers/inactive_customers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/selling/report/inactive_customers/inactive_customers.py b/erpnext/selling/report/inactive_customers/inactive_customers.py index 2dedb346601..1710566b92a 100644 --- a/erpnext/selling/report/inactive_customers/inactive_customers.py +++ b/erpnext/selling/report/inactive_customers/inactive_customers.py @@ -86,6 +86,7 @@ def get_last_sales_amt(customer, doctype): .select(sales_doctype.base_net_total) .where((sales_doctype.customer == customer) & (sales_doctype.docstatus == 1)) .orderby(date_col, order=frappe.qb.desc) + .orderby(sales_doctype.name, order=frappe.qb.desc) .limit(1) ).run()