class InvoiceCreator::Presenters::Invoice

Public Class Methods

new(invoice:, config:) click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 8
def initialize(invoice:, config:)
  @invoice = invoice
  @config = config
end

Public Instance Methods

billable_amount() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 25
def billable_amount
  amount(@invoice.billable_amount)
end
date() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 21
def date
  @invoice.invoice_date.strftime(@config.date_format)
end
due_date() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 17
def due_date
  @invoice.due_date.strftime(@config.date_format)
end
expenses_amount() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 37
def expenses_amount
  amount(@invoice.expenses_amount)
end
filename() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 13
def filename
  @invoice.invoice_date.strftime(@config.filename)
end
has_expenses?() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 41
def has_expenses?
  @invoice.expenses_amount > 0
end
invoice_identifier() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 33
def invoice_identifier
  sprintf(@config.invoice_identifier, @invoice.number)
end
rate() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 29
def rate
  amount(@invoice.rate)
end
total() click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 45
def total
  amount(@invoice.total)
end

Private Instance Methods

amount(amount) click to toggle source
# File lib/invoice_creator/presenters/invoice.rb, line 57
def amount(amount)
  sprintf(@config.currency_format, amount)
end