control order to logout
This commit is contained in:
@@ -71,7 +71,7 @@ class Api::OrdersController < Api::ApiController
|
||||
puts "WWwwWWWWWWww"
|
||||
puts sale_status
|
||||
if sale_status
|
||||
return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@@ -82,7 +82,7 @@ class Api::OrdersController < Api::ApiController
|
||||
puts "OOOOOOOOO"
|
||||
puts sale_status
|
||||
if sale_status
|
||||
return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
@@ -91,30 +91,32 @@ class Api::OrdersController < Api::ApiController
|
||||
puts "MMMMMMMM"
|
||||
puts sale_status
|
||||
if sale_status
|
||||
return false , @message = "bill requested"
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
end
|
||||
|
||||
# render json for http status code 202
|
||||
def return_json_status_with_code(code, msg, booking_id)
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
message: msg
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
booking = table.get_moved_booking
|
||||
puts booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return true
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
@@ -124,8 +126,9 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
end
|
||||
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return true
|
||||
else
|
||||
|
||||
@@ -39,6 +39,16 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def get_moved_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def get_new_booking
|
||||
# query for new
|
||||
# if status
|
||||
|
||||
@@ -54,7 +54,7 @@ class Order < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
return false, @message = "booking fail"
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user