Files
sx-fc/app/controllers/api/bookings_controller.rb
2023-10-17 16:52:12 +06:30

43 lines
1014 B
Ruby
Executable File

class Api::BookingsController < Api::ApiController
# skip_before_action :authenticate
#Show customer by 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])
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