Voucher adjustment, add ordering by created_at

It gives us a consistent result when calling #vouchers
This commit is contained in:
Gaetan Craig-Riou
2023-04-04 14:11:51 +10:00
committed by Maikel Linke
parent a1ad25f217
commit 94294fa161

View File

@@ -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