prevent order append to previous sale
This commit is contained in:
@@ -66,11 +66,22 @@ class Api::OrdersController < Api::ApiController
|
|||||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||||
|
|
||||||
if checkin_checkout_time(params[:booking_id])
|
if checkin_checkout_time(params[:booking_id])
|
||||||
|
|
||||||
|
if params[:booking_id].present?
|
||||||
|
booking = Booking.find(params[:booking_id])
|
||||||
|
end
|
||||||
|
if params[:table_id].present?
|
||||||
|
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||||
|
table = DiningFacility.find(params[:table_id])
|
||||||
|
booking = table.get_current_booking
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#for extratime
|
#for extratime
|
||||||
is_extra_time = false
|
is_extra_time = false
|
||||||
extra_time = ''
|
extra_time = ''
|
||||||
|
|
||||||
params[:order_items].each { |i|
|
params[:order_items].each { |i|
|
||||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||||
if i["item_instance_code"].include? "ext"
|
if i["item_instance_code"].include? "ext"
|
||||||
is_extra_time = true
|
is_extra_time = true
|
||||||
@@ -82,8 +93,7 @@ class Api::OrdersController < Api::ApiController
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
#end extra time
|
#end extra time
|
||||||
puts params[:order_items]
|
|
||||||
puts "ORDER ITEMS"
|
|
||||||
# begin
|
# begin
|
||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
@@ -98,51 +108,26 @@ class Api::OrdersController < Api::ApiController
|
|||||||
|
|
||||||
@order.is_extra_time = is_extra_time
|
@order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = 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 booking
|
|
||||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
|
||||||
if !booking.sale_id.nil?
|
|
||||||
sale_status = check_order_with_booking(booking)
|
|
||||||
|
|
||||||
if sale_status
|
#Create Table Booking or Room Booking
|
||||||
return return_json_status_with_code(400, "bill requested")
|
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||||
end
|
@order.new_booking = true
|
||||||
else
|
else
|
||||||
@order.new_booking = false
|
@order.new_booking = false
|
||||||
@order.booking_id = params[:booking_id]
|
@order.booking_id = booking.booking_id
|
||||||
end
|
end
|
||||||
else
|
|
||||||
sale_status = check_order_with_table(params[:table_id])
|
|
||||||
|
|
||||||
if sale_status
|
@status, @booking = @order.generate
|
||||||
return return_json_status_with_code(400, "bill requested")
|
if @status && @booking
|
||||||
end
|
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
end
|
end
|
||||||
end #booking exists
|
if @order.table_id.to_i > 0
|
||||||
else
|
table = DiningFacility.find(@booking.dining_facility_id)
|
||||||
sale_status = check_order_with_table(params[:table_id])
|
type = 'order'
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
if sale_status
|
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||||
# return false , @message = "bill requested"
|
end
|
||||||
return return_json_status_with_code(400, "bill requested")
|
# # for parallel order
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
|
||||||
if @status && @booking
|
|
||||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
|
||||||
end
|
|
||||||
if @order.table_id.to_i > 0
|
|
||||||
table = DiningFacility.find(@booking.dining_facility_id)
|
|
||||||
type = 'order'
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
|
||||||
|
|
||||||
end
|
|
||||||
# # for parallel order
|
|
||||||
# remoteIP = ""
|
# remoteIP = ""
|
||||||
# begin
|
# begin
|
||||||
# @status, @booking = @order.generate
|
# @status, @booking = @order.generate
|
||||||
@@ -211,12 +196,9 @@ class Api::OrdersController < Api::ApiController
|
|||||||
def checkin_checkout_time(booking_id)
|
def checkin_checkout_time(booking_id)
|
||||||
status = true
|
status = true
|
||||||
if !booking_id.nil?
|
if !booking_id.nil?
|
||||||
today = Time.now.utc
|
if booking = Booking.find(booking_id)
|
||||||
booking = Booking.find(booking_id)
|
if booking.checkout_at.present?
|
||||||
if !booking.nil?
|
if booking.checkout_at.utc <= Time.now.utc
|
||||||
if !booking.checkout_at.nil?
|
|
||||||
checkout_time = booking.checkout_at.utc
|
|
||||||
if checkout_time <= today
|
|
||||||
status = false
|
status = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -256,11 +238,11 @@ class Api::OrdersController < Api::ApiController
|
|||||||
oqs = assign_item.order_queue_station
|
oqs = assign_item.order_queue_station
|
||||||
|
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.all
|
||||||
|
|
||||||
unique_code="OrderItemPdf"
|
unique_code="OrderItemPdf"
|
||||||
if !printer.empty?
|
if !printer.empty?
|
||||||
printer.each do |printer_setting|
|
printer.each do |printer_setting|
|
||||||
if printer_setting.unique_code == 'OrderItemPdf'
|
if printer_setting.unique_code == 'OrderItemPdf'
|
||||||
unique_code="OrderItemPdf"
|
unique_code="OrderItemPdf"
|
||||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
||||||
unique_code="OrderItemSlimPdf"
|
unique_code="OrderItemSlimPdf"
|
||||||
@@ -272,9 +254,9 @@ class Api::OrdersController < Api::ApiController
|
|||||||
unique_code="OrderItemCustomisePdf"
|
unique_code="OrderItemCustomisePdf"
|
||||||
elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf'
|
elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf'
|
||||||
unique_code="OrderSetItemCustomisePdf"
|
unique_code="OrderSetItemCustomisePdf"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
@@ -301,6 +283,5 @@ class Api::OrdersController < Api::ApiController
|
|||||||
|
|
||||||
return from
|
return from
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
@@ -38,20 +38,10 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
@booking = @table.get_booking
|
@booking = @table.get_booking
|
||||||
if @booking
|
if @booking
|
||||||
@booking_id = @booking.booking_id
|
@booking_id = @booking.booking_id
|
||||||
@order_items = Array.new
|
@obj_order = @booking.orders.first
|
||||||
@booking.booking_orders.each do |booking_order|
|
@customer = @obj_order.customer
|
||||||
order = Order.find(booking_order.order_id)
|
@date = @obj_order.created_at
|
||||||
if (order.status == "new")
|
@order_items = @booking.order_items
|
||||||
@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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -102,8 +92,16 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
if params[:booking_id].present?
|
||||||
# Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
booking = Booking.find(params[:booking_id])
|
||||||
|
end
|
||||||
|
if params[:table_id].present?
|
||||||
|
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||||
|
table = DiningFacility.find(params[:table_id])
|
||||||
|
booking = table.get_current_booking
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
is_extra_time = false
|
is_extra_time = false
|
||||||
extra_time = ''
|
extra_time = ''
|
||||||
|
|
||||||
@@ -131,6 +129,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
else
|
else
|
||||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
@order.order_type = params[:order_type]
|
@order.order_type = params[:order_type]
|
||||||
@@ -144,82 +143,51 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
|
|
||||||
@order.is_extra_time = is_extra_time
|
@order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = extra_time
|
@order.extra_time = extra_time
|
||||||
#Create Table Booking or Room Booking
|
|
||||||
if !params["booking_id"].nil?
|
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||||
# check booking id is already completed.
|
@order.new_booking = true
|
||||||
booking = Booking.find(params[:booking_id])
|
else
|
||||||
if params[:table_id].to_i > 0
|
@order.new_booking = false
|
||||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
@order.booking_id = booking.booking_id
|
||||||
else
|
end
|
||||||
table_status = true
|
|
||||||
end
|
@status, @booking = @order.generate
|
||||||
if booking
|
|
||||||
if table_status && booking.booking_status != 'moved'
|
if @status && @booking
|
||||||
if !booking.sale_id.nil?
|
#send order broadcast to order_channel
|
||||||
sale_status = check_order_with_booking(booking)
|
if @order.table_id.to_i > 0
|
||||||
if sale_status
|
table = DiningFacility.find(@booking.dining_facility_id)
|
||||||
return return_json_status_with_code(400, "bill requested")
|
type = 'order'
|
||||||
end
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
else
|
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||||
@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
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
||||||
|
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
if @status && @booking
|
|
||||||
#send order broadcast to order_channel
|
|
||||||
if @order.table_id.to_i > 0
|
|
||||||
table = DiningFacility.find(@booking.dining_facility_id)
|
|
||||||
type = 'order'
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
|
||||||
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Order.send_customer_view(@booking)
|
# Order.send_customer_view(@booking)
|
||||||
|
|
||||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
||||||
|
|
||||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||||
|
|
||||||
# for second display
|
# for second display
|
||||||
if @order.source == 'quick_service'
|
if @order.source == 'quick_service'
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
||||||
end
|
|
||||||
#end
|
|
||||||
result = {:status=> @status, :data => @sale }
|
|
||||||
render :json => result.to_json
|
|
||||||
end
|
end
|
||||||
else
|
#end
|
||||||
result = {:status=> @status, :data => 0 }
|
result = {:status=> @status, :data => @sale }
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
result = {:status=> @status, :data => 0 }
|
||||||
|
render :json => result.to_json
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
today = DateTime.now
|
today = DateTime.now
|
||||||
day = Date.today.wday
|
day = Date.today.wday
|
||||||
@@ -14,7 +14,7 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
@menus = []
|
@menus = []
|
||||||
@menu = []
|
@menu = []
|
||||||
# else
|
# else
|
||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
@zone = Zone.all
|
@zone = Zone.all
|
||||||
@@ -27,14 +27,14 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||||
if !lookup_dine_in.empty?
|
if !lookup_dine_in.empty?
|
||||||
lookup_dine_in.each do |dine_in|
|
lookup_dine_in.each do |dine_in|
|
||||||
if dine_in[0].downcase == "dineincashier"
|
if dine_in[0].downcase == "dineincashier"
|
||||||
if dine_in[1] == '1'
|
if dine_in[1] == '1'
|
||||||
@quick_service_only = false
|
@quick_service_only = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render "origami/addorders/detail"
|
render "origami/addorders/detail"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
@menus = []
|
@menus = []
|
||||||
@menu = []
|
@menu = []
|
||||||
# else
|
# else
|
||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
if(params[:id][0,3] == "BKI")
|
if(params[:id][0,3] == "BKI")
|
||||||
@@ -58,38 +58,33 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
@table = DiningFacility.find(@table_id)
|
@table = DiningFacility.find(@table_id)
|
||||||
@booking = @table.get_booking
|
@booking = @table.get_booking
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = @booking.sale_id
|
||||||
|
|
||||||
if @booking
|
if @booking
|
||||||
@booking_id = @booking.booking_id
|
@booking_id = @booking.booking_id
|
||||||
@order_items = Array.new
|
@obj_order = @booking.orders.first
|
||||||
@booking.booking_orders.each do |booking_order|
|
@customer = @obj_order.customer
|
||||||
order = Order.find(booking_order.order_id)
|
@date = @obj_order.created_at
|
||||||
if (order.status == "new")
|
@order_items = @booking.order_items
|
||||||
@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
|
|
||||||
end
|
end
|
||||||
render "origami/addorders/detail"
|
|
||||||
|
render "origami/addorders/detail"
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_modify_order
|
def update_modify_order
|
||||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
booking = Booking.find(params[:booking_id])
|
||||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
sale = booking.sale
|
||||||
|
if sale && sale.sale_status != 'new'
|
||||||
|
render :json => { :status => false }
|
||||||
|
end
|
||||||
|
|
||||||
is_extra_time = false
|
is_extra_time = false
|
||||||
extra_time = ''
|
extra_time = ''
|
||||||
@cashier_type = "food_court"
|
cashier_type = "food_court"
|
||||||
|
|
||||||
items_arr = []
|
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
|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||||
if i["item_instance_code"].include? "ext"
|
if i["item_instance_code"].include? "ext"
|
||||||
is_extra_time = true
|
is_extra_time = true
|
||||||
@@ -108,82 +103,32 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
}
|
}
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
@order = Order.new
|
order = Order.new
|
||||||
@order.source = params[:order_source]
|
order.source = params[:order_source]
|
||||||
@order.order_type = params[:order_type]
|
order.order_type = params[:order_type]
|
||||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||||
@order.items = items_arr
|
order.items = items_arr
|
||||||
@order.guest = params[:guest_info]
|
order.guest = params[:guest_info]
|
||||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
@order.new_booking = true
|
order.waiters = current_login_employee.name
|
||||||
@order.waiters = current_login_employee.name
|
order.employee_name = current_login_employee.name
|
||||||
@order.employee_name = current_login_employee.name
|
|
||||||
|
|
||||||
@order.is_extra_time = is_extra_time
|
order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = extra_time
|
order.extra_time = extra_time
|
||||||
|
|
||||||
#Create Table Booking or Room Booking
|
order.new_booking = false
|
||||||
if !params["booking_id"].nil?
|
order.booking_id = booking.booking_id
|
||||||
# check booking id is already completed.
|
|
||||||
booking = Booking.find(params[:booking_id])
|
if order.generate
|
||||||
if params[:table_id].to_i > 0
|
if sale
|
||||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||||
else
|
render :json => { :status => true, :data => sale }
|
||||||
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
|
|
||||||
else
|
else
|
||||||
if params[:table_id].to_i > 0
|
render :json => { :status => true, :data => 'OK' }
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
@status, @booking = @order.generate
|
render :json => { :status => false }
|
||||||
if(params[:sale_id][0,3] == "SAL")
|
end
|
||||||
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
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -209,9 +154,9 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
return @sub_menu
|
return @sub_menu
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_all_product()
|
def get_all_product()
|
||||||
@product = Product.all
|
@product = Product.all
|
||||||
end
|
end
|
||||||
|
|
||||||
# render json for http status code
|
# render json for http status code
|
||||||
|
|||||||
@@ -7,12 +7,32 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@order = Sale.pending_order(@cashier_type)
|
@order = Sale.pending_order(@cashier_type)
|
||||||
@completed = Sale.completed_sale(@cashier_type)
|
@completed = Sale.completed_sale(@cashier_type)
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
@occupied_table = @sale.count.length + @order.count.length
|
@occupied_table = @sale.count.length + @order.count.length
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
id = params[:sale_id]
|
||||||
|
if id.start_with?("SAL")
|
||||||
|
@sale = Sale.find(id)
|
||||||
|
if @sale.sale_status == "new"
|
||||||
|
@bookings = @sale.bookings.first
|
||||||
|
@status = "sale"
|
||||||
|
else
|
||||||
|
redirect_to "/origami/#{params[:type]}" and return
|
||||||
|
end
|
||||||
|
elsif id.start_with?("BKI")
|
||||||
|
@bookings = Booking.find(id)
|
||||||
|
@order = @bookings.orders.where(status: "new").first
|
||||||
|
@order_items = @bookings.order_items
|
||||||
|
@status = "order"
|
||||||
|
end
|
||||||
|
|
||||||
|
if @dining = @bookings.dining_facility
|
||||||
|
@table_id = @dining.id
|
||||||
|
end
|
||||||
|
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
@sales = Sale.pending_sale(@cashier_type)
|
@sales = Sale.pending_sale(@cashier_type)
|
||||||
@orders = Sale.pending_order(@cashier_type)
|
@orders = Sale.pending_order(@cashier_type)
|
||||||
@@ -20,38 +40,6 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
@occupied_table = @sales.count.length + @orders.count.length
|
@occupied_table = @sales.count.length + @orders.count.length
|
||||||
|
|
||||||
@id = params[:sale_id]
|
|
||||||
if(@id[0,3] == "SAL")
|
|
||||||
@sale = Sale.find(@id)
|
|
||||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
|
||||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
|
||||||
@bookings = Booking.find(@booking)
|
|
||||||
@status = "sale"
|
|
||||||
else
|
|
||||||
# @booking = BookingOrder.find_by_order_id(@order).booking_id
|
|
||||||
@bookings = Booking.find(@id)
|
|
||||||
@status = "order"
|
|
||||||
|
|
||||||
@order_items = Array.new
|
|
||||||
@bookings.booking_orders.each do |booking_order|
|
|
||||||
@order = Order.find(booking_order.order_id)
|
|
||||||
if (@order.status == "new")
|
|
||||||
@order.order_items.each do |item|
|
|
||||||
@order_items.push(item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# puts @status
|
|
||||||
if @bookings.dining_facility_id.to_i > 0
|
|
||||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
|
||||||
@dining = DiningFacility.find(@table_id)
|
|
||||||
else
|
|
||||||
@table_id = nil
|
|
||||||
@dining = nil
|
|
||||||
end
|
|
||||||
@customers = Customer.pluck("customer_id, name")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def completed_sale
|
def completed_sale
|
||||||
@@ -64,13 +52,13 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@occupied_table = @sales.count.length + @orders.count.length
|
@occupied_table = @sales.count.length + @orders.count.length
|
||||||
|
|
||||||
@id = params[:sale_id]
|
@id = params[:sale_id]
|
||||||
|
|
||||||
@sale = Sale.find(@id)
|
@sale = Sale.find(@id)
|
||||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||||
@bookings = Booking.find(@booking)
|
@bookings = Booking.find(@booking)
|
||||||
@status = "sale"
|
@status = "sale"
|
||||||
|
|
||||||
if @bookings.dining_facility_id.to_i > 0
|
if @bookings.dining_facility_id.to_i > 0
|
||||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
||||||
@dining = DiningFacility.find(@table_id)
|
@dining = DiningFacility.find(@table_id)
|
||||||
@@ -96,7 +84,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@completed = Sale.completed_sale(@cashier_type)
|
@completed = Sale.completed_sale(@cashier_type)
|
||||||
|
|
||||||
@occupied_table = @sales.count.length + @orders.count.length
|
@occupied_table = @sales.count.length + @orders.count.length
|
||||||
|
|
||||||
@id = params[:sale_id]
|
@id = params[:sale_id]
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
@@ -105,7 +93,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||||
@bookings = Booking.find(@booking)
|
@bookings = Booking.find(@booking)
|
||||||
@status = "sale"
|
@status = "sale"
|
||||||
|
|
||||||
if @bookings.dining_facility_id.to_i > 0
|
if @bookings.dining_facility_id.to_i > 0
|
||||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
||||||
@dining = DiningFacility.find(@table_id)
|
@dining = DiningFacility.find(@table_id)
|
||||||
@@ -116,7 +104,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
|
|
||||||
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
|
||||||
.where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote")
|
.where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote")
|
||||||
|
|
||||||
@sale_taxes = []
|
@sale_taxes = []
|
||||||
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
|
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
|
||||||
if !sale_taxes.empty?
|
if !sale_taxes.empty?
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
today = DateTime.now
|
today = DateTime.now
|
||||||
day = Date.today.wday
|
day = Date.today.wday
|
||||||
# if params[:menu] == "true"
|
# if params[:menu] == "true"
|
||||||
@menus = []
|
@menus = []
|
||||||
@menu = []
|
@menu = []
|
||||||
# else
|
# else
|
||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
@zone = Zone.all
|
@zone = Zone.all
|
||||||
@customer = Customer.all
|
@customer = Customer.all
|
||||||
@tables = Table.all.active.order('status desc')
|
@tables = Table.all.active.order('status desc')
|
||||||
@@ -51,13 +51,13 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
@cashier_type = "quick_service"
|
@cashier_type = "quick_service"
|
||||||
today = DateTime.now
|
today = DateTime.now
|
||||||
day = Date.today.wday
|
day = Date.today.wday
|
||||||
# if params[:menu] == "true"
|
# if params[:menu] == "true"
|
||||||
@menus = []
|
@menus = []
|
||||||
@menu = []
|
@menu = []
|
||||||
# else
|
# else
|
||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
if(params[:id][0,3] == "BKI")
|
if(params[:id][0,3] == "BKI")
|
||||||
@table_id = nil
|
@table_id = nil
|
||||||
@table = nil
|
@table = nil
|
||||||
@@ -68,34 +68,29 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
@booking = @table.get_booking
|
@booking = @table.get_booking
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = @booking.sale_id
|
||||||
|
|
||||||
if @booking
|
if @booking
|
||||||
@booking_id = @booking.booking_id
|
@booking_id = @booking.booking_id
|
||||||
@order_items = Array.new
|
@obj_order = @booking.orders.first
|
||||||
@booking.booking_orders.each do |booking_order|
|
@customer = @obj_order.customer
|
||||||
order = Order.find(booking_order.order_id)
|
@date = @obj_order.created_at
|
||||||
if (order.status == "new")
|
@order_items = @booking.order_items
|
||||||
@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
|
|
||||||
end
|
end
|
||||||
render "origami/addorders/detail"
|
|
||||||
|
render "origami/addorders/detail"
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_modify_order
|
def update_modify_order
|
||||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
booking = Booking.find(params[:booking_id])
|
||||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
sale = booking.sale
|
||||||
|
if sale && sale.sale_status != 'new'
|
||||||
|
render :json => { :status => false }
|
||||||
|
end
|
||||||
|
|
||||||
is_extra_time = false
|
is_extra_time = false
|
||||||
extra_time = ''
|
extra_time = ''
|
||||||
@cashier_type = "quick_service"
|
cashier_type = "quick_service"
|
||||||
|
|
||||||
items_arr = []
|
items_arr = []
|
||||||
JSON.parse(params[:order_items]).each { |i|
|
JSON.parse(params[:order_items]).each { |i|
|
||||||
@@ -117,82 +112,32 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
}
|
}
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
@order = Order.new
|
order = Order.new
|
||||||
@order.source = params[:order_source]
|
order.source = params[:order_source]
|
||||||
@order.order_type = params[:order_type]
|
order.order_type = params[:order_type]
|
||||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||||
@order.items = items_arr
|
order.items = items_arr
|
||||||
@order.guest = params[:guest_info]
|
order.guest = params[:guest_info]
|
||||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
@order.new_booking = true
|
order.waiters = current_login_employee.name
|
||||||
@order.waiters = current_login_employee.name
|
order.employee_name = 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.new_booking = false
|
||||||
@order.extra_time = extra_time
|
order.booking_id = booking.booking_id
|
||||||
|
|
||||||
#Create Table Booking or Room Booking
|
if order.generate
|
||||||
if !params["booking_id"].nil?
|
if sale
|
||||||
# check booking id is already completed.
|
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||||
booking = Booking.find(params[:booking_id])
|
render :json => { :status => true, :data => sale }
|
||||||
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
|
|
||||||
else
|
else
|
||||||
if params[:table_id].to_i > 0
|
render :json => { :status => true, :data => 'OK' }
|
||||||
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
|
|
||||||
end
|
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
|
||||||
if(params[:sale_id][0,3] == "SAL")
|
|
||||||
if @status && @booking && @order.source == 'quick_service'
|
|
||||||
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
|
end
|
||||||
|
else
|
||||||
|
render :json => { :status => false }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -234,20 +179,20 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
def check_order_with_table(table_id)
|
def check_order_with_table(table_id)
|
||||||
table = DiningFacility.find(table_id)
|
table = DiningFacility.find(table_id)
|
||||||
if table
|
if table
|
||||||
booking = table.get_current_booking
|
booking = table.get_current_booking
|
||||||
# puts booking
|
# puts booking
|
||||||
if booking
|
if booking
|
||||||
if !booking.sale_id.nil?
|
if !booking.sale_id.nil?
|
||||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@order.new_booking = false
|
@order.new_booking = false
|
||||||
@order.booking_id = booking.booking_id
|
@order.booking_id = booking.booking_id
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
@status = false
|
@status = false
|
||||||
@error_message = "Operation failed, Could not request bill!"
|
@error_message = "Operation failed, Could not request bill!"
|
||||||
else
|
else
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
||||||
|
|
||||||
if sale_data = booking.sale
|
if sale_data = booking.sale
|
||||||
@status = true
|
@status = true
|
||||||
|
|||||||
@@ -108,10 +108,10 @@ class DiningFacility < ApplicationRecord
|
|||||||
return booking
|
return booking
|
||||||
elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
|
elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
|
||||||
return booking
|
return booking
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -135,7 +135,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bookings.each do |booking|
|
bookings.each do |booking|
|
||||||
now = Time.now.utc
|
now = Time.now.utc
|
||||||
hr = (now.strftime("%H").to_i).to_int
|
hr = (now.strftime("%H").to_i).to_int
|
||||||
@@ -164,7 +164,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
#if ENV["SERVER_MODE"] != 'cloud'
|
#if ENV["SERVER_MODE"] != 'cloud'
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
from = request.subdomain + "." + request.domain
|
from = request.subdomain + "." + request.domain
|
||||||
else
|
else
|
||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
||||||
@@ -176,7 +176,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
if table.length > 0
|
if table.length > 0
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
from = request.subdomain + "." + request.domain
|
from = request.subdomain + "." + request.domain
|
||||||
else
|
else
|
||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
if ENV["SERVER_MODE"] != 'cloud'
|
||||||
@@ -203,5 +203,5 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
return status
|
return status
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -57,13 +57,12 @@ class Order < ApplicationRecord
|
|||||||
if self.is_extra_time
|
if self.is_extra_time
|
||||||
if !booking.checkout_at.nil?
|
if !booking.checkout_at.nil?
|
||||||
new_time = booking.checkout_at + self.extra_time.to_i
|
new_time = booking.checkout_at + self.extra_time.to_i
|
||||||
booking.update_attributes(checkout_at: new_time)
|
booking.update(checkout_at: new_time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#end extra time
|
#end extra time
|
||||||
end
|
end
|
||||||
|
|
||||||
booking.save!
|
|
||||||
self.default_values
|
self.default_values
|
||||||
|
|
||||||
# cashier already opened?
|
# cashier already opened?
|
||||||
@@ -211,7 +210,6 @@ class Order < ApplicationRecord
|
|||||||
self.customer = Customer.find(1) if self.customer_id.nil?
|
self.customer = Customer.find(1) if self.customer_id.nil?
|
||||||
self.source = "emenu" if self.source.nil?
|
self.source = "emenu" if self.source.nil?
|
||||||
self.order_type = "dine-in" if self.order_type.nil?
|
self.order_type = "dine-in" if self.order_type.nil?
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|||||||
@@ -2533,72 +2533,25 @@ end
|
|||||||
|
|
||||||
def self.add_to_existing_pending_invoice(dining,sale_id,booking)
|
def self.add_to_existing_pending_invoice(dining,sale_id,booking)
|
||||||
|
|
||||||
|
sale = Sale.find(sale_id)
|
||||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||||
if dining.to_i > 0
|
|
||||||
table = DiningFacility.find(dining)
|
|
||||||
table.bookings.each do |booking|
|
|
||||||
# if !booking.checkout_at.nil?
|
|
||||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
|
||||||
# end
|
|
||||||
if booking.sale_id.nil?
|
|
||||||
booking.booking_orders.each do |booking_order|
|
|
||||||
|
|
||||||
booking.booking_status = 'moved'
|
if booking.sale_id.nil? || booking.booking_id != existing_booking.booking_id
|
||||||
order = Order.find(booking_order.order_id)
|
booking.orders.where(status: 'new').update(booking: existing_booking)
|
||||||
order.status = 'billed'
|
booking.update(booking_status: 'moved')
|
||||||
order.order_items.each do |item|
|
end
|
||||||
item.order_item_status = 'billed'
|
|
||||||
end
|
|
||||||
# create sale item
|
|
||||||
saleobj = Sale.find(sale_id)
|
|
||||||
order.order_items.each do |orer_item|
|
|
||||||
saleobj.add_item (orer_item)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Re-compute for add
|
existing_booking.orders.where(status: 'new').each do |order|
|
||||||
saleobj.compute(order.source)
|
order.status = 'billed'
|
||||||
saleobj.save
|
order.order_items.each do |item|
|
||||||
order.save
|
item.order_item_status = 'billed'
|
||||||
booking.save
|
sale.add_item(item)
|
||||||
end
|
|
||||||
|
|
||||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
|
||||||
booking_order.each do |bo|
|
|
||||||
bo.booking_id = existing_booking.booking_id
|
|
||||||
bo.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if booking.sale_id.nil?
|
|
||||||
booking.booking_orders.each do |booking_order|
|
|
||||||
|
|
||||||
booking.booking_status = 'moved'
|
|
||||||
order = Order.find(booking_order.order_id)
|
|
||||||
order.status = 'billed'
|
|
||||||
order.order_items.each do |item|
|
|
||||||
item.order_item_status = 'billed'
|
|
||||||
end
|
|
||||||
# create sale item
|
|
||||||
saleobj = Sale.find(sale_id)
|
|
||||||
order.order_items.each do |orer_item|
|
|
||||||
saleobj.add_item (orer_item)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Re-compute for add
|
|
||||||
saleobj.compute(order.source)
|
|
||||||
saleobj.save
|
|
||||||
order.save
|
|
||||||
booking.save
|
|
||||||
end
|
|
||||||
|
|
||||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
|
||||||
booking_order.each do |bo|
|
|
||||||
bo.booking_id = existing_booking.booking_id
|
|
||||||
bo.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
order.save
|
||||||
|
sale.compute(order.source)
|
||||||
|
sale.orders << order
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_shift_sale_items(sh_id)
|
def self.get_shift_sale_items(sh_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user