aboutsummaryrefslogtreecommitdiffstats
path: root/js/report.js
blob: 6cacf07726be79bb34e22d99d26899b0d691446e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$(function() {
  $('#date').datepicker();

  $.getJSON('transactions.json', function(data) {
    $.each(data.transactions, function() {
      var keys = Object.keys(this);
      var transaction = this;

      $.each(keys, function(i,v) {
        $('tbody tr:last td:eq(' + i + ')').html(transaction[v]);
      });

      $('tbody:last').append($('tbody tr:last').clone());
    });
    $('tbody tr:last').remove();

    var btc = 0;
    $('td:nth-child(4)').each(function() {
      btc += parseFloat($(this).html());
    });
    $('#btc').html(btc);

    var cad = 0;
    $('td:nth-child(5)').each(function() {
      cad += parseFloat($(this).html());
    });
    $('#cad').html(cad);
  });
});