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)


35
36
37
# File 'app/models/spree/store_credit_event.rb', line 35

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

#authorization_action?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/spree/store_credit_event.rb', line 31

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

#capture_action?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/spree/store_credit_event.rb', line 27

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

#display_actionObject



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

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

#display_amountObject



39
40
41
# File 'app/models/spree/store_credit_event.rb', line 39

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

#display_event_dateObject



47
48
49
# File 'app/models/spree/store_credit_event.rb', line 47

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

#display_user_total_amountObject



43
44
45
# File 'app/models/spree/store_credit_event.rb', line 43

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

#orderObject



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

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