Class: InvoiceCreator::Presenters::Invoice

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/invoice_creator/presenters/invoice.rb

Instance Method Summary collapse

Constructor Details

#initialize(invoice:, config:) ⇒ Invoice

Returns a new instance of Invoice.



8
9
10
11
# File 'lib/invoice_creator/presenters/invoice.rb', line 8

def initialize(invoice:, config:)
  @invoice = invoice
  @config = config
end

Instance Method Details

#billable_amountObject



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

def billable_amount
  amount(@invoice.billable_amount)
end

#dateObject



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

def date
  @invoice.invoice_date.strftime(@config.date_format)
end

#due_dateObject



17
18
19
# File 'lib/invoice_creator/presenters/invoice.rb', line 17

def due_date
  @invoice.due_date.strftime(@config.date_format)
end

#expenses_amountObject



37
38
39
# File 'lib/invoice_creator/presenters/invoice.rb', line 37

def expenses_amount
  amount(@invoice.expenses_amount)
end

#filenameObject



13
14
15
# File 'lib/invoice_creator/presenters/invoice.rb', line 13

def filename
  @invoice.invoice_date.strftime(@config.filename)
end

#has_expenses?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/invoice_creator/presenters/invoice.rb', line 41

def has_expenses?
  @invoice.expenses_amount > 0
end

#invoice_identifierObject



33
34
35
# File 'lib/invoice_creator/presenters/invoice.rb', line 33

def invoice_identifier
  sprintf(@config.invoice_identifier, @invoice.number)
end

#rateObject



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

def rate
  amount(@invoice.rate)
end

#totalObject



45
46
47
# File 'lib/invoice_creator/presenters/invoice.rb', line 45

def total
  amount(@invoice.total)
end