Class: SpreeCmCommissioner::VotingCredits::DeAllocate

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/voting_credits/de_allocate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ DeAllocate

Returns a new instance of DeAllocate.



6
7
8
# File 'app/services/spree_cm_commissioner/voting_credits/de_allocate.rb', line 6

def initialize(order)
  @order = order
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/services/spree_cm_commissioner/voting_credits/de_allocate.rb', line 4

def order
  @order
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/spree_cm_commissioner/voting_credits/de_allocate.rb', line 10

def call
  return true if already_canceled?

  # DeAllocate#call
  #   → purchase_transaction_exists? → false
  #   → raise RuntimeError
  #   → bubbles up to VotingCreditDeAllocationJob
  #   → Sidekiq retries
  raise "Vote credits not yet allocated for order #{order.number}" unless purchase_transaction_exists?

  process_refunds
end