Files
sx-fc/app/views/reports/hourly_saleitem/index.xls.erb
Thein Lin Kyaw 3c1cc737b5 improve receipt/details reports and implement number formatting
1) eager load reports for receipt/details
2) introduce number_format lookups to replace print_settings for number formatting
3) implement NumberFormattable concern, reference number_format lookups or print_settings if not exist, to get number format settings and number formatting
4) replace rails NumberHelper.number_with_precision with NumberFormattable.number_format hopefully to reduce overhead, formatting numbers for huge lists of data
2019-11-25 23:17:53 +06:30

132 lines
5.0 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<% time_arr = Array.new %>
<% acc_arr = Array.new %>
<% sale_item_count =0 %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% total_qty = 0 %>
<% time_count = 0 %>
<% grand_total = 0 %>
<% @sale_data.each do |sale| %>
<% if !time_arr.include?(sale.date_format) %>
<% sale_item_count =1 %>
<% time_count = time_count + 1 %>
<thead>
<td>&nbsp;</td>
<tr>
<td>
<strong>Time :<%= sale.date_format %></strong>
</td>
<td></td>
<td></td>
<td colspan="3" style="text-align:right"><strong></strong></td>
</tr>
<tr>
<td><strong>Menu Category</strong></td>
<td><strong>Item Code</strong></td>
<td><strong>Item Name</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
</thead>
<% time_arr.push(sale.date_format) %>
<% menu_cat_arr.clear %>
<% count = 0 %>
<% else %>
<% sale_item_count =sale_item_count +1 %>
<% end %>
<tbody>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.status_type =="promotion" && @type == "promotion"
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% if sale.status_type == "promotion" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% grand_total += sale.grand_total %>
<% if !sale.item_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %>
<tr>
<% if !menu_cat_arr.include?(sale.menu_category_name) %>
<td><%= sale.menu_category_name %></td>
<% menu_cat_arr.push(sale.menu_category_name) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code %></td>
<td><%= sale.product_name %></td>
<td><%= sale.total_item.to_i %></td>
<td><%= number_format(sale.unit_price.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
<td><%= number_format(sale.grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
<!-- <td><%= sale.date_format %></td> -->
</tr>
<% end %>
<!-- new tr -->
<% count = count + 1 %>
<% @hourly_total_qty.each do |hr| %>
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
<tr>
<td></td>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td>
<span class="underline" style="text-align:right">
<strong><%= total_qty.to_i %></strong>
<% total_qty = 0%>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= number_format(grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></strong>
<% grand_total = 0 %>
</span>
</td>
</tr>
<% footer_arr.push(sale.sale_id) %>
<% else %>
<% end %>
<% end %>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</body>
</html>