From 1e34237b2231d97cd9b4452487d4099897744b72 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 14 Feb 2025 16:41:43 +1100 Subject: [PATCH] Fix order of line item based report rows The orders_and_fulfillment_spec would sometimes fail when the database would return line items in a different order than they were created. Without specific `order` clause the order of rows can be random. The additional sorting may lead to more server load but also ensures more consistent results for users. --- lib/reporting/line_items.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporting/line_items.rb b/lib/reporting/line_items.rb index 01cd726ed0..0073b66d50 100644 --- a/lib/reporting/line_items.rb +++ b/lib/reporting/line_items.rb @@ -17,7 +17,7 @@ module Reporting def list(line_item_includes = [variant: [:supplier, :product]]) line_items = order_permissions.visible_line_items.in_orders(orders.result) - .order("supplier.name", "product.name", "variant.display_name") + .order("supplier.name", "product.name", "variant.display_name", "variant.unit_description") if @params[:supplier_id_in].present? line_items = line_items.supplied_by_any(@params[:supplier_id_in])