Class: InvoiceCreator::Models::Invoice
- Inherits:
-
Object
- Object
- InvoiceCreator::Models::Invoice
- Defined in:
- lib/invoice_creator/models/invoice.rb
Instance Attribute Summary collapse
-
#billable_hours ⇒ Object
readonly
Returns the value of attribute billable_hours.
-
#expenses_amount ⇒ Object
readonly
Returns the value of attribute expenses_amount.
-
#invoice_date ⇒ Object
readonly
Returns the value of attribute invoice_date.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
Instance Method Summary collapse
- #billable_amount ⇒ Object
- #due_date ⇒ Object
-
#initialize(rate:, due_day:, billable_hours:, expenses_amount: 0.0, invoice_date: Date.today, number: 1) ⇒ Invoice
constructor
A new instance of Invoice.
- #total ⇒ Object
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_hours ⇒ Object (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_amount ⇒ Object (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_date ⇒ Object (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 |
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'lib/invoice_creator/models/invoice.rb', line 6 def number @number end |
#rate ⇒ Object (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_amount ⇒ Object
29 30 31 |
# File 'lib/invoice_creator/models/invoice.rb', line 29 def billable_amount @billable_hours * @rate end |
#due_date ⇒ Object
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 |
#total ⇒ Object
25 26 27 |
# File 'lib/invoice_creator/models/invoice.rb', line 25 def total billable_amount + @expenses_amount end |