prevent order append to previous sale
This commit is contained in:
@@ -6,7 +6,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@@ -14,7 +14,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all
|
||||
@@ -27,14 +27,14 @@ class Origami::FoodCourtController < ApplicationController
|
||||
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
if dine_in[1] == '1'
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
if dine_in[1] == '1'
|
||||
@quick_service_only = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
@@ -58,38 +58,33 @@ class Origami::FoodCourtController < ApplicationController
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@sale_id = @booking.sale_id
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@order_items = Array.new
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
render "origami/addorders/detail"
|
||||
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
booking = Booking.find(params[:booking_id])
|
||||
sale = booking.sale
|
||||
if sale && sale.sale_status != 'new'
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
@cashier_type = "food_court"
|
||||
cashier_type = "food_court"
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
@@ -108,82 +103,32 @@ class Origami::FoodCourtController < ApplicationController
|
||||
}
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[: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.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
order.order_type = params[:order_type]
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[: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
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
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 }
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if(params[:sale_id][0,3] == "SAL")
|
||||
if @status && @booking && (@order.source == 'quick_service' || @order.source == 'food_court')
|
||||
if params[:sale_id]
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
if @order.table_id.to_i > 0
|
||||
@table_id = @order.table_id
|
||||
else
|
||||
@table_id = nil
|
||||
end
|
||||
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
|
||||
end
|
||||
|
||||
result = {:status=> true, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
elsif (params[:sale_id][0,3] == "BKI")
|
||||
result = {:status=> true, :data => 'OK' }
|
||||
render :json => result.to_json
|
||||
else
|
||||
result = {:status=> true, :data => nil }
|
||||
render :json => result.to_json
|
||||
end
|
||||
else
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -209,9 +154,9 @@ class Origami::FoodCourtController < ApplicationController
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_all_product()
|
||||
@product = Product.all
|
||||
@product = Product.all
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
|
||||
Reference in New Issue
Block a user