check no order

This commit is contained in:
phyusin
2018-11-28 11:29:43 +06:30
parent b750547066
commit 2dd940cc2e
2 changed files with 42 additions and 36 deletions

View File

@@ -11,6 +11,7 @@ class Api::BillController < Api::ApiController
table = 0
if (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?
@status = false
@error_message = "Operation failed, Could not request bill!"
@@ -51,6 +52,10 @@ class Api::BillController < Api::ApiController
end
end
end
else
@status = false
@error_message = "There is no order for '#{params[:booking_id]}'"
end
elsif (params[:order_id])
order = Order.find(params[:order_id])
@sale = Sale.new

View File

@@ -37,8 +37,9 @@ if (@booking)
json.remark item.remark
json.item_status item.order_item_status
@total_amount = @total_amount + (item.price * item.qty)
else
json.success false
end
end
json.sub_total @total_amount