|
@@ -178,6 +178,16 @@ function handleStateChange(hash) {
|
178
|
178
|
|
179
|
179
|
// -----------------------------------------------------------------------------
|
180
|
180
|
|
|
181
|
+/**
|
|
182
|
+ * Formats the specified number in a manner suitable for a currency. That is,
|
|
183
|
+ * fixed to two decimal places and with a thousand separator every 3 digits.
|
|
184
|
+ *
|
|
185
|
+ * @return A string representation of the number as a currency
|
|
186
|
+ */
|
|
187
|
+Number.prototype.toCurrency = function() {
|
|
188
|
+ return this.toFixed(2).replace(/([0-9])(?=([0-9]{3})+\.)/g, '$1,');
|
|
189
|
+};
|
|
190
|
+
|
181
|
191
|
/**
|
182
|
192
|
* Adds an 'alt' class to every other visible row in the specified table.
|
183
|
193
|
*
|
|
@@ -245,7 +255,7 @@ function ensureExpanded(oldList, newList) {
|
245
|
255
|
$('.hidden' + id).show();
|
246
|
256
|
var handle = $('#collapseHandle' + id);
|
247
|
257
|
handle.text(handle.text().replace(/\+/, '-'));
|
248
|
|
- handle.parents('tr').find('td.amount').text(handle.data('single'));
|
|
258
|
+ handle.parents('tr').find('td.amount').text(parseFloat(handle.data('single')).toCurrency());
|
249
|
259
|
}
|
250
|
260
|
});
|
251
|
261
|
|
|
@@ -255,7 +265,7 @@ function ensureExpanded(oldList, newList) {
|
255
|
265
|
$('.hidden' + id).hide();
|
256
|
266
|
var handle = $('#collapseHandle' + id);
|
257
|
267
|
handle.text(handle.text().replace(/\-/, '+'));
|
258
|
|
- handle.parents('tr').find('td.amount').text(handle.data('total'));
|
|
268
|
+ handle.parents('tr').find('td.amount').text(parseFloat(handle.data('total')).toCurrency());
|
259
|
269
|
}
|
260
|
270
|
});
|
261
|
271
|
|
|
@@ -362,12 +372,12 @@ function showSelectedMonths(start, end, incoming, outgoing, categoryFilter, expa
|
362
|
372
|
$('<td/>').text(this.Type ? this.Type : 'Other').appendTo(tr);
|
363
|
373
|
$('<td/>').text(this.Category ? this.Category : '').appendTo(tr);
|
364
|
374
|
$('<td/>').addClass('desc').text(this.Description).appendTo(tr);
|
365
|
|
- $('<td/>').addClass('amount').text(this.Amount).appendTo(tr);
|
|
375
|
+ $('<td/>').addClass('amount').text(this.Amount.toCurrency()).appendTo(tr);
|
366
|
376
|
});
|
367
|
377
|
|
368
|
378
|
var tr = $('<tr/>').addClass('data total').appendTo(table);
|
369
|
379
|
$('<th colspan="4" class="total">Total</th>').appendTo(tr);
|
370
|
|
- $('<td class="amount"></td>').text(total).appendTo(tr);
|
|
380
|
+ $('<td class="amount"></td>').text(total.toCurrency()).appendTo(tr);
|
371
|
381
|
|
372
|
382
|
colourTableRows(table);
|
373
|
383
|
drawCategoryPieChart(included, incoming);
|