Class: InvoiceCreator::Models::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/invoice_creator/models/invoice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rate:, due_day:, billable_hours:, expenses_amount: 0.0, invoice_date: Date.today, number: 1) ⇒ Invoice

Returns a new instance of Invoice.



12
13
14
15
16
17
18
19
# File 'lib/invoice_creator/models/invoice.rb', line 12

def initialize(rate:, due_day:, billable_hours:, expenses_amount: 0.0, invoice_date: Date.today, number: 1)
  @rate = rate
  @billable_hours = billable_hours
  @expenses_amount = expenses_amount
  @invoice_date = invoice_date
  @due_day = due_day
  @number = number
end

Instance Attribute Details

#billable_hoursObject (readonly)

Returns the value of attribute billable_hours.



6
7
8
# File 'lib/invoice_creator/models/invoice.rb', line 6

def billable_hours
  @billable_hours
end

#expenses_amountObject (readonly)

Returns the value of attribute expenses_amount.



6
7
8
# File 'lib/invoice_creator/models/invoice.rb', line 6

def expenses_amount
  @expenses_amount
end

#invoice_dateObject (readonly)

Returns the value of attribute invoice_date.



6
7
8
# File 'lib/invoice_creator/models/invoice.rb', line 6

def invoice_date
  @invoice_date
end

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'lib/invoice_creator/models/invoice.rb', line 6

def number
  @number
end

#rateObject (readonly)

Returns the value of attribute rate.



6
7
8
# File 'lib/invoice_creator/models/invoice.rb', line 6

def rate
  @rate
end

Instance Method Details

#billable_amountObject



29
30
31
# File 'lib/invoice_creator/models/invoice.rb', line 29

def billable_amount
  @billable_hours * @rate
end

#due_dateObject



21
22
23
# File 'lib/invoice_creator/models/invoice.rb', line 21

def due_date
  Date.new(@invoice_date.year, @invoice_date.month, @due_day)
end

#totalObject



25
26
27
# File 'lib/invoice_creator/models/invoice.rb', line 25

def total
  billable_amount + @expenses_amount
end