From bb9c452eb37be653a4f732d9852ca2dcdafba1bd Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 9 Dec 2013 13:40:32 -0800 Subject: Fix rounding issues and switch to mBTC --- public/js/calculator.coffee | 10 +++++----- public/js/report.coffee | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'public') diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 2de19ee9..1602fb3a 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -21,6 +21,7 @@ $(-> g.commission = parseFloat(get('commission')) g.logo = get('logo') g.errors = [] + g.receivable = 0 if g.user $.ajax( @@ -121,7 +122,6 @@ setupSocket = -> g.websocket.onmessage = (e) -> results = eval('(' + e.data + ')') from_address = '' - total = 0 received = 0 $.each(results.x.out, (i, v) -> @@ -135,7 +135,7 @@ setupSocket = -> input -= v.prev_out.value / 100000000 ) - if (total <= received) + if (g.receivable <= received) $('#amount').blur() $('#payment').hide() $('#received').fadeIn('slow') @@ -150,15 +150,15 @@ setupSocket = -> updateTotal = -> amount = parseFloat($('#amount').val()) - total = amount / g.exchange - total = Math.ceil(total * 10000) / 10 + total = (amount * 1000 / g.exchange).toFixed(5) + g.receivable = (amount / g.exchange).toFixed(8) unless $.isNumeric(total) total = '' $('#total').html(total.toString()) $('#qr').html('') - new QRCode('qr', "bitcoin:#{g.address}?amount=#{total.toString()}") + new QRCode('qr', "bitcoin:#{g.address}?amount=#{g.receivable.toString()}") fail = (msg) -> g.errors.push(msg) diff --git a/public/js/report.coffee b/public/js/report.coffee index 6654c692..372abe7b 100644 --- a/public/js/report.coffee +++ b/public/js/report.coffee @@ -48,6 +48,7 @@ display = (transactions) -> exchange = parseFloat(this.exchange) received = parseFloat(this.received) amount = received * exchange + received *= 1000 $('tbody').append(""" -- cgit v1.2.3