change stock check report and some structure
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
class Inventory::InventoryController < BaseInventoryController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@products = InventoryDefinition.all.active.order('created_at desc')
|
||||
end
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
(CASE WHEN sj.credit IS NULL THEN '-' ELSE sj.credit END) as credit,
|
||||
(CASE WHEN sj.debit IS NULL THEN '-' ELSE sj.debit END) as debit,
|
||||
(CASE WHEN sj.balance IS NULL THEN '-' ELSE sj.balance END) as balance")
|
||||
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
|
||||
.where("(CASE WHEN sj.balance > 0 THEN sj.balance=(SELECT MIN(balance) FROM stock_journals WHERE stock_journals.item_code = inventory_definitions.item_code ORDER BY created_at DESC) ELSE 1 END)")
|
||||
.group("inventory_definitions.item_code")
|
||||
.order("(CASE WHEN sj.balance > 0 THEN MIN(sj.balance) ELSE NULL END )")
|
||||
|
||||
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)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
|
||||
@@ -24,7 +24,14 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
|
||||
if inventory.nil?
|
||||
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
else
|
||||
@inventory_definition = InventoryDefinition.find(inventory.id)
|
||||
@inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.created_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @inventory_definition.save
|
||||
|
||||
@@ -26,15 +26,16 @@ class Origami::SalesController < BaseOrigamiController
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
tax_type = params[:tax_type]
|
||||
sale_data = []
|
||||
table = DiningFacility.find(dining)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
table.bookings.each do |booking|
|
||||
# if !booking.checkout_at.nil?
|
||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
||||
# end
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
@@ -49,6 +50,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
if !orer_item.set_menu_items.nil?
|
||||
saleobj.add_sub_item(orer_item.set_menu_items)
|
||||
end
|
||||
sale_data.push(orer_item)
|
||||
end
|
||||
|
||||
# Re-compute for add
|
||||
@@ -58,7 +60,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
booking.save
|
||||
|
||||
order_array.push(order.order_id)
|
||||
|
||||
|
||||
end
|
||||
|
||||
receipt_no = Sale.find(sale_id).receipt_no
|
||||
@@ -75,6 +77,10 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
if !sale_data.empty?
|
||||
# InventoryJob.perform_now(self.id)
|
||||
InventoryDefinition.calculate_product_count(nil,sale_data)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user