update print pay in qs

This commit is contained in:
Aung Myo
2018-02-21 12:34:03 +06:30
parent 4ebe353182
commit 4455b03e8a
6 changed files with 73 additions and 54 deletions

View File

@@ -309,9 +309,9 @@ class Order < ApplicationRecord
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
def self.pay_process_order_queue(id,table_id,sale_id=nil)
#Send to background job for processing
OrderQueueProcessorJob.perform_later(id, table_id)
OrderQueueProcessorJob.perform_later(id, table_id,sale_id)
end
def check_cup_status(status)

View File

@@ -13,46 +13,22 @@ class OrderQueueStation < ApplicationRecord
# validations
validates_presence_of :station_name, :printer_name
def process_order (order, table_id)
def process_order (order, table_id,sale_id=nil)
oqs_stations = OrderQueueStation.active
dining=DiningFacility.find(table_id)
# oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
order_items = order.order_items
# get dining
booking = Booking.find_by_dining_facility_id(dining.id)
#Assign OQS id to order Items
# oqs_stations.each do |oqs|
# is_auto_printed = false
# oqs_order_items = []
# #Get List of 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)
# # if oqs.id == oqpbz.order_queue_station_id
# # #Same Order_items can appear in two location.
# # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# # else
# if (order_item.price != 0)
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# oqs_order_items.push(order_item)
# end
# # end
# end
# end
# end
if table_id > 0
# get dining
dining=DiningFacility.find(table_id)
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
booking = Booking.find_by_dining_facility_id(dining.id)
# ToDo per item per printer
OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").find_each do |oqpbz|
oqs_by_zones.each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
@@ -86,17 +62,51 @@ class OrderQueueStation < ApplicationRecord
end
end
end
# if oqs.id == oqpbz.order_queue_station_id
# # Auto Printing
# if oqs.auto_print
# if oqs_order_items.length > 0
# print_slip(oqs, order, oqs_order_items)
# is_auto_printed = true
# end
# end
# end
end
# end
end
else
# get dining
sale = Sale.find(sale_id).shift_sale_id
terminal_by_zones = CashierTerminalByZones.where("cashier_terminal_id=#{shift.cashier_terminal_id}")
# ToDo per item per printer
terminal_by_zones.each do |tbz|
OrderQueueProcessByZone.where("zone_id=#{tbz.zone_id}").find_each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of 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)
# if oqs.id == oqpbz.order_queue_station_id
# #Same Order_items can appear in two location.
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
# end
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
end
end #end else
end
private