update receipt repoert

This commit is contained in:
Aung Myo
2017-07-08 10:25:22 +06:30
parent 4d3de51e72
commit 8985393535
13 changed files with 751 additions and 208 deletions

View File

@@ -1,43 +1,91 @@
<div class="span12">
<div class="table-responsive">
<div class="container margin-top-20">
<div class="card row">
<table class="table table-striped" border="0">
<thead>
<% if !params[:from].blank?%>
<tr>
<th colspan="7">From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%></th>
</tr>
<% end %>
<% if @shift_from %>
<tr>
<% if @shift.employee %>
<% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>
<% end %>
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tr>
<th>Recipt No</th>
<th>Cashier Name</th>
<th>Total Amount</th>
<th>Discount Amount </th>
<th>Tax Amount</th>
<!-- <th>Other Amount</th> -->
<th>Grand Total</th>
<th>Rounding Adj.</th>
<th>Grand Total +<br/>
Rounding Adj.
</th>
</tr>
</thead>
<tbody>
<% grand_total = 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 %>
<tbody>
<% total_sales = 0 %>
<% net_sales = 0 %>
<% @sale_data.each do |sale| %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% @sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.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><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<td><%= sprintf "%.2f",result.total_tax rescue '-' %></td>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td>
<td><b><%= discount_amt rescue '-'%></b></td>
<td><b><%= sprintf "%.2f",total_tax rescue '-'%></b></td><!--
<td><b><%= sprintf "%.2f",service_charge rescue '-'%></b></td> -->
<!-- <td><b><%= other_amt rescue '-'%></b></td> -->
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>Total Amount</td>
<td>Discount Amount</td>
<td>Tax Amount</td>
<td>Grand Total</td>
<td>Rounding Adj.</td>
<td>Grand Total +<br/>
Rounding Adj.
</td>
</tr>
</tbody>
</table>
</div>
</div>