Class: InvoiceController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/invoice_controller.rb

Instance Method Summary collapse

Instance Method Details

#autocreateObject



20
21
22
# File 'app/controllers/invoice_controller.rb', line 20

def autocreate
  @autofill = Autofill.new
end

#autofillObject



62
63
64
65
66
67
68
# File 'app/controllers/invoice_controller.rb', line 62

def autofill
  @autofill = Autofill.new_from_params(params[:autofill])

  respond_to do |format|
    format.js
  end
end

#createObject



32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/invoice_controller.rb', line 32

def create
  @invoice = Invoice.new(params[:invoice])
  if @invoice.save
    flash[:notice] = "Invoice created"
    redirect_to invoice_path(@invoice)
  else
    render :action => 'new'
  end    
    
end

#destroyObject



52
53
54
55
56
57
58
59
60
# File 'app/controllers/invoice_controller.rb', line 52

def destroy
  if @invoice.destroy
    flash[:notice] = "Invoice deleted"
    redirect_to invoice_index_path
  else
    flash[:notice] = "Error"
    redirect_to invoice_index_path
  end
end

#editObject



29
30
# File 'app/controllers/invoice_controller.rb', line 29

def edit
end

#indexObject



11
12
13
14
15
# File 'app/controllers/invoice_controller.rb', line 11

def index
  @open_invoices = Invoice.open
  @late_invoices = Invoice.late
  @closed_invoices = Invoice.closed
end

#newObject



17
18
# File 'app/controllers/invoice_controller.rb', line 17

def new
end

#outstandingObject



70
71
72
73
74
# File 'app/controllers/invoice_controller.rb', line 70

def outstanding
  @invoice = Invoice.find_by_id(params[:invoice_id])
  @invoice ||= Invoice.find_by_id(params[:id])
  render :text => @invoice.outstanding
end

#showObject



24
25
26
27
# File 'app/controllers/invoice_controller.rb', line 24

def show
  @payments = @invoice.payments.find(:all, :order => 'applied_on DESC')
  render :layout => 'print' if params[:print]
end

#updateObject



43
44
45
46
47
48
49
50
# File 'app/controllers/invoice_controller.rb', line 43

def update
  if @invoice.update_attributes(params[:invoice])
    flash[:notice] = "Invoice saved"
    redirect_to invoice_path(@invoice)
  else
    render :action => 'edit'
  end    
end