for all items

This commit is contained in:
phyusin
2018-02-15 13:24:29 +06:30
6 changed files with 128 additions and 39 deletions

View File

@@ -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