<tr <% if purchase.status == "cancelled" %> class="danger"<% end %> >
	<td> # </td>
	<td><%= purchase.purchase_code %></td>
	<td><%= purchase.user.first_name%></td>
  <% if current_user.usertype == "A" %>
    <td><%= purchase.pointsale.present? ? purchase.pointsale.name : '' %></td>
    <td><%= purchase.warehouse.present? ? purchase.warehouse.name : '' %></td>
  <% end %>
	<td><%= purchase.supplier.nick_name %></td>
  <td><%= number_to_currency(purchase.total, precision: 2) %> <%= purchase.is_in_dollars ? 'USD' : 'MXN' %></td>

	<td> <%= l(purchase.purchase_date, :format => '%d/%B/%Y')  %> </td>
    <td class="text-center">
      <% case purchase.status %>
          <% when "paid"%>
            <span class="label label-sm label-success"> <i class="fa fa-check"></i> Pagada </span>
          <% when "cancelled"%>
             <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
          <% when "parcial"%>
            <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Abonada </span>
          <% when "notpaid"%>
            <span class="label label-sm label-default"> <i class="fa fa-clock-o"></i> Pendiente de pago </span>
      <% end %>
    </td>
	<td class="text-center">
      	<%= link_to purchase, {:class=>"btn btn-icon-only default", :title=>"Ver compra"} do %> <i class="fa fa-search"></i> <% end %>
      	<% daysToCancel = @pos_config.days_cancel_purchase %>
      	<% if (can? :manage, Purchase) && (purchase.purchase_date + daysToCancel.days >= Date.today) && !purchase.cancelled? %>
			<%= link_to purchase_path(purchase), method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar compra", data: { confirm: '¿Está seguro de cancelar la compra?'}   do %> <i class="fa fa-times"></i> <% end %>
		<% end %>
	</td>
</tr>
