for all items
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -28,9 +28,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?
|
||||
@@ -52,7 +52,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,6 +21,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@orders.push(@order)
|
||||
@order_items.push({'all_order' => @order.order_items})
|
||||
|
||||
@order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
@@ -68,6 +69,9 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
|
||||
puts "@order_items"
|
||||
puts @order_items.to_json
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -163,9 +167,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
order_items.each do |order_item|
|
||||
if updated_order_id.include?(order_item["order_id"])
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order_id
|
||||
orderItem.save!
|
||||
update_order_item(order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -176,12 +178,10 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
else
|
||||
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|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order_id
|
||||
orderItem.save!
|
||||
update_order_item(order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -214,26 +214,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
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,
|
||||
orderItem.set_menu_items,
|
||||
orderItem.order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order.order_id
|
||||
end
|
||||
orderItem.save!
|
||||
update_order_item(order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -258,6 +239,29 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def update_order_item(order_item)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
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,
|
||||
orderItem.set_menu_items,
|
||||
orderItem.order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order.order_id
|
||||
end
|
||||
orderItem.save!
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user