change split bill process
This commit is contained in:
@@ -38,6 +38,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
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
|
||||
@@ -47,6 +49,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
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
|
||||
@@ -116,9 +120,9 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@spit_bill = 0
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@spit_bill = lookup_spit_bill[0][1]
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,21 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
@orders.each do |order|
|
||||
order.order_items.each_with_index do |item, index|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
order.order_items[index].set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@order_items_count = Hash.new
|
||||
bookings = Booking.all
|
||||
if !bookings.nil?
|
||||
@@ -24,6 +39,8 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
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
|
||||
@@ -33,6 +50,8 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
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
|
||||
|
||||
@@ -34,6 +34,8 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
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
|
||||
@@ -43,6 +45,8 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
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
|
||||
@@ -119,9 +123,9 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@spit_bill = 0
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@spit_bill = lookup_spit_bill[0][1]
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,11 +28,40 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
@order_items.push(item)
|
||||
|
||||
arr_item = Hash.new
|
||||
if item.qty.to_i > 1
|
||||
i = 1
|
||||
while i <= item.qty.to_i do
|
||||
arr_item = {'order_items_id' => item.order_items_id,
|
||||
'order_id' => item.order_id,
|
||||
'order_item_status' => item.order_item_status,
|
||||
'item_order_by' => item.item_order_by,
|
||||
'item_code' => item.item_code,
|
||||
'item_instance_code' => item.item_instance_code,
|
||||
'item_name' => item.item_name,
|
||||
'alt_name' => item.alt_name,
|
||||
'account_id' => item.account_id,
|
||||
'qty' => '1.0',
|
||||
'price' => item.price,
|
||||
'remark' => item.remark,
|
||||
'options' => item.options,
|
||||
'set_menu_items' => item.set_menu_items,
|
||||
'taxable' => item.taxable,
|
||||
'completed_by' => item.completed_by,
|
||||
'created_at' => item.created_at,
|
||||
'updated_at' => item.updated_at}
|
||||
i += 1
|
||||
@order_items.push({@order.order_id => arr_item})
|
||||
end
|
||||
else
|
||||
@order_items.push({@order.order_id => item})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -186,8 +215,25 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order.order_id
|
||||
orderItem.save!
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user