Class: Dorsale::BillingMachine::Invoice::Copy

Inherits:
Service
  • Object
show all
Defined in:
app/services/dorsale/billing_machine/invoice/copy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(invoice) ⇒ Copy

Returns a new instance of Copy.



4
5
6
# File 'app/services/dorsale/billing_machine/invoice/copy.rb', line 4

def initialize(invoice)
  @invoice = invoice
end

Instance Attribute Details

#copyObject

Returns the value of attribute copy.



2
3
4
# File 'app/services/dorsale/billing_machine/invoice/copy.rb', line 2

def copy
  @copy
end

#invoiceObject

Returns the value of attribute invoice.



2
3
4
# File 'app/services/dorsale/billing_machine/invoice/copy.rb', line 2

def invoice
  @invoice
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/dorsale/billing_machine/invoice/copy.rb', line 8

def call
  @copy = invoice.dup

  @invoice.lines.each do |line|
    @copy.lines << line.dup
  end

  @copy.date         = Time.zone.now.to_date
  @copy.due_date     = Time.zone.now.to_date + 30.days
  @copy.unique_index = nil
  @copy.paid         = false

  @copy
end