class StockJournalsController < ApplicationController
  before_action :set_stock_journal, only: [:show, :edit, :update, :destroy]

  # GET /stock_journals
  # GET /stock_journals.json
  def index
    @stock_journals = StockJournal.all
  end

  # GET /stock_journals/1
  # GET /stock_journals/1.json
  def show
  end

  # GET /stock_journals/new
  def new
    @stock_journal = StockJournal.new
  end

  # GET /stock_journals/1/edit
  def edit
  end

  # POST /stock_journals
  # POST /stock_journals.json
  def create
    @stock_journal = StockJournal.new(stock_journal_params)

    respond_to do |format|
      if @stock_journal.save
        format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' }
        format.json { render :show, status: :created, location: @stock_journal }
      else
        format.html { render :new }
        format.json { render json: @stock_journal.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /stock_journals/1
  # PATCH/PUT /stock_journals/1.json
  def update
    respond_to do |format|
      if @stock_journal.update(stock_journal_params)
        format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully updated.' }
        format.json { render :show, status: :ok, location: @stock_journal }
      else
        format.html { render :edit }
        format.json { render json: @stock_journal.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /stock_journals/1
  # DELETE /stock_journals/1.json
  def destroy
    @stock_journal.destroy
    respond_to do |format|
      format.html { redirect_to stock_journals_url, notice: 'Stock journal was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_stock_journal
      @stock_journal = StockJournal.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def stock_journal_params
      params.fetch(:stock_journal, {})
    end
end
