Class: InvoiceController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- InvoiceController
- Defined in:
- app/controllers/invoice_controller.rb
Instance Method Summary collapse
- #autocreate ⇒ Object
- #autofill ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #outstanding ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#autocreate ⇒ Object
20 21 22 |
# File 'app/controllers/invoice_controller.rb', line 20 def autocreate @autofill = Autofill.new end |
#autofill ⇒ Object
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 |
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
29 30 |
# File 'app/controllers/invoice_controller.rb', line 29 def edit end |
#index ⇒ Object
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 |
#new ⇒ Object
17 18 |
# File 'app/controllers/invoice_controller.rb', line 17 def new end |
#outstanding ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |