From fc3cd1e72d3c17533181a3aacfdf1207b13b4fc5 Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 27 Feb 2018 11:33:51 +0630 Subject: [PATCH] check order item --- .../origami/split_bill_controller.rb | 26 ++++++++++--------- app/views/origami/split_bill/index.html.erb | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 59dd3a71..9f8afd0d 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -147,15 +147,15 @@ 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 - # puts "order_id_count > 1" + puts "order_id_count > 1" updated_order_id = Array.new order_ids.each do |odr_id| @@ -165,8 +165,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| @@ -195,7 +195,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 @@ -223,7 +223,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_by_order_id(order_id) @@ -236,7 +236,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 @@ -266,7 +266,9 @@ class Origami::SplitBillController < BaseOrigamiController end end else - if order_ids.count == 1 && order_id_count > 0 && order_item_count == 1 + # puts order_ids + if order_ids.count == 1 && order_id_count == 0 && order_item_count == 1 + BookingOrder.find_by_order_id(order_ids[0]).delete BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]}) order_items.each do |order_item| update_order_item(order_ids[0], order_item) diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index fdd07dd8..1db44d41 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -214,7 +214,7 @@ <%= sale_data.receipt_no %> <%= sale_data.grand_total %> - <% if !@current_user.nil? && @current_user.role == 'cashier' %> + <% if !@current_user.nil? && @current_user.role != 'waiter' %>