Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -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,25 +8,28 @@ 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(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
|
||||
|
||||
|
||||
@@ -1,25 +1,44 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(printer_name,order_id, item_code)
|
||||
def print_order_item(oqs,order_id, item_code)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||
pdf = OrderItemPdf.new(order_item[0])
|
||||
pdf.render_file "tmp/receipt.pdf"
|
||||
self.print("tmp/receipt.pdf", printer_name)
|
||||
if oqs.print_copy
|
||||
self.print("tmp/receipt.pdf", oqs.printer_name)
|
||||
self.print("tmp/receipt.pdf", oqs.printer_name)
|
||||
else
|
||||
self.print("tmp/receipt.pdf", oqs.printer_name)
|
||||
end
|
||||
end
|
||||
|
||||
def print_order_summary(printer_name,order_id)
|
||||
def print_order_summary(oqs,order_id)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order=print_query('order_summary',order_id)
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(order)
|
||||
pdf.render_file filename
|
||||
|
||||
self.print(filename, printer_name)
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
pdf = OrderItemPdf.new(odi)
|
||||
pdf.render_file "tmp/receipt.pdf"
|
||||
if oqs.print_copy
|
||||
self.print("tmp/receipt.pdf", oqs.printer_name)
|
||||
self.print("tmp/receipt.pdf", oqs.printer_name)
|
||||
else
|
||||
self.print("tmp/receipt.pdf", oqs.printer_name)
|
||||
end
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(order)
|
||||
pdf.render_file filename
|
||||
self.print(filename, oqs.printer_name)
|
||||
end
|
||||
end
|
||||
|
||||
# Query for OQS with status
|
||||
|
||||
Reference in New Issue
Block a user