Module: Spree::Order::StoreCredit
- Included in:
- Spree::Order
- Defined in:
- app/models/spree/order/store_credit.rb
Instance Method Summary collapse
- #could_use_store_credit? ⇒ Boolean
- #covered_by_store_credit? ⇒ Boolean (also: #covered_by_store_credit)
- #display_order_total_after_store_credit ⇒ Object
- #display_store_credit_remaining_after_capture ⇒ Object
- #display_total_applicable_store_credit ⇒ Object
- #display_total_applied_store_credit ⇒ Object
- #display_total_available_store_credit ⇒ Object
- #order_total_after_store_credit ⇒ Object
- #total_applicable_store_credit ⇒ Object
- #total_applied_store_credit ⇒ Object
- #total_available_store_credit ⇒ Object
- #using_store_credit? ⇒ Boolean
Instance Method Details
#could_use_store_credit? ⇒ Boolean
17 18 19 20 21 |
# File 'app/models/spree/order/store_credit.rb', line 17 def could_use_store_credit? return false if Spree::PaymentMethod::StoreCredit.available.empty? total_available_store_credit > 0 end |
#covered_by_store_credit? ⇒ Boolean Also known as: covered_by_store_credit
4 5 6 7 8 |
# File 'app/models/spree/order/store_credit.rb', line 4 def covered_by_store_credit? return false unless user user.total_available_store_credit >= total end |
#display_order_total_after_store_credit ⇒ Object
51 52 53 |
# File 'app/models/spree/order/store_credit.rb', line 51 def display_order_total_after_store_credit Spree::Money.new(order_total_after_store_credit, currency: currency) end |
#display_store_credit_remaining_after_capture ⇒ Object
59 60 61 |
# File 'app/models/spree/order/store_credit.rb', line 59 def display_store_credit_remaining_after_capture Spree::Money.new(total_available_store_credit - total_applicable_store_credit, currency: currency) end |
#display_total_applicable_store_credit ⇒ Object
43 44 45 |
# File 'app/models/spree/order/store_credit.rb', line 43 def display_total_applicable_store_credit Spree::Money.new(-total_applicable_store_credit, currency: currency) end |
#display_total_applied_store_credit ⇒ Object
47 48 49 |
# File 'app/models/spree/order/store_credit.rb', line 47 def display_total_applied_store_credit Spree::Money.new(-total_applied_store_credit, currency: currency) end |
#display_total_available_store_credit ⇒ Object
55 56 57 |
# File 'app/models/spree/order/store_credit.rb', line 55 def display_total_available_store_credit Spree::Money.new(total_available_store_credit, currency: currency) end |
#order_total_after_store_credit ⇒ Object
23 24 25 |
# File 'app/models/spree/order/store_credit.rb', line 23 def order_total_after_store_credit total - total_applicable_store_credit end |
#total_applicable_store_credit ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/spree/order/store_credit.rb', line 27 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 |
#total_applied_store_credit ⇒ Object
35 36 37 |
# File 'app/models/spree/order/store_credit.rb', line 35 def total_applied_store_credit payments.store_credits.valid.sum(:amount) end |
#total_available_store_credit ⇒ Object
11 12 13 14 15 |
# File 'app/models/spree/order/store_credit.rb', line 11 def total_available_store_credit return 0.0 unless user user.total_available_store_credit end |
#using_store_credit? ⇒ Boolean
39 40 41 |
# File 'app/models/spree/order/store_credit.rb', line 39 def using_store_credit? total_applied_store_credit > 0 end |