From 4f1a6fefe75d394ef743db4514d7c1bef62ec788 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 14 Feb 2018 17:32:34 +0630 Subject: [PATCH] check void for table status update --- app/controllers/application_controller.rb | 10 +++++----- app/controllers/origami/home_controller.rb | 7 +++++-- app/controllers/origami/orders_controller.rb | 4 ++-- app/controllers/origami/rooms_controller.rb | 6 +++--- app/controllers/origami/void_controller.rb | 15 ++++++++++++--- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0966a573..e66d7700 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -38,11 +38,11 @@ class ApplicationController < ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 096af4d3..b725c23e 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -27,9 +27,9 @@ class Origami::HomeController < BaseOrigamiController @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - @order_items_count = Hash.new bookings = Booking.all if !bookings.nil? + @order_items_count = Hash.new bookings.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' if !booking.booking_orders.empty? @@ -51,7 +51,7 @@ class Origami::HomeController < BaseOrigamiController if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) else - @order_items_count[booking.dining_facility_id] += sale.sale_items.count + @order_items_count[booking.dining_facility_id] = sale.sale_items.count end end end @@ -59,6 +59,9 @@ class Origami::HomeController < BaseOrigamiController end end + puts "@order_items_count" + puts @order_items_count.to_json + @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index ec2f58ba..91388e4d 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -13,9 +13,9 @@ class Origami::OrdersController < BaseOrigamiController end end - @order_items_count = Hash.new bookings = Booking.all if !bookings.nil? + @order_items_count = Hash.new bookings.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' if !booking.booking_orders.empty? @@ -37,7 +37,7 @@ class Origami::OrdersController < BaseOrigamiController if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) else - @order_items_count[booking.dining_facility_id] += sale.sale_items.count + @order_items_count[booking.dining_facility_id] = sale.sale_items.count end end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 68cb8798..29b865a4 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -22,10 +22,10 @@ class Origami::RoomsController < BaseOrigamiController @shop = Shop::ShopDetail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - - @order_items_count = Hash.new + bookings = Booking.all if !bookings.nil? + @order_items_count = Hash.new bookings.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' if !booking.booking_orders.empty? @@ -47,7 +47,7 @@ class Origami::RoomsController < BaseOrigamiController if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) else - @order_items_count[booking.dining_facility_id] += sale.sale_items.count + @order_items_count[booking.dining_facility_id] = sale.sale_items.count end end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 52b2068c..aa36067b 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -40,16 +40,25 @@ class Origami::VoidController < BaseOrigamiController # end table_avaliable = true + table_count = 0 table = sale.bookings[0].dining_facility table.bookings.each do |booking| - if !booking.sale.nil? - if booking.sale.sale_status == 'new' + if booking.booking_status != 'moved' + if booking.sale_id + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' + table_avaliable = false + table_count += 1 + else + table_avaliable = true + end + else table_avaliable = false + table_count += 1 end end end - if table_avaliable + if table_avaliable && table_count == 0 table.status = 'available' table.save end