inventory
This commit is contained in:
@@ -1,74 +1,98 @@
|
||||
class Inventory::StockChecksController < BaseInventoryController
|
||||
before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@check = StockCheck.new
|
||||
end
|
||||
|
||||
def create
|
||||
item_list = JSON.parse(params[:stock_item])
|
||||
reason = params[:reason]
|
||||
check = StockCheck.new
|
||||
@check = check.create(current_user, reason, item_list)
|
||||
end
|
||||
|
||||
def show
|
||||
@check = StockCheck.find(params[:id])
|
||||
end
|
||||
|
||||
def save_to_journal
|
||||
check = params[:data]
|
||||
stockCheck = StockCheck.find(check)
|
||||
stockCheck.stock_check_items.each do |item|
|
||||
StockJournal.from_stock_check(item)
|
||||
end
|
||||
end
|
||||
|
||||
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /stock_checks
|
||||
# GET /stock_checks.json
|
||||
def index
|
||||
@stock_checks = StockCheck.all
|
||||
end
|
||||
|
||||
# GET /stock_checks/1
|
||||
# GET /stock_checks/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /stock_checks/new
|
||||
def new
|
||||
@stock_check = StockCheck.new
|
||||
end
|
||||
|
||||
# GET /stock_checks/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /stock_checks
|
||||
# POST /stock_checks.json
|
||||
def create
|
||||
@stock_check = StockCheck.new(stock_check_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_check.save
|
||||
format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @stock_check }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /stock_checks/1
|
||||
# PATCH/PUT /stock_checks/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @stock_check.update(stock_check_params)
|
||||
format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @stock_check }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /stock_checks/1
|
||||
# DELETE /stock_checks/1.json
|
||||
def destroy
|
||||
@stock_check.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_check
|
||||
@stock_check = StockCheck.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def stock_check_params
|
||||
params.fetch(:stock_check, {})
|
||||
end
|
||||
# def index
|
||||
# @stock_checks = StockCheck.all
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1
|
||||
# # GET /stock_checks/1.json
|
||||
# def show
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/new
|
||||
# def new
|
||||
# @stock_check = StockCheck.new
|
||||
# end
|
||||
#
|
||||
# # GET /stock_checks/1/edit
|
||||
# def edit
|
||||
# end
|
||||
#
|
||||
# # POST /stock_checks
|
||||
# # POST /stock_checks.json
|
||||
# def create
|
||||
# @stock_check = StockCheck.new(stock_check_params)
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @stock_check.save
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
|
||||
# format.json { render :show, status: :created, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :new }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # PATCH/PUT /stock_checks/1
|
||||
# # PATCH/PUT /stock_checks/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @stock_check.update(stock_check_params)
|
||||
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @stock_check }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # DELETE /stock_checks/1
|
||||
# # DELETE /stock_checks/1.json
|
||||
# def destroy
|
||||
# @stock_check.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_stock_check
|
||||
# @stock_check = StockCheck.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def stock_check_params
|
||||
# params.fetch(:stock_check, {})
|
||||
# end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user