Files
sx-fc/app/views/reports/receipt_no/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

131 lines
5.7 KiB
Plaintext
Executable File

<!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">
<thead>
<tr>
<th colspan="9"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="9"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th><%= t("views.right_panel.detail.dining") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></th>
<th><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> </th>
<% @tax_profiles.each do |tax| %>
<th><%= tax.name %></th>
<% end %>
<!-- <th>Other Amount</th> -->
<th><%= t("views.right_panel.detail.grand_total") %></th>
<th><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<th><%= t("views.right_panel.detail.grand_total") %> +<br/>
<%= t("views.right_panel.detail.rnd_adj_sh") %>
</th>
</tr>
</thead>
<tbody>
<% grand_total = 0 %>
<% old_grand_total = 0 %>
<% after_rounding = 0 %>
<% total_tax = 0 %>
<% guest_count = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% other_amt = 0 %>
<% total_nett = 0 %>
<% rounding_adj = 0%>
<% gov_tax = 0 %>
<% service_charge = 0 %>
<% if @sale_data %>
<% @sale_data.each do |result| %>
<% grand_total += result.grand_total.to_f %>
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
<% rounding_adj += result.rounding_adjustment.to_f %>
<tr>
<td>
<%if result.type %>
<%= result.type %> - <%= result.name %>
<% else %>
-
<% end %>
</td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% @tax_profiles.each do |tax| %>
<% if sale_tax = result.sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %>
<td><%= number_format(sale_tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> </td>
<% else %>
<td><%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% end %>
<% end %>
<td><%= number_format(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_format(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="3">&nbsp;</td>
<td><b><%= number_format(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_format(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<% @tax_profiles.each do |tax| %>
<% if sale_tax = @sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %>
<td><%= number_format(sale_tax.st_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> </td>
<% else %>
<td><%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<% end %>
<% end %>
<td><b><%= number_format(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= number_format(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_format(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
<% @tax_profiles.each do |tax| %>
<td><%= tax.name %></td>
<% end %>
<td><%= t("views.right_panel.detail.grand_total") %></td>
<td><%= t("views.right_panel.detail.rnd_adj_sh") %></td>
<td><%= t("views.right_panel.detail.grand_total") %> +<br/>
<%= t("views.right_panel.detail.rnd_adj_sh") %>
</td>
<td>
</td>
</tr>
<%end%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>