<% if @sale.present? %>
  window.location = "<%= new_sale_path %>";
  $("#notice").html("<%= flash[:notice] %>");
  var ticket_window = window.open("<%= print_receipt_path(@sale.id, format: 'pdf') %>", 'New tab', '' );
  ticket_window.print();

<% elsif @products_return.present? %>
  window.location = "<%= products_returns_path %>";
  $("#notice").html("<%= flash[:notice] %>");
  var ticket_window = window.open("<%= print_return_receipt_path(@products_return.id, format: 'pdf') %>", 'New tab', '' );
  ticket_window.print();

<% end %>
