<div class="span12">
<div class="table-responsive">

<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>

      <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>
</div>
