diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1a073cc9..5fcdcdea 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 7cd6c426..bb1a8752 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -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 diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 47fed13a..6e2d3e38 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/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 5d9cbec7..f2284e15 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -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 diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index f9ad89a4..f9fbe55a 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 diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index 0963b2ca..70d9f147 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -26,7 +26,7 @@
Order Items
+| Items | +QTY | +Price | +
|---|---|---|
|
+ <%=odr_item['order_id'] %>
+ <%=odr_item['account_id'] %>
+
+ <%=odr_item['item_name'] %>
+ <% if !odr_item['set_menu_items'].nil?
+ odr_item['set_menu_items'].each do |item_instance| %>
+ <%= item_instance %> + <% end + end %> + + |
+ + <%=odr_item['qty']%> + | ++ <%=(odr_item['qty'].to_f * odr_item['price'].to_f)%> + | +
| Sub Total: | +<%=sub_total%> | +
Order Items