prevent order append to previous sale
This commit is contained in:
@@ -66,11 +66,22 @@ class Api::OrdersController < Api::ApiController
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
end
|
||||
if params[:table_id].present?
|
||||
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
booking = table.get_current_booking
|
||||
end
|
||||
end
|
||||
|
||||
#for extratime
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
params[:order_items].each { |i|
|
||||
params[:order_items].each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
@@ -82,8 +93,7 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
}
|
||||
#end extra time
|
||||
puts params[:order_items]
|
||||
puts "ORDER ITEMS"
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@@ -98,51 +108,26 @@ class Api::OrdersController < Api::ApiController
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
#Create Table Booking or Room Booking
|
||||
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if @status && @booking
|
||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
type = 'order'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
|
||||
end
|
||||
# # for parallel order
|
||||
@status, @booking = @order.generate
|
||||
if @status && @booking
|
||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
type = 'order'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
end
|
||||
# # for parallel order
|
||||
# remoteIP = ""
|
||||
# begin
|
||||
# @status, @booking = @order.generate
|
||||
@@ -211,12 +196,9 @@ class Api::OrdersController < Api::ApiController
|
||||
def checkin_checkout_time(booking_id)
|
||||
status = true
|
||||
if !booking_id.nil?
|
||||
today = Time.now.utc
|
||||
booking = Booking.find(booking_id)
|
||||
if !booking.nil?
|
||||
if !booking.checkout_at.nil?
|
||||
checkout_time = booking.checkout_at.utc
|
||||
if checkout_time <= today
|
||||
if booking = Booking.find(booking_id)
|
||||
if booking.checkout_at.present?
|
||||
if booking.checkout_at.utc <= Time.now.utc
|
||||
status = false
|
||||
end
|
||||
end
|
||||
@@ -256,11 +238,11 @@ class Api::OrdersController < Api::ApiController
|
||||
oqs = assign_item.order_queue_station
|
||||
|
||||
printer = PrintSetting.all
|
||||
|
||||
|
||||
unique_code="OrderItemPdf"
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'OrderItemPdf'
|
||||
if printer_setting.unique_code == 'OrderItemPdf'
|
||||
unique_code="OrderItemPdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
@@ -272,9 +254,9 @@ class Api::OrdersController < Api::ApiController
|
||||
unique_code="OrderItemCustomisePdf"
|
||||
elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf'
|
||||
unique_code="OrderSetItemCustomisePdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
@@ -301,6 +283,5 @@ class Api::OrdersController < Api::ApiController
|
||||
|
||||
return from
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user