change query for origami
This commit is contained in:
@@ -27,40 +27,37 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
# bookings = Booking.all
|
||||
# if !bookings.nil?
|
||||
bookings = Booking.all
|
||||
if !bookings.today.nil?
|
||||
@order_items_count = Hash.new
|
||||
# bookings.each do |booking|
|
||||
# if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
# if !booking.booking_orders.empty?
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# if !order.order_items.empty?
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if !booking.sale_id.nil?
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status !='completed'
|
||||
# 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
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
puts "@order_items_count"
|
||||
puts @order_items_count.to_json
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if !booking.sale_id.nil?
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status !='completed'
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@dining.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@@ -126,12 +123,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
#for bank integration
|
||||
@checkout_time = Lookup.collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
#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
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
@@ -140,9 +137,4 @@ def set_dining
|
||||
@dining = DiningFacility.find(params[:dining_id])
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,37 +43,37 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
# 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?
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# if !order.order_items.empty?
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if !booking.sale_id.nil?
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status !='completed'
|
||||
# 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
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
bookings = Booking.all
|
||||
if !bookings.today.nil?
|
||||
@order_items_count = Hash.new
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if !booking.sale_id.nil?
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status !='completed'
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
|
||||
@@ -23,37 +23,37 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
# bookings = Booking.all
|
||||
# if !bookings.nil?
|
||||
bookings = Booking.all
|
||||
if !bookings.today.nil?
|
||||
@order_items_count = Hash.new
|
||||
# bookings.each do |booking|
|
||||
# if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
# if !booking.booking_orders.empty?
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# if !order.order_items.empty?
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if !booking.sale_id.nil?
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status !='completed'
|
||||
# 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
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if !booking.sale_id.nil?
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status !='completed'
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@room.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
|
||||
@@ -9,6 +9,7 @@ class Booking < ApplicationRecord
|
||||
has_many :booking_orders
|
||||
has_many :orders, :through => :booking_orders
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
||||
|
||||
def self.update_dining_facility(booking_arr, newd, old)
|
||||
table = DiningFacility.find(newd)
|
||||
|
||||
Reference in New Issue
Block a user