<div class="row">
  <div class="col-lg-12">
    <ol class="breadcrumb">
       <li><a href="<%= crm_root_path %>">Home</a></li>
       <li class="active">
           <a href="<%= transactions_credit_notes_path %>">Credit Note</a>
       </li>
       
    </ol>
  </div>
</div>

<div class="row">
  <div class="col-lg-12">
      <div class="main-box-body clearfix">
        <div class="table-responsive">
          <table class="table table-striped">
            <thead>
              <tr>
                <th>Sale Id </th>
                <th>Receipt no </th>
                <th>Credit Amount</th>
                <th>Cashier</th>
                <th>Customer Name</th>
                <th>Receipt Date</th>
              </tr>
            </thead>

            <tbody>
                  <% @sales.each do |sale| %>
                    <tr>
                      <td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
                      <td><%= sale.receipt_no %></td>
                      <td><%credit = SalePayment.where('sale_id = ? AND payment_method=?', sale.sale_id,"creditnote").first %>
                        <%= credit.payment_amount rescue '-' %>
                      </td>
                      <td><%= sale.cashier_name rescue '-' %></td>
                      <td><%= link_to sale.customer.name, crm_customer_path(sale.customer_id) %></td>
                      <td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
                    </tr>
                  <% end %>
             
            </tbody>
          </table>
          <br>
          
        </div>
      </div>

  </div>
</div>
<!-- 
<script type="text/javascript">
  $(function () {

            $('.datepicker').datepicker({
               format : 'dd-mm-yyyy',
               autoclose: true
            });
            $('.datepicker').attr('ReadOnly','true');
            $('.datepicker').css('cursor','pointer');

     
  });
</script> -->



     

