      $(document).ready(function() {
        $('.main-spinner').show();
      var index = $('#datatable_accounting_capital_report').DataTable({
        "lengthMenu": [[20, 25, 50, 100,200, 500 , 1000, 2000 , 5000], [20, 25, 50, 100,200, 500 , 1000, 2000 , 5000  ]],
        serverSide: true,
        ajax: "/realty/report-accounting-cash-flow-lish",
        columns: [
          {data: 'DT_RowIndex','searchable':false},
          {data: 'journal_paydate','name':'nso007_journal.journal_paydate'},
          {data: 'journal_type','name':'nso007_journaltype.journaltype_name'},
          {data: 'invoice','name':'nso007_journal.journal_invoice'},
          {data: 'user_by','searchable':false},
          {data: 'des','name':'nso007_journal.journal_des'},
          {data: 'cash_in','name':'nso007_journal.journal_debit'},
          {data: 'cash_out','name':'nso007_journal.journal_credit'},
        ],
        
        "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_cash_in = api
              .column( 6 )
              .data()
              .reduce( function (a, b) {
                  return intVal(a) + intVal(b);
              }, 0 );

          var tatal_cash_out = api
              .column( 7 )
              .data()
              .reduce( function (a, b) {
                  return intVal(a) + intVal(b);
              }, 0 );

          var total_balance = (total_cash_in - tatal_cash_out);

          var numFormat = $.fn.dataTable.render.number( '\,', '.', 2, '$ ' ).display;
          $( api.column( 6 ).footer() ).html(numFormat(total_cash_in));
          $( api.column( 7 ).footer() ).html(numFormat(tatal_cash_out));
          $('tr:eq(1) td:eq(1)', api.table().footer()).html(numFormat(total_balance));
        },        
      });
      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';
    });