From c7caf71e938a0ad8653457675e64b404f0b5f7f6 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 17 Jul 2015 15:51:12 -0300 Subject: [PATCH] add a new record for network fees --- src/js/controllers/index.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index dc6d91985..344feaf7e 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -608,8 +608,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (txs && txs.length > 0) { allTxs.push(txs); return getHistory(skip + 100, cb); - } - else { + } else { return cb(null, lodash.flatten(allTxs)); } }); @@ -637,7 +636,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.satToUnit = 1 / self.unitToSatoshi; var data = txs; var satToBtc = 1 / 100000000; - var filename = 'Copay-' + (self.alias || self.walletName ) + '.csv'; + var filename = 'Copay-' + (self.alias || self.walletName) + '.csv'; var csvContent = ''; if (!isNode) csvContent = 'data:text/csv;charset=utf-8,'; csvContent += 'Date,Destination,Note,Amount,Currency,Spot Value,Total Value,Tax Type,Category\n'; @@ -650,23 +649,24 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (it.action == 'moved') amount = 0; - if (it.action == 'sent' || it.action=='moved') - amount += it.fees; - - _amount = (it.action == 'sent' ? '-' : '') + (amount * satToBtc).toFixed(8); - _note = formatString((it.message ? 'Note: ' + it.message + ' - ' : '') + 'TxId: ' + it.txid + ' Fee'+ (it.fees * satToBtc).toFixed(8)) ; + _amount = (it.action == 'sent' ? '-' : '') + (amount * satToBtc).toFixed(8); + _note = formatString((it.message ? it.message : '') + ' TxId: ' + it.txid + ' Fee:' + (it.fees * satToBtc).toFixed(8)); if (it.action == 'moved') - _note += ' Moved:' + (it.amount * satToBtc).toFixed(8) + _note += ' Moved:' + (it.amount * satToBtc).toFixed(8) dataString = formatDate(it.time * 1000) + ',' + formatString(it.addressTo) + ',' + _note + ',' + _amount + ',BTC,,,,'; - csvContent += index < data.length ? dataString + "\n" : dataString; + csvContent += dataString + "\n"; + + if (it.fees && (it.action == 'moved' || it.action == 'sent')) { + var _fee = (it.fees * satToBtc).toFixed(8) + csvContent += formatDate(it.time * 1000) + ',Bitcoin Network Fees,, -' + _fee + ',BTC,,,,' + "\n"; + } }); if (isNode) { saveFile('#export_file', csvContent); - } - else { + } else { var encodedUri = encodeURI(csvContent); var link = document.createElement("a"); link.setAttribute("href", encodedUri);