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 |
# File 'app/models/spree/order/store_credit.rb', line 17 def could_use_store_credit? 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
49 50 51 |
# File 'app/models/spree/order/store_credit.rb', line 49 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
57 58 59 |
# File 'app/models/spree/order/store_credit.rb', line 57 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
41 42 43 |
# File 'app/models/spree/order/store_credit.rb', line 41 def display_total_applicable_store_credit Spree::Money.new(-total_applicable_store_credit, currency: currency) end |
#display_total_applied_store_credit ⇒ Object
45 46 47 |
# File 'app/models/spree/order/store_credit.rb', line 45 def display_total_applied_store_credit Spree::Money.new(-total_applied_store_credit, currency: currency) end |
#display_total_available_store_credit ⇒ Object
53 54 55 |
# File 'app/models/spree/order/store_credit.rb', line 53 def display_total_available_store_credit Spree::Money.new(total_available_store_credit, currency: currency) end |
#order_total_after_store_credit ⇒ Object
21 22 23 |
# File 'app/models/spree/order/store_credit.rb', line 21 def order_total_after_store_credit total - total_applicable_store_credit end |
#total_applicable_store_credit ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/models/spree/order/store_credit.rb', line 25 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
33 34 35 |
# File 'app/models/spree/order/store_credit.rb', line 33 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
37 38 39 |
# File 'app/models/spree/order/store_credit.rb', line 37 def using_store_credit? total_applied_store_credit > 0 end |