Sha256: 7fa07c17633fa3631521360c0c2df48d96f3d6a5c61b14f46caea9a5894c6e3f
Contents?: true
Size: 756 Bytes
Versions: 91
Compression:
Stored size: 756 Bytes
Contents
# frozen_string_literal: true module Spree class Reimbursement < Spree::Base class Credit < Spree::Base class_attribute :default_creditable_class self.default_creditable_class = Spree::StoreCredit belongs_to :reimbursement, inverse_of: :credits, optional: true belongs_to :creditable, polymorphic: true, optional: 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 end
Version data entries
91 entries across 91 versions & 1 rubygems