-
Notifications
You must be signed in to change notification settings - Fork 2
/
Print.js
31 lines (22 loc) · 1.1 KB
/
Print.js
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
var Print = (array_transactions, typeSort) => {
var sprintf = require("sprintf-js").sprintf;
const sortBy = require("./SortBy");
// const parser = require("./parser");
// array_transactions = parser(file);
sortBy(array_transactions, typeSort);
// console.log(sprintf("%5j",array_transactions));
for (transaccion in array_transactions) {
var movements = (array_transactions[transaccion]["movements"].length);
var date = array_transactions[transaccion].date
var description = array_transactions[transaccion].description
console.log();
console.log(sprintf("%5s %5s", date, description));
for (var i=0; i<movements; i++) {
var amount = array_transactions[transaccion]["movements"][i]["amount"];
var curr = array_transactions[transaccion]["movements"][i]["currency"];
var desc = array_transactions[transaccion]["movements"][i]["description"];
console.log(' ' +sprintf("%-20s %40s", desc, `${curr} ${amount}`));
}
}
}
module.exports = Print;