From 94294fa1617faaa408ef980fe5a9ad69ac4f5759 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Tue, 4 Apr 2023 14:11:51 +1000 Subject: [PATCH] Voucher adjustment, add ordering by created_at It gives us a consistent result when calling #vouchers --- app/models/spree/order.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 20f1b3225c..65d1b2aa44 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -62,7 +62,11 @@ module Spree has_many :line_item_adjustments, through: :line_items, source: :adjustments has_many :shipment_adjustments, through: :shipments, source: :adjustments has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy - has_many :vouchers, -> { where(originator_type: 'Voucher') }, + has_many :vouchers, + -> { + where(originator_type: 'Voucher') + .order("#{Spree::Adjustment.table_name}.created_at ASC") + }, class_name: 'Spree::Adjustment', dependent: :destroy