-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseLine.js
More file actions
53 lines (41 loc) · 1.01 KB
/
Copy pathparseLine.js
File metadata and controls
53 lines (41 loc) · 1.01 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function parseLine (line) {
if (line === '') {
return null;
}
const lineArr = line.split('\t');
// 0 - Bokningsdag
// 1 - Valutadag
// 2 - Betalningsdag
// 3 - Belopp
// 4 - Mottagare/Betalare
// 5 - Kontonummer
// 6 - BIC
// 7 - Kontotransaktion
// 8 - Referens
// 9 - Betalarens referens
// 10 - Meddelande
// 11 - Kortets nummer
// 12 - Kvitto
const dateParts = lineArr[2].split('.');
const date = dateParts[0] + '/' + dateParts[1] + '/' + dateParts[2];
const payee = lineArr[4];
const memo = lineArr[10];
let amount = lineArr[3].replace(',', '.');
amount = parseFloat(amount);
let outflow = 0;
let inflow = 0;
if (amount > 0) {
inflow = amount;
} else {
outflow = -1 * amount;
}
const payment = {
date: date,
payee: payee,
memo: '"' + memo + '"',
outflow: outflow,
inflow: inflow,
};
return payment;
}
module.exports = parseLine;