check order item split process
This commit is contained in:
@@ -15,6 +15,13 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type})
|
||||
end
|
||||
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
|
||||
sale_order = SaleOrder.find_by_order_id(@order.order_id)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
|
||||
@@ -149,6 +149,8 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
if !order_id.nil?
|
||||
if order_id_count > 1
|
||||
puts "order_id_count > 1"
|
||||
|
||||
updated_order_id = Array.new
|
||||
order_ids.each do |odr_id|
|
||||
odr = Order.find(odr_id)
|
||||
@@ -157,10 +159,13 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
puts "updated_order_id"
|
||||
puts updated_order_id
|
||||
|
||||
if !updated_order_id.empty?
|
||||
order_ids.each do |odr_id|
|
||||
unless updated_order_id.include?(odr_id)
|
||||
# BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
@@ -172,16 +177,102 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
else
|
||||
order_ids.each do |odr_id|
|
||||
# BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find_by_order_id(odr_id)
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
new_order_status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = Order.new
|
||||
order.source = "cashier"
|
||||
order.order_type = order_type
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
order.item_count = order_items.count
|
||||
order.status = "new"
|
||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
||||
order.waiters = current_user.name
|
||||
order.employee_name = current_user.name
|
||||
order.guest_info = nil
|
||||
order.save!
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
BookingOrder.find_by_order_id(order_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
|
||||
puts "order_id_count < 1"
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_id, order_item)
|
||||
orderItem = OrderItem.find_by_order_id(order_id)
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
new_order_status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(order_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = Order.new
|
||||
order.source = "cashier"
|
||||
order.order_type = order_type
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
order.item_count = order_items.count
|
||||
order.status = "new"
|
||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
||||
order.waiters = current_user.name
|
||||
order.employee_name = current_user.name
|
||||
order.guest_info = nil
|
||||
order.save!
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -217,7 +308,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.id, order_item)
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user