From 1387766f4fc1c9354730c07bebf0a9f013e4c6ac Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 10 Dec 2012 17:06:50 -0800 Subject: Check for transactions existence --- public/js/report.coffee | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/public/js/report.coffee b/public/js/report.coffee index 28ec988b..225f4392 100644 --- a/public/js/report.coffee +++ b/public/js/report.coffee @@ -28,14 +28,32 @@ filterDates = -> display = (transactions) -> $('tbody tr').remove() + $('thead, tfoot').show() + + if transactions.length is 0 + $('tbody').append(""" + + + No transactions were found during the specified time period + + + """) + $('thead, tfoot').hide() + $.each(transactions, -> + exchange = parseFloat(this.exchange) + received = parseFloat(this.received) + amount = received * exchange + + return true unless !isNaN(parseFloat(amount)) && isFinite(amount) + $('tbody').append(""" #{this.date} #{this.address} - #{parseFloat(this.exchange).toFixed(2)} - #{parseFloat(this.received).toFixed(2)} - #{(this.received * this.exchange).toFixed(2)} + #{exchange.toFixed(2)} + #{received.toFixed(2)} + #{amount.toFixed(2)} """) ) -- cgit v1.2.3