  $(document).ready(function() {
      $('.main-spinner').show();
      var index = $('#datatable_accounting_capital_report').DataTable({
        "lengthMenu": [[20, 25, 50, 100, 500], [20, 25, 50, 100, 500]],
        serverSide: true,
        ajax: "/realty/report-accounting-capital",
        columns: [
          {data: 'DT_RowIndex',"searchable": false},
          {data: 'do_date','name':'nso007_journal.journal_paydate'},
          {data: 'acc_code','name':'nso007_account_chart.acc_name'},
          {data: 'acc_name','name':'nso007_account_chart.id'},
          {data: 'reference','name':'nso007_journal.journal_invoice'},
          {data: 'user_log_name',"searchable": false},
          {data: 'description','name':'nso007_journal.journal_des'},
          {data: 'debit_amount'}
        ],
        "initComplete": function(settings, json) {
          $('.main-spinner').hide();
        },

                "footerCallback": function ( row, data, start, end, display ) {
                  var api = this.api(), data;
       
                  // converting to interger to find total
                  var intVal = function ( i ) {
                      return typeof i === 'string' ?
                          i.replace(/[\$,]/g, '')*1 :
                          typeof i === 'number' ?
                              i : 0;
                  };
       
                  var total_capita = api
                      .column( 7 )
                      .data()
                      .reduce( function (a, b) {
                          return intVal(a) + intVal(b);
                      }, 0 );

                  var numFormat = $.fn.dataTable.render.number( '\,', '.', 2, '$ ' ).display;
                  $( api.column( 7 ).footer() ).html(numFormat(total_capita));
                },        
      });
      index.on( 'order.dt search.dt', function () {
        index.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
          cell.innerHTML = i+1 ;
        } );
      } ).draw();
      $.fn.dataTable.ext.errMode = 'throw';

      
  });