Class: BBNW::Invoice

Inherits:
Object
  • Object
show all
Includes:
InvoiceDisplayUtils
Defined in:
lib/big_bucks_no_whammies.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InvoiceDisplayUtils

#company, #display_price, #header, #message_display

Methods included from DateTimeUtils

#is_number?, #long_date, #long_date_time, #long_time, #parse_time, #short_date, #short_time, #time_description

Constructor Details

#initializeInvoice

Returns a new instance of Invoice.



14
15
16
# File 'lib/big_bucks_no_whammies.rb', line 14

def initialize
  @meetings = {}
end

Instance Attribute Details

#line_items(repository_adapter, activities_span, time_estimate_adapter, group_by_task_id = true) ⇒ Object

Usage :

Compute time usage % over a 20 hour span

  line_items(git_commits, 20)

Compute time usage using recorded time activities
and cross reference that with git commits.

  line_items(git_commits, time_sink_activities)


28
29
30
# File 'lib/big_bucks_no_whammies.rb', line 28

def line_items
  @line_items
end

Instance Method Details

#generate(invoice_num, company_logo, company_name, company_details, bill_to, rate_per_hour, start_date = nil, end_date = nil, hours = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/big_bucks_no_whammies.rb', line 35

def generate(invoice_num, , company_name,
             company_details, bill_to, rate_per_hour, start_date = nil, end_date = nil, hours = nil)

  raise "There are not line items to generate a report with." if @line_items.empty?

  rate_per_second = rate_per_hour / 3600.to_f
  Payday::Config.default.    = 
  Payday::Config.default.company_name    = company_name
  Payday::Config.default.company_details = company(company_details, start_date, end_date, hours)

  due_date      = Date.today + 21
  invoice       = Payday::Invoice.new(:invoice_number => invoice_num,
                                      :bill_to        => bill_to.join("\n"),
                                      :due_at         => due_date)

  display_price = display_price(rate_per_hour)

  build_line_item_report(display_price, invoice, rate_per_second, Fixnum)
  build_line_item_report(display_price, invoice, rate_per_second, String)

  invoice.render_pdf_to_file(invoice_path(invoice_num, bill_to[0]))
end

#meeting(label, start_time, end_time, account_for) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/big_bucks_no_whammies.rb', line 58

def meeting(label, start_time, end_time, )
  s = Time.parse(start_time)
  e = Time.parse(end_time)
  meeting_label = "Meeting (#{short_time(s)} - #{short_time(e)}): #{label}"
  time_span =  ? (e - s) : 0
  @meetings[BBNW::Meeting.new(meeting_label, s, e, )] = time_span
end

#task(label, start_time, end_time) ⇒ Object



66
67
68
69
70
71
# File 'lib/big_bucks_no_whammies.rb', line 66

def task(label, start_time, end_time)
  s = Time.parse(start_time)
  e = Time.parse(end_time)
  label = "Task : #{label}"
  @meetings[BBNW::Meeting.new(label, s, e)] = e - s
end