Module: InvoicesHelper

Defined in:
app/helpers/invoices_helper.rb

Instance Method Summary collapse

Instance Method Details

#header_tagsObject



48
49
50
51
# File 'app/helpers/invoices_helper.rb', line 48

def header_tags
  return stylesheet_link_tag("invoice.css", :plugin => "chiliproject_invoice", :media => 'all') +
    stylesheet_link_tag("invoice_print.css", :plugin => "chiliproject_invoice", :media => 'print')
end

#invoice_list_tabs(invoices = { }) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/invoices_helper.rb', line 3

def invoice_list_tabs(invoices = { })
  tabs = [{:name => 'open', :label => "label_open_invoices", :items => invoices[:open]},
          {:name => 'late', :label => "label_late_invoices", :items => invoices[:late]},
          {:name => 'closed', :label => "label_closed_invoices", :items => invoices[:closed]}
          ]
end

#invoice_menu(invoice = nil) {|menu_items| ... } ⇒ Object

Yields:

  • (menu_items)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/invoices_helper.rb', line 29

def invoice_menu(invoice=nil, &block)
  menu_items = []
  menu_items << link_to(l(:label_invoice_list), invoice_index_path, :class => 'icon icon-invoice-list') 
  menu_items << link_to(l(:label_new_invoice), new_invoice_path, :class => 'icon icon-invoice-new') 
  menu_items << link_to(l(:label_new_autofilled_invoice), autocreate_invoice_path, :class => 'icon icon-invoice-new') 

  if invoice.nil?
    menu_items << link_to(l(:label_new_payment),  new_payment_path, :class => 'icon icon-payment-new') 
  else 
    menu_items << link_to(l(:label_new_payment), new_invoice_payment_path(invoice), :class => 'icon icon-payment-new') 
  end

  yield menu_items if block_given?

  return (:div, menu_items.join(' '), :class => "contextual nonprinting", :id => "invoice-menu") +
    (:div, '', :style => 'clear: both')

end

#invoice_status(invoice) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/invoices_helper.rb', line 10

def invoice_status(invoice)
  case true
  when invoice.fully_paid?
    return (:div,
                       (:p, l(:label_paid_invoice)),
                       :class => "invoice-message fully-paid nonprinting")
  when invoice.late?
    return (:div,
                       (:p, l(:label_late_invoices)),
                       :class => "invoice-message late nonprinting")
    
  else
    return (:div,
                       (:p, l(:label_open_invoices)),
                       :class => "invoice-message pending nonprinting")
    
  end
end