update check_in_process
This commit is contained in:
@@ -25,6 +25,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
||||||
|
|
||||||
check_out_time = nil
|
check_out_time = nil
|
||||||
extra_minutes = nil
|
extra_minutes = nil
|
||||||
alert_time_min = 0
|
alert_time_min = 0
|
||||||
@@ -65,73 +66,46 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
if params[:dining_id]
|
if params[:dining_id]
|
||||||
dining_facility = DiningFacility.find(params[:dining_id])
|
dining_facility = DiningFacility.find(params[:dining_id])
|
||||||
if dining_facility.is_active && dining_facility.status == "available"
|
if dining_facility.is_active && dining_facility.status == "available"
|
||||||
if params[:checkin_time]
|
if dining_facility.current_checkin_booking.nil?
|
||||||
checkin_at = nil
|
if params[:checkin_time].present?
|
||||||
if !params[:checkin_time].empty?
|
checkin_at = Time.parse(params[:checkin_time])
|
||||||
checkin_at = Time.parse(params[:checkin_time]).utc
|
|
||||||
else
|
else
|
||||||
checkin_at = Time.now.utc
|
checkin_at = Time.now
|
||||||
end
|
end
|
||||||
|
|
||||||
if !checkin_at.nil?
|
checkout_at = nil
|
||||||
if dining_facility.check_time(checkin_at, "checkin")
|
|
||||||
booking = dining_facility.get_current_booking
|
|
||||||
if booking.nil?
|
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
|
||||||
:checkin_by=>current_login_employee.name,:checkin_at => checkin_at,:checkout_at =>nil, :booking_status => "assign", :reserved_at => nil, :reserved_by => nil })
|
|
||||||
if booking.save!
|
|
||||||
dining_facility.status = "occupied"
|
|
||||||
dining_facility.save!
|
|
||||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkin_at => booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M:%S"), :message => "Check-in success" }
|
|
||||||
else
|
|
||||||
render :json => { :status => false, :error_message => "Booking does not create successfully!" }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
render :json => { :status => false, :error_message => "Checkin time not available!" }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
render :json => { :status => false, :error_message => "Operation failed!" }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
booking = dining_facility.current_checkout_booking
|
|
||||||
if booking.nil?
|
|
||||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||||
|
today = Time.now
|
||||||
if !lookup_checkout_time.empty?
|
if !lookup_checkout_time.empty?
|
||||||
today = Time.now.utc.getlocal
|
|
||||||
checkout_at = Time.now.utc.getlocal
|
|
||||||
|
|
||||||
lookup_checkout_time.each do |checkout_time|
|
lookup_checkout_time.each do |checkout_time|
|
||||||
arr_time = checkout_time[0].split("-")
|
start_time, end_time = checkout_time[0].split("-").map{ |t| Time.parse(t.strip).strftime("%H:%M%p") }
|
||||||
start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
|
|
||||||
end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
|
|
||||||
if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time
|
if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time
|
||||||
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
|
checkout_at = checkin_at + (checkout_time[1]).to_i.minutes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if checkout_at.strftime("%Y-%m-%d %H:%M%p") >= today.strftime("%Y-%m-%d %H:%M%p")
|
booking = nil
|
||||||
# if dining_facility.type == "Table"
|
ActiveRecord::Base.transaction do
|
||||||
# type = "TableBooking"
|
booking = Booking.create({
|
||||||
# else
|
:dining_facility_id => params[:dining_id],
|
||||||
# type = "RoomBooking"
|
:type => "TableBooking",
|
||||||
# end
|
:checkin_by => current_login_employee.name,
|
||||||
|
:checkin_at => checkin_at,
|
||||||
|
:checkout_at => checkout_at,
|
||||||
|
:booking_status => "assign",
|
||||||
|
:reserved_at => checkout_at,
|
||||||
|
:reserved_by => current_login_employee.name })
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
|
||||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
|
||||||
if booking.save!
|
|
||||||
dining_facility.status = "occupied"
|
dining_facility.status = "occupied"
|
||||||
dining_facility.save!
|
dining_facility.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
|
|
||||||
unique_code = "CheckInOutPdf"
|
unique_code = "CheckInOutPdf"
|
||||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|
||||||
@@ -142,17 +116,10 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility)
|
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
render :json => { :status => true, :booking_id => booking.booking_id, :checkin_at => booking.checkin_at.strftime("%Y-%m-%d %H:%M"), :checkout_at => booking.checkout_at.strftime("%Y-%m-%d %H:%M") }
|
||||||
else
|
|
||||||
render :json => { :status => true }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
render :json => { :status => true }
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
render :json => { :status => false, :error_message => "Booking already exist!" }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
else
|
||||||
error_message = "#{dining_facility.type} is not available!"
|
error_message = "#{dining_facility.type} is not available!"
|
||||||
render :json => { :status => false, :error_message => error_message }
|
render :json => { :status => false, :error_message => error_message }
|
||||||
@@ -161,6 +128,8 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
error_message = "dining_id is required!"
|
error_message = "dining_id is required!"
|
||||||
render :json => { :status => false, :error_message => error_message }
|
render :json => { :status => false, :error_message => error_message }
|
||||||
end
|
end
|
||||||
|
rescue ActiveRecord::RecordInvalid => exception
|
||||||
|
render :json => { :status => false, :error_message => exception.message }
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_time
|
def request_time
|
||||||
|
|||||||
@@ -37,18 +37,16 @@ class Api::OrdersController < Api::ApiController
|
|||||||
@booking = table.get_booking
|
@booking = table.get_booking
|
||||||
end
|
end
|
||||||
|
|
||||||
@tax_profile = nil
|
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||||
# arr_tax = []
|
# arr_tax = []
|
||||||
|
|
||||||
# if !arr_tax.empty?
|
# if !arr_tax.empty?
|
||||||
# @tax_profile = TaxProfile.where(:id => arr_tax)
|
# @tax_profile = TaxProfile.where(:id => arr_tax)
|
||||||
# else
|
# else
|
||||||
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
# @tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@shop = Shop.current_shop
|
@shop = Shop.current_shop
|
||||||
puts "Hello world"
|
|
||||||
puts @shop.to_json
|
|
||||||
return @shop.to_json
|
return @shop.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user