<tr class="<%= sale.cancelled? ? 'danger' : '' %>">
  <td><%= l(sale.date_sale, :format => '%d/%m/%Y') %></td>
  <td><%= sale.sale_code %> </td>
  <td><%= @pointsale.present? ? @pointsale.name : sale.get_pointsale.name %> </td>
  <td><%= sale.sales_details.sum(:quantity).to_i %> </td>
  <td>
    <% if sale.saletype == "credit" && sale.credit_note.blank? %>
    Crédito
    <% elsif sale.saletype == "credit" && sale.credit_note.present? %>
    Crédito/vale
    <% elsif sale.saletype == "cash" %>
    Contado
    <% elsif sale.saletype == "reserved" %>
    Apartado
    <% end %>
  </td>
  <td><%= sale_status(sale) %></td>
  <td><%= number_to_currency(sale.amount, precision: 2) %></td>
  <td><%= number_to_currency(sale.tax, precision: 2) %></td>
  <td><%= number_to_currency(sale.discount, precision: 2) %></td>
  <td><%= number_to_currency(sale.total, precision: 2) %></td>
  <% cost = sale_utility(sale.sales_details) %>
  <td><%= number_to_currency(cost, precision: 2) %></td>
  <td><%= number_to_currency(sale.total - cost, precision: 2) %></td>
</tr>
