add void and cancel on pending bill
This commit is contained in:
@@ -292,4 +292,34 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
booking.save!
|
||||
end
|
||||
end
|
||||
|
||||
def cancel_order
|
||||
order_id = params[:order_id]
|
||||
|
||||
if order_id.present?
|
||||
order = Order.find(order_id)
|
||||
booking = order.booking
|
||||
if order && booking
|
||||
if order.order_items.present?
|
||||
order.order_items.update_all(order_item_status: 'cancelled')
|
||||
end
|
||||
order.status = 'cancelled'
|
||||
order.save
|
||||
booking.booking_status = 'cancelled'
|
||||
booking.save
|
||||
respond_to do |format|
|
||||
format.json { render :json => { :status => true, :order_id => order_id } }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json { render :json => { :status => false, :error_message => "Order not found" } }
|
||||
end
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json { render :json => { :status => false, :error_message => "OrderID does not exist" } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user