<div class="card row">
	  <div class="table-responsive">
	  <table class="table table-bordered">
	  <thead> 
		  <% if params[:from]%>
		    <tr>
		        <th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to]  rescue '-'%>)</th>
		   </tr>
		  <% end %> 
		    <tr>
		    <th style='text-align:center;'>Sr.no</th>
		    <th style='text-align:center;'>Date</th>
		    <th style='text-align:center;'>Void Amount</th>
		    <th style='text-align:center;'>Mpu Sales</th>
		    <th style='text-align:center;'>Master Sales</th>
		    <th style='text-align:center;'>Visa Sales</th>
		    <th style='text-align:center;'>Jcb Sales</th>
		    <th style='text-align:center;'>Paypar Sales</th>
		    <th style='text-align:center;'>Cash Sales</th>
		    <th style='text-align:center;'>Credit Sales</th>
		    <th style='text-align:center;'>FOC Sales</th>
		    <th style='text-align:center;'>(Discount)</th>
		    <th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>     
		    <th style='text-align:center;'>Rounding Adj.</th>
		    <th style='text-align:center;'>Grand Total</th>     	        
		    </tr>
		  </thead>
		<% unless @sale_data.empty? %>
		  
		  <tbody>
		  <% void   = 0 %>
		  <% mpu    = 0 %>
		  <% master = 0 %>
		  <% visa   = 0 %>
		  <% jcb    = 0 %>
		  <% paypar = 0 %>
		  <% cash   = 0 %>
		  <% credit = 0 %>
		  <% foc    = 0 %>
		  <% discount = 0 %>
		  <% total    = 0 %>
		  <% grand_total = 0 %>  
		  <% count = 1 %> <% rounding_adj = 0 %>
		  <% @sale_data.each do |sale| %>
		    <% void += sale[:void_amount] %>
		    <% mpu += sale[:mpu_amount] %>
		    <% master += sale[:master_amount] %>
		    <% visa += sale[:visa_amount] %>
		    <% jcb += sale[:jcb_amount] %>
		    <% paypar += sale[:paypar_amount] %>
		    <% cash += sale[:cash_amount] %>
		    <% credit += sale[:credit_amount] %>   
		    <% foc += sale[:foc_amount] %>
		    <% discount += sale[:total_discount] %>
		    <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f  %>
		    <% grand_total += sale[:grand_total].to_f  %>	
		    <% rounding_adj += sale[:rounding_adj].to_f %>	
		  <tr>
		    <td style='text-align:right;'><%= count %></td>
		    <td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-'  %></td>
		    <td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>    
		    <td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>   
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>	   	
		  </tr>
		  <% count = count + 1 %>
		  <% end %>

		  <tr style="font-weight:600;">
		    <td colspan="3" style='text-align:center;'>Total</td>	
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>    
		    <td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>    
			<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>   	
			<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>   
		  </tr>

		  <% total_tax = 0 %>
		  <% unless @tax.empty? %>
		  <% @tax.each do |tax| %>
		  <% total_tax += tax.tax_amount.to_f %>
		  <tr style="font-weight:600;">
		    <td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
			<td colspan="2">&nbsp;</td>
		  </tr>
		  
		  <% end %>
		  <% net = total - total_tax %>
		  <tr style="font-weight:600;">
		    <td colspan="12" style='text-align:right;'>Net Amount</td>
		    <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
			<td colspan="2">&nbsp;</td>	
		  </tr>
		  <% end %>
		  </tbody>
		<% end %>
		</table>
		</div>
	</div>