update order for oqs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class OrderQueueProcessorJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(order_id)
|
||||
def perform(order_id, table_id)
|
||||
# Do something later
|
||||
#Order ID
|
||||
order = Order.find(order_id)
|
||||
@@ -10,7 +10,7 @@ class OrderQueueProcessorJob < ApplicationJob
|
||||
#Execute orders and send to order stations
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order)
|
||||
oqs.process_order(order, table_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -199,7 +199,7 @@ class Order < ApplicationRecord
|
||||
#Process order items and send to order queue
|
||||
def process_order_queue
|
||||
#Send to background job for processing
|
||||
OrderQueueProcessorJob.perform_later(self.id)
|
||||
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -8,26 +8,30 @@ class OrderQueueStation < ApplicationRecord
|
||||
|
||||
scope :active, -> {where(is_active: true)}
|
||||
|
||||
def process_order (order)
|
||||
def process_order (order, table_id)
|
||||
oqs_stations = OrderQueueStation.active
|
||||
dining=DiningFacility.find_by_name(table_id)
|
||||
oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
|
||||
|
||||
order_items = order.order_items
|
||||
#Assign OQS id to order Items
|
||||
oqs_stations.each do |oqs|
|
||||
#Get List of items -
|
||||
pq_items = JSON.parse(oqs.processing_items)
|
||||
pq_items = JSON.parse(oqs.processing_items)
|
||||
|
||||
#Loop through the processing items
|
||||
pq_items.each do |pq_item|
|
||||
#Processing through the looping items
|
||||
order_items.each do |order_item|
|
||||
if (pq_item == order_item.item_code)
|
||||
#Same Order_items can appear in two location.
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
if oqs.id == oqpbz.order_queue_station_id
|
||||
#Loop through the processing items
|
||||
pq_items.each do |pq_item|
|
||||
#Processing through the looping items
|
||||
order_items.each do |order_item|
|
||||
if (pq_item == order_item.item_code)
|
||||
#Same Order_items can appear in two location.
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#Print OQS where printing is require
|
||||
|
||||
Reference in New Issue
Block a user