This commit is contained in:
yarzar_code
2020-01-12 20:07:28 +06:30
parent 314cc507a3
commit dff2c69627
89 changed files with 492 additions and 469 deletions

View File

@@ -3,14 +3,14 @@ class Inventory::InventoryController < BaseInventoryController
def index
filter = params[:filter]
@inventory_definitions = InventoryDefinition.get_by_category(@shop,filter)
@inventory_definitions = InventoryDefinition.get_by_category(filter)
end
def show
inventory_definition_id = params[:inventory_definition_id]
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")
inventory = InventoryDefinition.find_by_id(inventory_definition_id)
@stock_journals = StockJournal.where("item_code=?",inventory.item_code).order("id DESC")
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
respond_to do |format|

View File

@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions
# GET /inventory_definitions.json
def index
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'")
@inventory_definitions = InventoryDefinition.all
end
# GET /inventory_definitions/1
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions/new
def new
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
@menus = Menu.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_and_shop_code(params[:item_code],@shop.shop_code)
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new
@@ -84,7 +84,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# DELETE /inventory_definitions/1
# DELETE /inventory_definitions/1.json
def destroy
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
inventory = InventoryDefinition.find_by_id(params[:id])
@inventory_definition.destroy
respond_to do |format|
format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
@@ -107,7 +107,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
private
# Use callbacks to share common setup or constraints between actions.
def set_inventory_definition
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
@inventory_definition = InventoryDefinition.find_by_id(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -8,7 +8,6 @@ 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?
@@ -24,7 +23,7 @@ class Inventory::StockChecksController < BaseInventoryController
end
def show
@check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code)
@check = StockCheck.find_by_id(params[:id])
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])