Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -9,15 +9,17 @@ class Api::BillController < Api::ApiController
|
||||
#create Bill by Booking ID
|
||||
if (params[:booking_id])
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee)
|
||||
else
|
||||
@status = true
|
||||
@sale_id = booking.sale_id
|
||||
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee)
|
||||
else
|
||||
@status = true
|
||||
@sale_id = booking.sale_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elsif (params[:order_id])
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee)
|
||||
|
||||
@@ -6,11 +6,9 @@ class Api::BookingsController < Api::ApiController
|
||||
end
|
||||
|
||||
def show
|
||||
@booking = Booking.find(params[:id])
|
||||
booking = Booking.find(params[:id])
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
@booking = booking
|
||||
end
|
||||
end
|
||||
|
||||
# private
|
||||
# def Bookings_params
|
||||
# params.permit(:id, :order_id)
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -7,11 +7,45 @@ class Api::OrdersController < Api::ApiController
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
def get_order
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
# API - This api will retrive current booking for android with table or room id
|
||||
def view_orders
|
||||
booking_id = params[:booking_id]
|
||||
table_id = params[:table_id]
|
||||
if Booking.exists?(booking_id)
|
||||
booking = Booking.find(booking_id)
|
||||
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == table_id.to_i
|
||||
@booking = booking
|
||||
else
|
||||
table = DiningFacility.find(table_id)
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == table_id.to_i
|
||||
@booking = booking
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
puts "only table"
|
||||
table = DiningFacility.find(table_id)
|
||||
booking = table.get_current_booking
|
||||
puts booking
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == table_id.to_i
|
||||
@booking = booking
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API allow new order creation
|
||||
# Input Params
|
||||
@@ -38,18 +72,50 @@ class Api::OrdersController < Api::ApiController
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
puts "booking sale is null"
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
# booking.table id not equal current table
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
puts "booking sale is null"
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
#no booking id
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
Reference in New Issue
Block a user