check no order
This commit is contained in:
@@ -11,6 +11,7 @@ class Api::BillController < Api::ApiController
|
|||||||
table = 0
|
table = 0
|
||||||
if (params[:booking_id])
|
if (params[:booking_id])
|
||||||
booking = Booking.find(params[:booking_id])
|
booking = Booking.find(params[:booking_id])
|
||||||
|
if booking.booking_orders.count > 0
|
||||||
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "Operation failed, Could not request bill!"
|
@error_message = "Operation failed, Could not request bill!"
|
||||||
@@ -51,6 +52,10 @@ class Api::BillController < Api::ApiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@status = false
|
||||||
|
@error_message = "There is no order for '#{params[:booking_id]}'"
|
||||||
|
end
|
||||||
elsif (params[:order_id])
|
elsif (params[:order_id])
|
||||||
order = Order.find(params[:order_id])
|
order = Order.find(params[:order_id])
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ if (@booking)
|
|||||||
json.remark item.remark
|
json.remark item.remark
|
||||||
json.item_status item.order_item_status
|
json.item_status item.order_item_status
|
||||||
@total_amount = @total_amount + (item.price * item.qty)
|
@total_amount = @total_amount + (item.price * item.qty)
|
||||||
|
else
|
||||||
|
json.success false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
json.sub_total @total_amount
|
json.sub_total @total_amount
|
||||||
|
|||||||
Reference in New Issue
Block a user