# -*- encoding : utf-8 -*-

class Admin::TvaRatesController < ApplicationController
  layout "admin"
  before_action :auth_admin

  before_action :admin_space
  
  def admin_space
    @admin_space = "preferences"
  end
  
  def index
    @tva_rates = TvaRate.order("accounting_zone_id ASC, rate ASC").all

  end

  def show
    @tva_rate = TvaRate.find(params[:id])

  end

  def new
    @tva_rate = TvaRate.new
  
  end

  def edit
    @tva_rate = TvaRate.find(params[:id])
    
  end

  def create
    @tva_rate = TvaRate.new(params.require(:tva_rate).permit!)

    if @tva_rate.save
      
    else
      render action: "new"
 
    end

  end


  def update
    @tva_rate = TvaRate.find(params[:id])


    if @tva_rate.update_attributes(params.require(:tva_rate).permit!)
      
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @tva_rate = TvaRate.find(params[:id])
    @tva_rate.destroy
    
  end
end
