update quickservice

This commit is contained in:
Aung Myo
2018-02-09 11:32:29 +06:30
parent a64fc8a4f5
commit edade3662b
9 changed files with 243 additions and 74 deletions

View File

@@ -305,29 +305,10 @@ class Order < ApplicationRecord
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
#Send to background job for processing
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
OrderQueueProcessorJob.perform_later(id, table_id)
else
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
OrderQueueProcessorJob.perform_later(id, table_id)
else
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
OrderQueueProcessorJob.perform_later(id, table_id)
end
end
end
def self.check_cup_status(status)
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end

View File

@@ -1232,6 +1232,50 @@ end
query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service")
end
def self.add_to_existing_pending_invoice(dining,sale_id)
puts sale_id
table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id)
puts existing_booking.to_json
table.bookings.each do |booking|
# if !booking.checkout_at.nil?
# existing_booking.update_attributes(checkout_at: checkout_at)
# end
if booking.sale_id.nil?
puts booking.to_json
booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved'
order = Order.find(booking_order.order_id)
order.status = 'billed'
order.order_items.each do |item|
item.order_item_status = 'billed'
end
# create sale item
saleobj = Sale.find(sale_id)
puts "saleobj"
puts saleobj.to_json
order.order_items.each do |orer_item|
saleobj.add_item (orer_item)
end
# Re-compute for add
saleobj.compute
saleobj.save
order.save
booking.save
end
booking_order = BookingOrder.where('booking_id=?',booking)
booking_order.each do |bo|
bo.booking_id = existing_booking.booking_id
bo.save
end
end
end
end
private
def generate_custom_id