Sha256: 6d1da81a2d62304c1153530b72dc2f080b10282cb64b031d69ea54d03936b65c
Contents?: true
Size: 1.66 KB
Versions: 17
Compression:
Stored size: 1.66 KB
Contents
module Spree class Order < Spree::Base module StoreCredit def covered_by_store_credit? return false unless user user.total_available_store_credit >= total end alias covered_by_store_credit covered_by_store_credit? def total_available_store_credit return 0.0 unless user user.total_available_store_credit end def could_use_store_credit? total_available_store_credit > 0 end def order_total_after_store_credit total - total_applicable_store_credit end def total_applicable_store_credit if payment? || confirm? || complete? total_applied_store_credit else [total, (user.try(:total_available_store_credit) || 0.0)].min end end def total_applied_store_credit payments.store_credits.valid.sum(:amount) end def using_store_credit? total_applied_store_credit > 0 end def display_total_applicable_store_credit Spree::Money.new(-total_applicable_store_credit, currency: currency) end def display_total_applied_store_credit Spree::Money.new(-total_applied_store_credit, currency: currency) end def display_order_total_after_store_credit Spree::Money.new(order_total_after_store_credit, currency: currency) end def display_total_available_store_credit Spree::Money.new(total_available_store_credit, currency: currency) end def display_store_credit_remaining_after_capture Spree::Money.new(total_available_store_credit - total_applicable_store_credit, currency: currency) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems