var purchases_table = $('#purchases_per_month_table').DataTable();
var expenses_table = $('#expenses_per_month_table').DataTable();
$('#purchases_per_month_table').dataTable().fnClearTable();
$('#expenses_per_month_table').dataTable().fnClearTable();

<% @purchases.each_with_index do |purchase, key| %>
  var row = $('<%= j render partial: "report_purchase", locals: { purchase: purchase } %>');
  purchases_table.row.add(row).draw();
<% end %>

<% @expenses.each_with_index do |expense, key| %>
  var row = $('<%= j render partial: "report_expense", locals: { expense: expense } %>');
  expenses_table.row.add(row).draw();
<% end %>

$('#start_date_display').html("<%= l @start_date.to_date, format: :long %>");
$('#end_date_display').html("<%= l @end_date.to_date, format: :long %>");
$('#note_info').removeClass('hidden');

$('#prods_total').html('<%= @total_prods %>');
$('#purchases_quantity').html('<%= @purchases.count %>');

$('#cash_purchases_total').html(accounting.formatMoney('<%= @total_purchased.round(2) %>'));
$('#cash_purchases_total_dollars').html(accounting.formatMoney('<%= @total_dollars.round(2) %>'));
// $('#credit_purchases_total').html(accounting.formatMoney('< %= @purchases.sum(:total).round(2) %>'));
$('#expenses_total').html(accounting.formatMoney('<%= @expenses.sum(:quantity).round(2) %>'));
$('#purchases_total').html(accounting.formatMoney('<%= @total_purchased.round(2) %>'));
$('#purchases_total_dollars').html(accounting.formatMoney('<%= @total_dollars.round(2) %>'));
