Class: Invoice
- Inherits:
-
Object
- Object
- Invoice
- Defined in:
- lib/contract_ltd/invoice.rb
Instance Method Summary collapse
- #days ⇒ Object
- #filename ⇒ Object
-
#initialize(date, total_days) ⇒ Invoice
constructor
A new instance of Invoice.
- #invoice_num ⇒ Object
- #month_year ⇒ Object
- #name(ext) ⇒ Object
- #rate(rate = nil) ⇒ Object
- #subtotal ⇒ Object
- #todays_date ⇒ Object
- #total ⇒ Object
- #total_hours ⇒ Object
- #vat ⇒ Object
Constructor Details
#initialize(date, total_days) ⇒ Invoice
Returns a new instance of Invoice.
32 33 34 35 36 |
# File 'lib/contract_ltd/invoice.rb', line 32 def initialize(date, total_days) @name = 'invoice' @date = date @total_days = total_days end |
Instance Method Details
#days ⇒ Object
66 67 68 |
# File 'lib/contract_ltd/invoice.rb', line 66 def days @total_days end |
#filename ⇒ Object
86 87 88 |
# File 'lib/contract_ltd/invoice.rb', line 86 def filename invoice_filename(@date) end |
#invoice_num ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/contract_ltd/invoice.rb', line 38 def invoice_num previous_invoice_count = Dir['invoice_*'].size if previous_invoice_count == 0 puts "WARNING: NO PREVIOUS INVOICES DETECTED" puts "If this is the first invoice you can ignore this warning" puts "Otherwise make sure previous invoices are in the correct format:" puts " #{timesheet_filename(@date)}" puts " #{invoice_filename(@date)}" end '%03d' % (previous_invoice_count + 1) end |
#month_year ⇒ Object
50 51 52 |
# File 'lib/contract_ltd/invoice.rb', line 50 def month_year @date.to_s(:month_name_year) end |
#name(ext) ⇒ Object
82 83 84 |
# File 'lib/contract_ltd/invoice.rb', line 82 def name(ext) "#{@name}.#{ext}" end |
#rate(rate = nil) ⇒ Object
62 63 64 |
# File 'lib/contract_ltd/invoice.rb', line 62 def rate(rate = nil) @rate ||= rate end |
#subtotal ⇒ Object
70 71 72 |
# File 'lib/contract_ltd/invoice.rb', line 70 def subtotal rate * days end |
#todays_date ⇒ Object
54 55 56 |
# File 'lib/contract_ltd/invoice.rb', line 54 def todays_date Date.today.to_s(:long) end |
#total ⇒ Object
78 79 80 |
# File 'lib/contract_ltd/invoice.rb', line 78 def total subtotal + vat end |
#total_hours ⇒ Object
58 59 60 |
# File 'lib/contract_ltd/invoice.rb', line 58 def total_hours @total_days * 7.5 end |
#vat ⇒ Object
74 75 76 |
# File 'lib/contract_ltd/invoice.rb', line 74 def vat subtotal * 0.2 end |