Sha256: dd7c3672a867011b4d57ff9d778b35c53ce5964aa6086d6f54ca727605a416ea

Contents?: true

Size: 611 Bytes

Versions: 122

Compression:

Stored size: 611 Bytes

Contents

module Spree
  class Reimbursement::Credit < Spree::Base
    class_attribute :default_creditable_class
    self.default_creditable_class = nil

    belongs_to :reimbursement, inverse_of: :credits
    belongs_to :creditable, polymorphic: true

    validates :creditable, presence: true

    class << self
      def total_amount_reimbursed_for(reimbursement)
        reimbursement.credits.to_a.sum(&:amount)
      end
    end

    def description
      creditable.class.name.demodulize
    end

    def display_amount
      Spree::Money.new(amount, currency: creditable.try(:currency) || 'USD')
    end
  end
end

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
spree_core-3.4.6 app/models/spree/reimbursement/credit.rb
spree_core-3.7.10 app/models/spree/reimbursement/credit.rb
spree_core-4.0.3 app/models/spree/reimbursement/credit.rb
spree_core-3.7.9 app/models/spree/reimbursement/credit.rb
spree_core-4.0.2 app/models/spree/reimbursement/credit.rb
spree_core-3.7.8 app/models/spree/reimbursement/credit.rb
spree_core-4.0.1 app/models/spree/reimbursement/credit.rb
spree_core-3.7.7 app/models/spree/reimbursement/credit.rb
spree_core-4.0.0 app/models/spree/reimbursement/credit.rb
spree_core-4.0.0.rc3 app/models/spree/reimbursement/credit.rb
spree_core-3.7.6 app/models/spree/reimbursement/credit.rb
spree_core-3.7.5 app/models/spree/reimbursement/credit.rb
spree_core-4.0.0.rc2 app/models/spree/reimbursement/credit.rb
spree_core-4.0.0.rc1 app/models/spree/reimbursement/credit.rb
spree_core-4.0.0.beta app/models/spree/reimbursement/credit.rb
spree_core-3.7.4 app/models/spree/reimbursement/credit.rb
spree_core-3.7.3 app/models/spree/reimbursement/credit.rb
spree_core-3.7.2 app/models/spree/reimbursement/credit.rb
spree_core-3.7.1 app/models/spree/reimbursement/credit.rb
spree_core-3.7.0 app/models/spree/reimbursement/credit.rb