foodcourt apis for app

This commit is contained in:
Thein Lin Kyaw
2022-07-08 16:06:12 +06:30
parent 7485486868
commit 063345eae3
37 changed files with 785 additions and 171 deletions

View File

@@ -1,14 +1,42 @@
class Api::BookingsController < Api::ApiController
# skip_before_action :authenticate
skip_before_action :authenticate
#Show customer by ID
def index
@customer = Customer.find_by(params[:id])
def index
@bookings = Booking.all
if params[:shift_id].present?
@bookings = @bookings.includes(:dining_facility, :sale, orders: :order_items)
.where()
end
end
def show
booking = Booking.find(params[:id])
if booking.dining_facility_id.to_i == params[:table_id].to_i
@booking = booking
@booking = Booking.find(params[:id])
end
def pending
@bookings = Booking.where(checkout_at: nil)
end
def billed
if shift = ShiftSale.current_shift
@bookings = Booking.includes(:sale)
.where(sales: {shift_sale_id: shift.id})
.where.not(sales: {sale_status: ['completed', 'void']})
end
end
def completed
if shift = ShiftSale.current_shift
@bookings = Booking.includes(:sale)
.where(sales: {shift_sale_id: shift.id, sale_status: ['completed']})
end
end
def void
if shift = ShiftSale.current_shift
@bookings = Booking.includes(:sale)
.where(sales: {shift_sale_id: shift.id, sale_status: ['void']})
end
end
end