Sha256: 0e88d932ccdd85a358d66691d83941ede5725b9eaeee2c63ebc0e7db51fe007c
Contents?: true
Size: 1.73 KB
Versions: 30
Compression:
Stored size: 1.73 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? return false if Spree::PaymentMethod::StoreCredit.available.empty? 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
30 entries across 30 versions & 1 rubygems