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-4.10.1 app/models/spree/reimbursement/credit.rb
spree_core-4.10.0 app/models/spree/reimbursement/credit.rb
spree_core-4.9.0 app/models/spree/reimbursement/credit.rb
spree_core-4.8.3 app/models/spree/reimbursement/credit.rb
spree_core-4.8.2 app/models/spree/reimbursement/credit.rb
spree_core-4.7.3 app/models/spree/reimbursement/credit.rb
spree_core-4.6.6 app/models/spree/reimbursement/credit.rb
spree_core-4.5.5 app/models/spree/reimbursement/credit.rb
spree_core-4.0.9 app/models/spree/reimbursement/credit.rb
spree_core-4.1.15 app/models/spree/reimbursement/credit.rb
spree_core-4.2.7 app/models/spree/reimbursement/credit.rb
spree_core-4.3.3 app/models/spree/reimbursement/credit.rb
spree_core-4.4.1 app/models/spree/reimbursement/credit.rb
spree_core-4.5.4 app/models/spree/reimbursement/credit.rb
spree_core-4.6.5 app/models/spree/reimbursement/credit.rb
spree_core-4.7.2 app/models/spree/reimbursement/credit.rb
spree_core-4.7.1 app/models/spree/reimbursement/credit.rb
spree_core-4.6.4 app/models/spree/reimbursement/credit.rb
spree_core-4.7.0 app/models/spree/reimbursement/credit.rb
spree_core-4.6.3 app/models/spree/reimbursement/credit.rb