conflic data
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -278,16 +278,42 @@ 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, self.table_id)
|
||||
end
|
||||
|
||||
cup_status = `#{"sudo service cups status"}`
|
||||
print_status = check_cup_status(cup_status)
|
||||
|
||||
if print_status
|
||||
OrderQueueProcessorJob.perform_later(self.id, self.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(self.id, self.table_id)
|
||||
else
|
||||
msg = ' Print Error ! Please contact to service'
|
||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
|
||||
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
|
||||
end
|
||||
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
|
||||
|
||||
#send order items and send to order queue
|
||||
def send_order_broadcast(booking)
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, options="")
|
||||
def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, before_updated_qty="", options="")
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
@@ -14,7 +14,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
# check for item not to show
|
||||
# if order_item[0].price != 0
|
||||
@@ -22,15 +22,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
else
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
pdf = OrderSetItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderSetItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
else
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -52,7 +52,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
# Query for per order
|
||||
def print_order_summary(print_settings,oqs, order_id, order_items, print_status)
|
||||
def print_order_summary(print_settings,oqs, order_id, order_items, print_status, before_updated_qty="", options="")
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
@@ -76,20 +76,20 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
# check for item not to show
|
||||
#if odi.price != 0
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
pdf = OrderSetItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderSetItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -109,20 +109,20 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_summary_slim|
|
||||
if order_summary_slim[0] == 'OrderSlimPdf'
|
||||
if order_summary_slim[1] == '1'
|
||||
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
elsif order_summary_slim[0] == 'OrderSetPdf'
|
||||
if order_summary_slim[1] == '1'
|
||||
pdf = OrderSummarySetPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf = OrderSummarySetPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -143,7 +143,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
# Print for orders in booking
|
||||
def print_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||
def print_booking_summary(print_settings,oqs, booking_id, print_status,before_updated_qty="")
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
@@ -162,20 +162,20 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
# check for item not to show
|
||||
#if odi.price != 0
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
|
||||
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
pdf = OrderSetItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
|
||||
pdf = OrderSetItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -198,20 +198,20 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_summary_slim|
|
||||
if order_summary_slim[0] == 'OrderSlimPdf'
|
||||
if order_summary_slim[1] == '1'
|
||||
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
elsif order_summary_slim[0] == 'OrderSetPdf'
|
||||
if order_summary_slim[1] == '1'
|
||||
pdf = OrderSummarySetPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf = OrderSummarySetPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
||||
else
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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.
|
||||
@@ -706,7 +743,7 @@ def self.get_item_query()
|
||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
||||
"i.remark as status_type,"+
|
||||
" i.unit_price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||
" mii.price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id ")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
|
||||
@@ -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
|
||||
@@ -398,6 +398,7 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
else
|
||||
status = false
|
||||
sale_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -408,7 +409,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user