change checkout time and free time
This commit is contained in:
@@ -78,6 +78,16 @@ class DiningFacility < ApplicationRecord
|
||||
def get_checkout_booking
|
||||
booking = self.get_current_checkout_booking
|
||||
if booking
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
free_time_min = 0
|
||||
if !lookup_checkout_time.nil?
|
||||
if lookup_checkout_time[0][0] == 'min'
|
||||
free_time_min = (lookup_checkout_time[0][1]).to_i
|
||||
else
|
||||
free_time_min = 15
|
||||
end
|
||||
end
|
||||
|
||||
now = Time.now.utc
|
||||
hr = (now.strftime("%H").to_i).to_int
|
||||
min = (now.strftime("%M").to_i).to_int
|
||||
@@ -88,7 +98,7 @@ class DiningFacility < ApplicationRecord
|
||||
checkout_at_min -= min
|
||||
if (checkout_at_hr < hr)
|
||||
return booking
|
||||
elsif (checkout_at_hr == hr && checkout_at_min <= 15)
|
||||
elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
|
||||
return booking
|
||||
else
|
||||
return nil
|
||||
@@ -103,18 +113,28 @@ class DiningFacility < ApplicationRecord
|
||||
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||
arr_booking = Array.new
|
||||
if bookings
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
free_time_min = 0
|
||||
if !lookup_checkout_time.nil?
|
||||
if lookup_checkout_time[0][0] == 'min'
|
||||
free_time_min = (lookup_checkout_time[0][1]).to_i
|
||||
else
|
||||
free_time_min = 15
|
||||
end
|
||||
end
|
||||
|
||||
bookings.each do |booking|
|
||||
now = Time.now.utc.getlocal
|
||||
now = Time.now.utc
|
||||
hr = (now.strftime("%H").to_i).to_int
|
||||
min = (now.strftime("%M").to_i).to_int
|
||||
if !booking.checkout_at.nil?
|
||||
checkout_at = booking.checkout_at.utc.getlocal
|
||||
checkout_at = booking.checkout_at.utc
|
||||
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
|
||||
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
|
||||
checkout_at_min -= min
|
||||
if (checkout_at_hr < hr)
|
||||
arr_booking.push({'table_id' => booking.dining_facility_id})
|
||||
elsif (checkout_at_hr == hr && checkout_at_min <= 15)
|
||||
elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
|
||||
arr_booking.push({'table_id' => booking.dining_facility_id})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user