Class: InvoiceCreator::Presenters::Invoice
- Inherits:
-
Object
- Object
- InvoiceCreator::Presenters::Invoice
- Extended by:
- Forwardable
- Defined in:
- lib/invoice_creator/presenters/invoice.rb
Instance Method Summary collapse
- #billable_amount ⇒ Object
- #date ⇒ Object
- #due_date ⇒ Object
- #expenses_amount ⇒ Object
- #filename ⇒ Object
- #has_expenses? ⇒ Boolean
-
#initialize(invoice:, config:) ⇒ Invoice
constructor
A new instance of Invoice.
- #invoice_identifier ⇒ Object
- #rate ⇒ Object
- #total ⇒ Object
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_amount ⇒ Object
25 26 27 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 25 def billable_amount amount(@invoice.billable_amount) end |
#date ⇒ Object
21 22 23 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 21 def date @invoice.invoice_date.strftime(@config.date_format) end |
#due_date ⇒ Object
17 18 19 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 17 def due_date @invoice.due_date.strftime(@config.date_format) end |
#expenses_amount ⇒ Object
37 38 39 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 37 def expenses_amount amount(@invoice.expenses_amount) end |
#filename ⇒ Object
13 14 15 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 13 def filename @invoice.invoice_date.strftime(@config.filename) end |
#has_expenses? ⇒ Boolean
41 42 43 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 41 def has_expenses? @invoice.expenses_amount > 0 end |
#invoice_identifier ⇒ Object
33 34 35 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 33 def invoice_identifier sprintf(@config.invoice_identifier, @invoice.number) end |
#rate ⇒ Object
29 30 31 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 29 def rate amount(@invoice.rate) end |
#total ⇒ Object
45 46 47 |
# File 'lib/invoice_creator/presenters/invoice.rb', line 45 def total amount(@invoice.total) end |