aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/report.coffee
blob: b8a85f3edca73751aa7a5487b47c29f361dceadf (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
30
31
32
#= require jquery-1.8.2.min.js
#= require jquery-ui-1.9.0.custom.min.js

$(->
  $('.date').datepicker()

  $.getJSON('transactions', (data) ->
    $.each(data.transactions, ->
      $('tbody').append("""
        <tr>
          <td>#{this.date}</td>
          <td>#{this.address}</td>
          <td>#{parseFloat(this.exchange).toFixed(2)}</td>
          <td>#{parseFloat(this.received).toFixed(2)}</td>
          <td>#{(this.received * this.exchange).toFixed(2)}</td>
        </tr>
      """)
    )

    btc = 0
    $('td:nth-child(4)').each(->
      btc += parseFloat($(this).html())
    )
    $('#btc').html(btc.toFixed(2))

    cad = 0
    $('td:nth-child(5)').each(->
      cad += parseFloat($(this).html())
    )
    $('#cad').html(cad.toFixed(2))
  )
)