Sha256: 82cfe92b12094a406fc70d22c892768d1d44c748343bb85fe154b4b89da5e339

Contents?: true

Size: 615 Bytes

Versions: 72

Compression:

Stored size: 615 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

72 entries across 72 versions & 1 rubygems

Version Path
spree_core-3.2.9 app/models/spree/reimbursement/credit.rb
spree_core-3.1.14 app/models/spree/reimbursement/credit.rb
spree_core-3.3.6 app/models/spree/reimbursement/credit.rb
spree_core-3.2.8 app/models/spree/reimbursement/credit.rb
spree_core-3.1.13 app/models/spree/reimbursement/credit.rb
spree_core-3.3.5 app/models/spree/reimbursement/credit.rb
spree_core-3.3.4 app/models/spree/reimbursement/credit.rb
spree_core-3.2.7 app/models/spree/reimbursement/credit.rb
spree_core-3.1.12 app/models/spree/reimbursement/credit.rb
spree_core-3.3.3 app/models/spree/reimbursement/credit.rb
spree_core-3.2.6 app/models/spree/reimbursement/credit.rb
spree_core-3.1.11 app/models/spree/reimbursement/credit.rb
spree_core-3.1.10 app/models/spree/reimbursement/credit.rb
spree_core-3.3.2 app/models/spree/reimbursement/credit.rb
spree_core-3.2.5 app/models/spree/reimbursement/credit.rb
spree_core-3.1.9 app/models/spree/reimbursement/credit.rb
spree_core-3.3.1 app/models/spree/reimbursement/credit.rb
spree_core-3.2.4 app/models/spree/reimbursement/credit.rb
spree_core-3.1.8 app/models/spree/reimbursement/credit.rb
spree_core-3.3.0 app/models/spree/reimbursement/credit.rb