From 992914ee46f7434c617decba95f134e34e27b1a8 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 23 May 2018 17:23:38 +0630 Subject: [PATCH] check multiple items in split bill --- .../origami/split_bill_controller.rb | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 77f4589a..faa41926 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -161,11 +161,11 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts order_id - puts order_ids.count - puts order_id_count - puts order_items.count - puts order_item_count + # puts order_id + # puts order_ids.count + # puts order_id_count + # puts order_items.count + # puts order_item_count if !order_id.nil? if order_id_count > 1 @@ -181,8 +181,8 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts "updated_order_id" - puts updated_order_id + # puts "updated_order_id" + # puts updated_order_id if !updated_order_id.empty? order_ids.each do |odr_id| @@ -211,7 +211,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts new_order_status + # puts new_order_status if new_order_status BookingOrder.find_by_order_id(odr_id).delete @@ -239,7 +239,7 @@ class Origami::SplitBillController < BaseOrigamiController end end else - puts "order_id_count < 1" + # puts "order_id_count < 1" new_order_status = true order_items.each do |order_item| orderItem = OrderItem.find(order_item["id"]) @@ -252,7 +252,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts new_order_status + # puts new_order_status if new_order_status BookingOrder.find_by_order_id(order_id).delete @@ -337,12 +337,12 @@ class Origami::SplitBillController < BaseOrigamiController end Promotion.promo_activate(sale) - if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain - else - from = "" - end - ActionCable.server.broadcast "bill_channel",table: table,from:from + # if ENV["SERVER_MODE"] == 'cloud' + # from = request.subdomain + "." + request.domain + # else + # from = "" + # end + # ActionCable.server.broadcast "bill_channel",table: table,from:from render :json => { status: status } else @@ -379,20 +379,26 @@ class Origami::SplitBillController < BaseOrigamiController orderItem.set_menu_items = instance_item_sets.to_json end - OrderItem.processs_item(orderItem.item_code, - orderItem.item_instance_code, - orderItem.item_name, - orderItem.alt_name, - orderItem.account_id, - order_item['qty'], - orderItem.price, - orderItem.options, - set_menu_items_obj.to_json, - order_id, - orderItem.item_order_by, - orderItem.taxable) - - orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f + same_order = OrderItem.find_by_order_id(order_id) + if same_order.nil? + OrderItem.processs_item(orderItem.item_code, + orderItem.item_instance_code, + orderItem.item_name, + orderItem.alt_name, + orderItem.account_id, + order_item['qty'], + orderItem.price, + orderItem.options, + set_menu_items_obj.to_json, + order_id, + orderItem.item_order_by, + orderItem.taxable) + else + same_order.qty = same_order.qty.to_f + order_item['qty'].to_f + same_order.set_menu_items = set_menu_items_obj.to_json + same_order.save + end + orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f else orderItem.order_id = order_id end