From d9a3a8e59fa8f0bc43a39d94c0939385cf0b7b9d Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 7 Jun 2018 11:12:01 +0630 Subject: [PATCH] check set menu item price --- app/views/api/orders/view_orders.json.jbuilder | 13 ++++++++++++- app/views/origami/home/show.html.erb | 7 +++++-- app/views/origami/rooms/show.html.erb | 11 +++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder index dd72a3a3..9118b87f 100755 --- a/app/views/api/orders/view_orders.json.jbuilder +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -36,6 +36,7 @@ if (@booking) end json.order_items order_items do |item| + total_set_menu = 0 # For YGN BBQ if item.item_code.include? ("PSA_") adult_count += item.qty @@ -46,6 +47,7 @@ if (@booking) child_spent += (item.price * item.qty) end # End YGN BBQ + json.order_items_id item.order_items_id json.order_id item.order_id json.item_code item.item_code @@ -57,7 +59,16 @@ if (@booking) json.options item.options json.remark item.remark json.item_status item.order_item_status - @total_amount = @total_amount + (item.price * item.qty) + + #start set menu item price + if !item.set_menu_items.nil? && item.set_menu_items != '[]' + JSON.parse(item.set_menu_items).each do |item_instance| + total_set_menu += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f + end + end + #end set menu item price + + @total_amount = @total_amount + (item.price * item.qty) + total_set_menu end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 986bed5f..b6039c00 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -284,6 +284,7 @@ unless @order_items.nil? || @order_items.empty? count = 0 @order_items.each do |order_item| + set_item_prices = 0 count += 1 sub_total = sub_total + (order_item.price * order_item.qty) @@ -301,7 +302,8 @@ <% end %> <% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]' - JSON.parse(order_item.set_menu_items).each do |item_instance| %> + JSON.parse(order_item.set_menu_items).each do |item_instance| + set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && !item_instance["options"].empty? %> @@ -313,10 +315,11 @@ <% end %> <% end + sub_total += set_item_prices end %> <%= order_item.qty %> - <%= order_item.qty*order_item.price %> + <%= (order_item.qty*order_item.price).to_f + set_item_prices %> <% diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index ee1573ea..a4f06b85 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -269,8 +269,9 @@ unless @order_items.nil? || @order_items.empty? count = 0 @order_items.each do |order_item | - count += 1 - sub_total = sub_total + (order_item.price * order_item.qty) + set_item_prices = 0 + count += 1 + sub_total = sub_total + (order_item.price * order_item.qty) # unless order_item.price == 0 %> @@ -286,7 +287,8 @@ <% end %> <% if !order_item.set_menu_items.nil? - JSON.parse(order_item.set_menu_items).each do |item_instance| %> + JSON.parse(order_item.set_menu_items).each do |item_instance| + set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> @@ -298,10 +300,11 @@ <% end %> <% end + sub_total += set_item_prices end %> <%= order_item.qty %> - <%= order_item.qty*order_item.price %> + <%= (order_item.qty*order_item.price).to_f + set_item_prices %> <%