shop code
This commit is contained in:
@@ -3,16 +3,14 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(filter)
|
||||
@inventory_definitions = InventoryDefinition.get_by_category(@shop,filter)
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||
|
||||
@stock_journals = StockJournal.where(item_code: inventory.item_code).order("id DESC")
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(inventory_definition_id,@shop.shop_code)
|
||||
@stock_journals = StockJournal.where("item_code=? and shop_code='#{@shop.shop_code}'",inventory.item_code).order("id DESC")
|
||||
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
|
||||
|
||||
respond_to do |format|
|
||||
@@ -20,12 +18,4 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# GET /inventory_definitions
|
||||
# GET /inventory_definitions.json
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.all
|
||||
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
# GET /inventory_definitions/1
|
||||
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
|
||||
# GET /inventory_definitions/new
|
||||
def new
|
||||
@menus = Menu.all
|
||||
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
end
|
||||
@@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code)
|
||||
if inventory.nil?
|
||||
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
@@ -39,6 +39,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
@inventory_definition.min_order_level = params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.shop_code = @shop.shop_code
|
||||
@inventory_definition.created_by = current_user.id
|
||||
if @inventory_definition.save
|
||||
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
|
||||
@@ -83,16 +84,16 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# DELETE /inventory_definitions/1
|
||||
# DELETE /inventory_definitions/1.json
|
||||
def destroy
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
@inventory_definition.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
|
||||
inventory = InventoryDefinition.find(params[:id])
|
||||
StockJournal.delete_stock_journal(inventory.item_code)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code)
|
||||
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
StockJournal.delete_stock_journal(inventory.item_code,@shop)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code,@shop)
|
||||
if !inventory.nil?
|
||||
inventory.destroy
|
||||
flash[:message] = 'Inventory was successfully destroyed.'
|
||||
@@ -103,16 +104,10 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_inventory_definition
|
||||
@inventory_definition = InventoryDefinition.find(params[:id])
|
||||
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
@@ -25,7 +25,6 @@ class Inventory::StockCheckItemsController < BaseInventoryController
|
||||
# POST /stock_check_items.json
|
||||
def create
|
||||
@stock_check_item = StockCheckItem.new(stock_check_item_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @stock_check_item.save
|
||||
format.html { redirect_to inventory_stock_checks_path, notice: 'Stock check item was successfully created.' }
|
||||
@@ -61,12 +60,6 @@ class Inventory::StockCheckItemsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_check_item
|
||||
|
||||
@@ -8,19 +8,23 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.where("inventory_definitions.shop_code='#{@shop.shop_code}'")
|
||||
.group("mi.menu_category_id")
|
||||
.order("mi.menu_category_id desc")
|
||||
unless !@category.nil?
|
||||
@category_id =@category[0].id
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
item_list = JSON.parse(params[:stock_item])
|
||||
reason = params[:reason]
|
||||
check = StockCheck.new
|
||||
@check = check.create(current_user, reason, item_list)
|
||||
@check = check.create(current_user, reason, item_list,@shop)
|
||||
end
|
||||
|
||||
def show
|
||||
@check = StockCheck.find(params[:id])
|
||||
@check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
|
||||
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])
|
||||
|
||||
@@ -28,31 +32,31 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
|
||||
def save_to_journal
|
||||
check = params[:data]
|
||||
stockCheck = StockCheck.find(check)
|
||||
stockCheck = StockCheck.find_by_id_and_shop_code(check,@shop.shop_code)
|
||||
stockCheck.stock_check_items.each do |item|
|
||||
StockJournal.from_stock_check(item)
|
||||
StockJournal.from_stock_check(item,@shop)
|
||||
end
|
||||
end
|
||||
|
||||
def print_stock_check
|
||||
stock_id = params[:stock_check_id] # sale_id
|
||||
stockcheck = StockCheck.find(stock_id)
|
||||
stockcheck = StockCheck.find_by_id_and_shop_code(stock_id,@shop.shop_code)
|
||||
stockcheck_items = stockcheck.stock_check_items
|
||||
member_info = nil
|
||||
unique_code = 'StockCheckPdf'
|
||||
|
||||
shop_details = current_shop
|
||||
checker = Employee.find(stockcheck.check_by)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
checker = Employee.find_by_id_and_shop_code(stockcheck.check_by,@shop.shop_code)
|
||||
print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
||||
if !print_settings.nil?
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
|
||||
|
||||
#Pull this menu
|
||||
@menu_category = InventoryDefinition.search_by_category(params[:id])
|
||||
puts @menu_category.to_json
|
||||
|
||||
@@ -25,7 +25,7 @@ class StockJournalsController < ApplicationController
|
||||
# POST /stock_journals.json
|
||||
def create
|
||||
@stock_journal = StockJournal.new(stock_journal_params)
|
||||
|
||||
@stock_journal.shop_code = @shop.shop_code
|
||||
respond_to do |format|
|
||||
if @stock_journal.save
|
||||
format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' }
|
||||
@@ -61,12 +61,6 @@ class StockJournalsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_journal
|
||||
|
||||
Reference in New Issue
Block a user