Class: Stall::CartCreditNoteCreationService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/stall/cart_credit_note_creation_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cart) ⇒ CartCreditNoteCreationService

Returns a new instance of CartCreditNoteCreationService.



5
6
7
# File 'app/services/stall/cart_credit_note_creation_service.rb', line 5

def initialize(cart)
  @cart = cart
end

Instance Attribute Details

#cartObject (readonly)

Returns the value of attribute cart.



3
4
5
# File 'app/services/stall/cart_credit_note_creation_service.rb', line 3

def cart
  @cart
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
# File 'app/services/stall/cart_credit_note_creation_service.rb', line 9

def call
  if cart.remainder? && !adjustment_exists?
    credit_note = create_credit_note!
    create_adjustment_for!(credit_note)

    true
  else
    false
  end
end