Class: Spree::StoreCreditEvent
- Inherits:
-
Base
- Object
- Base
- Spree::StoreCreditEvent
- Includes:
- Metadata, SoftDeletable
- Defined in:
- app/models/spree/store_credit_event.rb
Constant Summary collapse
- NON_EXPOSED_ACTIONS =
[Spree::StoreCredit::ELIGIBLE_ACTION, Spree::StoreCredit::AUTHORIZE_ACTION]
Instance Method Summary collapse
- #action_requires_reason? ⇒ Boolean
- #authorization_action? ⇒ Boolean
- #capture_action? ⇒ Boolean
- #display_action ⇒ Object
- #display_amount ⇒ Object
- #display_event_date ⇒ Object
- #display_remaining_amount ⇒ Object
- #display_user_total_amount ⇒ Object
- #order ⇒ Object
Instance Method Details
#action_requires_reason? ⇒ Boolean
32 33 34 |
# File 'app/models/spree/store_credit_event.rb', line 32 def action_requires_reason? [Spree::StoreCredit::ADJUSTMENT_ACTION, Spree::StoreCredit::INVALIDATE_ACTION].include?(action) end |
#authorization_action? ⇒ Boolean
28 29 30 |
# File 'app/models/spree/store_credit_event.rb', line 28 def action == Spree::StoreCredit::AUTHORIZE_ACTION end |
#capture_action? ⇒ Boolean
24 25 26 |
# File 'app/models/spree/store_credit_event.rb', line 24 def capture_action? action == Spree::StoreCredit::CAPTURE_ACTION end |
#display_action ⇒ Object
52 53 54 55 |
# File 'app/models/spree/store_credit_event.rb', line 52 def display_action return if NON_EXPOSED_ACTIONS.include?(action) I18n.t("spree.store_credit.display_action.#{action}") end |
#display_amount ⇒ Object
36 37 38 |
# File 'app/models/spree/store_credit_event.rb', line 36 def display_amount Spree::Money.new(amount, {currency:}) end |
#display_event_date ⇒ Object
48 49 50 |
# File 'app/models/spree/store_credit_event.rb', line 48 def display_event_date I18n.l(created_at.to_date, format: :long) end |
#display_remaining_amount ⇒ Object
44 45 46 |
# File 'app/models/spree/store_credit_event.rb', line 44 def display_remaining_amount Spree::Money.new(amount_remaining, {currency:}) end |
#display_user_total_amount ⇒ Object
40 41 42 |
# File 'app/models/spree/store_credit_event.rb', line 40 def display_user_total_amount Spree::Money.new(user_total_amount, {currency:}) end |
#order ⇒ Object
57 58 59 |
# File 'app/models/spree/store_credit_event.rb', line 57 def order Spree::Payment.find_by(response_code: ).try(:order) end |