Class: Spree::StoreCreditEvent

Inherits:
Base
  • Object
show all
Includes:
Discard::Model, ParanoiaDeprecations
Defined in:
app/models/spree/store_credit_event.rb

Constant Summary

NON_EXPOSED_ACTIONS =
[Spree::StoreCredit::ELIGIBLE_ACTION, Spree::StoreCredit::AUTHORIZE_ACTION]

Instance Method Summary collapse

Methods included from ParanoiaDeprecations

#paranoia_delete, #paranoia_destroy

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#admin_form_preference_names, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#action_requires_reason?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/spree/store_credit_event.rb', line 37

def action_requires_reason?
  [Spree::StoreCredit::ADJUSTMENT_ACTION, Spree::StoreCredit::INVALIDATE_ACTION].include?(action)
end

#authorization_action?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/spree/store_credit_event.rb', line 33

def authorization_action?
  action == Spree::StoreCredit::AUTHORIZE_ACTION
end

#capture_action?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/spree/store_credit_event.rb', line 29

def capture_action?
  action == Spree::StoreCredit::CAPTURE_ACTION
end

#display_actionObject



57
58
59
60
# File 'app/models/spree/store_credit_event.rb', line 57

def display_action
  return if NON_EXPOSED_ACTIONS.include?(action)
  I18n.t("spree.store_credit.display_action.#{action}")
end

#display_amountObject



41
42
43
# File 'app/models/spree/store_credit_event.rb', line 41

def display_amount
  Spree::Money.new(amount, { currency: currency })
end

#display_event_dateObject



53
54
55
# File 'app/models/spree/store_credit_event.rb', line 53

def display_event_date
  I18n.l(created_at.to_date, format: :long)
end

#display_remaining_amountObject



49
50
51
# File 'app/models/spree/store_credit_event.rb', line 49

def display_remaining_amount
  Spree::Money.new(amount_remaining, { currency: currency })
end

#display_user_total_amountObject



45
46
47
# File 'app/models/spree/store_credit_event.rb', line 45

def display_user_total_amount
  Spree::Money.new(user_total_amount, { currency: currency })
end

#orderObject



62
63
64
# File 'app/models/spree/store_credit_event.rb', line 62

def order
  Spree::Payment.find_by(response_code: authorization_code).try(:order)
end