fixed invetory

This commit is contained in:
NyanLinHtut
2019-09-25 11:54:54 +06:30
parent e558746e26
commit 9d330bb28c
13 changed files with 402 additions and 146 deletions

View File

@@ -21,6 +21,8 @@ class Inventory::InventoryController < BaseInventoryController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail

View File

@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions/new
def new
@menus = Menu.all
@menus = Menu.all
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
@inventory_definition = InventoryDefinition.new
end
@@ -28,7 +28,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
def create
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new
@inventory_definition.item_code = params[:item_code]
@inventory_definition.min_order_level = params[:min_order_level]
@@ -83,11 +83,24 @@ 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_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
inventory = InventoryDefinition.find(params[:id])
StockJournal.delete_stock_journal(inventory.item_code)
StockCheckItem.delete_stock_check_item(inventory.item_code)
if !inventory.nil?
inventory.destroy
flash[:message] = 'Inventory was successfully destroyed.'
render :json => {:status=> "Success", :url => inventory_url }.to_json
else
flash[:error] = 'Inventory could not destroy! This record is using in somewhere.'
render :json => {:status=> "Error", :url => inventory_url }.to_json
end
end
#Shop Name in Navbor