Class: Spree::StoreCreditEvent

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

Methods inherited from Base

display_includes

Methods included from Core::Permalinks

#generate_permalink, #save_permalink

Instance Method Details

#action_requires_reason?Boolean

Returns:

  • (Boolean)


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

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

#authorization_action?Boolean

Returns:

  • (Boolean)


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

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

#capture_action?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/spree/store_credit_event.rb', line 23

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



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

def display_amount
  Spree::Money.new(amount, { 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_remaining_amountObject



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

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

#display_user_total_amountObject



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

def display_user_total_amount
  Spree::Money.new(user_total_amount, { 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