Refactor #vouchers

Use "has_many" instead of a method
This commit is contained in:
Gaetan Craig-Riou
2023-04-04 11:24:22 +10:00
committed by Maikel Linke
parent 4b5d6d7eac
commit 87cc525d27

View File

@@ -62,6 +62,9 @@ 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') },
class_name: 'Spree::Adjustment',
dependent: :destroy
belongs_to :order_cycle
belongs_to :distributor, class_name: 'Enterprise'
@@ -618,10 +621,6 @@ module Spree
end
end
def vouchers
adjustments.where(originator_type: 'Voucher')
end
private
def fee_handler