<tr class=<%= (sale.cancelled? ? 'danger' : '') %>>
  <td><%= sale.id %></td>
  <td><%= sale.sale_code %> </td>
  <% if current_user.usertype == 'A' %>
    <td> <%= sale.get_pointsale.name %> </td>
  <% end %>
  <td> <%= sale.customer.nick_name %> </td>
  <td> <%= sale.seller.name %> </td>
  <td> <%= l(sale.date_sale, :format => '%d/%m/%Y') %> </td>
  <td> <%= l(sale.expiration_date, :format => '%d/%B/%Y') %> </td>
  <td> <%= sale.sales_details.sum(:quantity) %> </td>
  <td>
      <% if sale.reserve_is_expired? && !sale.paid? && !sale.cancelled? %>
        <span class="label label-warning"> VENCIDO </span>
      <% elsif sale.cancelled? %>
        <span class="label label-danger"> CANCELADO </span>
      <% elsif sale.parcial? %>
        <span class="label label-success"> VIGENTE </span>
      <% elsif sale.paid? %>
        <span class="label label-success"> PAGADO </span>
      <% end %>
  </td>
  <td><%= number_to_currency(sale.total, precision: 2) %></td>
  <td><%= number_to_currency(sale.reserve_debt, precision: 2) %></td>
  <td class="hide_c">
    <!-- detalle del traspaso -->
    <%= link_to sale, {:class=>"btn btn-icon-only default", :title=>"Ver apartado"} do %>
      <i class="fa fa-search"></i>
    <% end %>
    <!-- reimprimir ticket -->
    <%= link_to print_receipt_path(sale.id, format: 'pdf'), {:class=>"btn btn-icon-only default", :target => "blank"} do %>
      <i class="fa fa-print"></i>
    <% end %>
    <!-- regresar productos a inventario cuando vencio el apartado -->
    <% if sale.reserve_is_expired? && !sale.cancelled_by_expiration? && !sale.paid? && !sale.cancelled? %>
      <%= link_to sale_return_expired_path(sale), :class=>"btn btn-icon-only btn-info", :title=>"Regresar producto(s) a inventario", data: { confirm: '¿Esta seguro que desea reingresar los productos a inventario?', method: 'post'}  do %>
          <i class="fa fa-reply"></i>
      <% end %>
    <% end %>
    <!-- Cancelar apartado -->
    <% if !sale.reserve_is_expired? && !sale.cancelled? && !sale.paid? %>
      <%= link_to cancel_reserved_sale_path(sale), :remote => true, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar apartado" do %>
        <i class="fa fa-ban"></i>
      <% end %>
    <% end %>
    <!-- liquidar traspaso -->
    <% if (can? :liquidate_reserve, Sale) && !sale.cancelled_by_expiration? && sale.parcial? %>
      <%= link_to sale_liquidate_reserve_path(sale), :remote => true, :class=>"btn btn-icon-only green-dark", :title=>"Liquidar apartado" do %>
        <i class="fa fa-dollar"></i>
      <% end %>
    <% end %>
  </td>
</tr>
