update remove job from cable and cup control in print

This commit is contained in:
Aung Myo
2018-02-01 15:30:30 +06:30
parent f608aa8516
commit 9efd54e68b
8 changed files with 110 additions and 12 deletions

View File

@@ -46,7 +46,8 @@ class Api::BillController < Api::ApiController
Promotion.promo_activate(@sale)
BillBroadcastJob.perform_later(table)
#BillBroadcastJob.perform_later(table)
ActionCable.server.broadcast "bill_channel",table: table
else
@status = false
@error_message = "No Current Open Shift"

View File

@@ -5,7 +5,8 @@ class Api::CallWaitersController < ActionController::API
@table_id = params[:dining_id]
@time = params[:time]
@table = DiningFacility.find(@table_id)
CallWaiterJob.perform_later(@table,@time)
# CallWaiterJob.perform_later(@table,@time)
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time
# get printer info
@shop = Shop::ShopDetail

View File

@@ -155,6 +155,14 @@ class DiningFacility < ApplicationRecord
def self.check_in_booking(table_id)
table = DiningFacility.find(table_id)
#Send to background job for processing
CheckInBookingJob.perform_later(table)
# CheckInBookingJob.perform_later(table)
ActionCable.server.broadcast "check_in_booking_channel",table: table
end
def self.checkin_time
table = DiningFacility.get_checkin_booking
if table.length > 0
ActionCable.server.broadcast "checkin_channel",table: table
end
end
end

View File

@@ -279,6 +279,16 @@ class Order < ApplicationRecord
def process_order_queue
#Send to background job for processing
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# order = Order.find(order_id)
# #Execute orders and send to order stations
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, table_id)
# end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
@@ -287,7 +297,8 @@ class Order < ApplicationRecord
table = DiningFacility.find(booking.dining_facility_id)
type = 'order'
#Send to background job for processing
OrderBroadcastJob.perform_later(table,type)
# OrderBroadcastJob.perform_later(table,type)
ActionCable.server.broadcast "order_channel",table: table,type:type
end
#Origami: Cashier : to view order Table

View File

@@ -123,9 +123,25 @@ class OrderQueueStation < ApplicationRecord
end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
else
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
end
end
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# update print status for order items
ai.print_status=true
@@ -159,8 +175,23 @@ class OrderQueueStation < ApplicationRecord
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
else
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
end
end
# update print status for completed same order items
assigned_order_item.each do |ai|
@@ -168,4 +199,12 @@ class OrderQueueStation < ApplicationRecord
ai.save
end
end
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
end

View File

@@ -128,7 +128,9 @@ class Sale < ApplicationRecord
booking.checkout_by = requested_by.name
booking.save
InventoryJob.perform_now(self.id)
# InventoryJob.perform_now(self.id)
saleObj = Sale.find(self.id)
InventoryDefinition.calculate_product_count(saleObj)
return true, self.id
end
@@ -137,6 +139,41 @@ class Sale < ApplicationRecord
end
#fOR Quick Service pay and create
def self.request_bill(order,current_user,current_login_employee)
@sale = Sale.new
sale_order=SaleOrder.new
if shift = ShiftSale.current_open_shift(current_user.id)
order_id = order.order_id # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
# puts "current_login_employee"
# puts current_login_employee.name
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
# Bind shift sale id to sale
@sale_data.shift_sale_id = shift.id
@sale_data.save
# Promotion Activation
Promotion.promo_activate(@sale)
@status = true
return @status, @sale
else
@status = false
@message = "No Current Open Shift for This Employee"
end
end
#This is when spilt bill is request - then we cannot link order to invoice
#Cos there will be multiple orders - and items are spilt from there.
#Unless order is spilt by then it is possible.

View File

@@ -335,7 +335,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
sale_audit = SaleAudit.record_paymal(sObj.sale_id, remark, 1)
if !response.nil?
if response["status"] == true
@@ -408,7 +408,8 @@ class SalePayment < ApplicationRecord
type = 'payment'
#Send to background job for processing
OrderBroadcastJob.perform_later(table,type)
# OrderBroadcastJob.perform_later(table,type)
ActionCable.server.broadcast "order_channel",table: table,type:type
end
end

View File

@@ -11,5 +11,5 @@ every 30.minutes do
end
every 1.minutes do
runner "CheckinJob.perform"
runner "DiningFacility.checkin_time"
end