Sha256: 7c3112a23fbcfc36ac6efad02e4805de9ec65e835b080435e588a8e5009d0f11

Contents?: true

Size: 1.15 KB

Versions: 134

Compression:

Stored size: 1.15 KB

Contents

class ::IshManager::InvoicesController < IshManager::ApplicationController

  before_action :set_lists

  def index
    authorize! :index, Ish::Invoice
    @invoices = Ish::Invoice.all.includes( :payments )
  end

  def new
    authorize! :new, @invoice
  end

  def create
    @invoice = Ish::Invoice.new params[:invoice].permit!
    authorize! :create, @invoice
    if @invoice.save
      flash[:notice] = "created invoice"
    else
      flash[:alert] = "Cannot create invoice: #{@invoice.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  def update
    @invoice = Ish::Invoice.find params[:id]
    authorize! :update, @invoice
    if @invoice.update_attributes params[:invoice].permit!
      flash[:notice] = 'Success'
      redirect_to :action => 'index'
    else
      flash[:alert] = "Cannot update invoice: #{@invoice.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  #
  # private
  #
  private

  def set_lists
    @invoice_number = Ish::Invoice.order_by( :number => :desc ).first
    @invoice_number = @invoice_number ? @invoice_number.number + 1 : 1
    @new_invoice = Ish::Invoice.new :number => @invoice_number
  end

end

Version data entries

134 entries across 134 versions & 1 rubygems

Version Path
ish_manager-0.1.8.453 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.452 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.451 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.450 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.449 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.448 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.447 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.446 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.445 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.444 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.443 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.442 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.441 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.440 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.439 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.438 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.437 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.436 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.435 app/controllers/ish_manager/invoices_controller.rb
ish_manager-0.1.8.434 app/controllers/ish_manager/invoices_controller.rb