Class: Spree::StoreCreditEvent

Inherits:
ActiveRecord::Base
  • Object
show all
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

Instance Method Details

#action_requires_reason?Boolean

Returns:

  • (Boolean)


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

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

#authorization_action?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/models/spree/store_credit_event.rb', line 25

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

#capture_action?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/spree/store_credit_event.rb', line 21

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

#display_actionObject



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

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

#display_amountObject



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

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

#display_event_dateObject



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

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

#display_user_total_amountObject



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

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

#orderObject



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

def order
  Spree::Payment.find_by_response_code(authorization_code).try(:order)
end