From 7cc7419b67d696d6ce89295e7864d97012280ad8 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 7 May 2018 10:22:15 +0630 Subject: [PATCH] Edit waste and spoile report excel --- .../reports/waste_and_spoilage/index.xls.erb | 113 +++++++++++------- 1 file changed, 69 insertions(+), 44 deletions(-) diff --git a/app/views/reports/waste_and_spoilage/index.xls.erb b/app/views/reports/waste_and_spoilage/index.xls.erb index 4b4fa0a3..48f26650 100755 --- a/app/views/reports/waste_and_spoilage/index.xls.erb +++ b/app/views/reports/waste_and_spoilage/index.xls.erb @@ -5,52 +5,77 @@
Report For <%= @sale_type? @sale_type : 'Waste' %>
- <% @sale_data.each do |sale| %> + <% receipt_arr = Array.new %> + <% menu_cat_arr = Array.new %> + <% footer_arr = Array.new %> + <% count = 0 %> <% waste_and_spoil_item_count = 0%> - - - - - - - - - - - - - - - + + <% @sale_data.each do |sale| %> + <% if !receipt_arr.include?(sale.receipt_no) %> + + + + + + + + + + + + + + + + + + <% receipt_arr.push(sale.receipt_no) %> + <% menu_cat_arr.clear %> + <% count = 0 %> + <% end %> - <% sale.sale_items.each do |item| %> - <% if !item.item_instance_code.nil?%> - <% waste_and_spoil_item_count += item.qty.to_i%> - - - - - - - - <% end %> - <% end %> - - - - - - - - <% end %> + + + <% if !sale.item_instance_code.nil?%> + <% waste_and_spoil_item_count += sale.qty.to_i %> + + <% if !menu_cat_arr.include?(sale.name) %> + + <% menu_cat_arr.push(sale.name) %> + <% else %> + + <% end %> + + + + + + + <% end %> + <% count = count + 1 %> + <% if sale.sale_items.count == count %> + + + + + + + + <% footer_arr.push(sale.sale_id) %> + <% end %> + + <% end %>
- Receipt No :<%= sale.receipt_no %> - Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %>
Item NameItem CodeQtyPriceTotal Price
 
+ Receipt No :<%= sale.receipt_no %> + Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %>
Menu CategoryItem NameItem CodeQtyPriceTotal Price
<%= item.product_name %><%= item.product_code %><%= item.qty %><%= item.price %><%= item.price %>
Total Qty: - <%= waste_and_spoil_item_count %> - Grand Total: - - <%= sale.grand_total %> - -
<%= sale.name %> <%= sale.product_name %><%= sale.product_code %><%= sale.qty.to_i %><%= sale.unit_price %><%= sale.price %>
Total Qty: + + <%= waste_and_spoil_item_count %> + <% waste_and_spoil_item_count = 0%> + Grand Total: + + <%= sale.grand_total %> + +