fix foodcourt sales transaction
This commit is contained in:
@@ -64,7 +64,6 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
@booking_id =@booking.booking_id
|
||||
@order_id =@booking.order_id
|
||||
@sale_data = Sale.find_by_sale_id(@booking.sale_id)
|
||||
|
||||
elsif params[:pending_id]
|
||||
id = params[:pending_id]
|
||||
if id.include? "SAL"
|
||||
@@ -166,40 +165,46 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
}
|
||||
|
||||
# begin
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
order.order_type = params[:order_type]
|
||||
# order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
order.items = items_arr
|
||||
order.guest = params[:guest_info]
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
order.waiters = current_login_employee.name
|
||||
order.employee_name = current_login_employee.name
|
||||
Order.transaction do
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
order.order_type = params[:order_type]
|
||||
# order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
order.items = items_arr
|
||||
order.guest = params[:guest_info]
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
order.waiters = current_login_employee.name
|
||||
order.employee_name = current_login_employee.name
|
||||
|
||||
order.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
order.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
|
||||
order.new_booking = false
|
||||
order.booking_id = booking.booking_id
|
||||
order.new_booking = false
|
||||
order.booking_id = booking.booking_id
|
||||
|
||||
if order.generate
|
||||
if sale
|
||||
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||
render :json => { :status => true, :data => sale }
|
||||
if order.generate
|
||||
if sale
|
||||
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||
render :json => { :status => true, :data => sale }
|
||||
else
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
end
|
||||
else
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
render :json => { :status => false }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false }
|
||||
end
|
||||
end
|
||||
|
||||
def request_bill
|
||||
sale_data =[]
|
||||
customer_id = params[:customer_id]
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = params[:order_id] # order_id
|
||||
order_id = params[:order_id]
|
||||
order = Order.find(order_id)
|
||||
booking = order.booking
|
||||
if Customer.exists?(customer_id: customer_id)
|
||||
booking.orders.update_all(customer_id: customer_id)
|
||||
end
|
||||
if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil?
|
||||
@status = false
|
||||
@error_message = "Operation failed, Could not request bill!"
|
||||
@@ -295,7 +300,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
|
||||
def cancel_order
|
||||
order_id = params[:order_id]
|
||||
|
||||
|
||||
if order_id.present?
|
||||
order = Order.find(order_id)
|
||||
booking = order.booking
|
||||
@@ -321,5 +326,5 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user