@furkot/export-expense-report 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/expense-report.js +10 -4
- package/lib/format.js +6 -2
- package/package.json +1 -1
package/lib/expense-report.js
CHANGED
|
@@ -64,6 +64,7 @@ function* expenseReport(options) {
|
|
|
64
64
|
'Description',
|
|
65
65
|
'Date',
|
|
66
66
|
'Amount',
|
|
67
|
+
'Currency',
|
|
67
68
|
'Type',
|
|
68
69
|
'Notes'
|
|
69
70
|
];
|
|
@@ -79,6 +80,7 @@ function* expenseReport(options) {
|
|
|
79
80
|
costRoute,
|
|
80
81
|
distance,
|
|
81
82
|
name,
|
|
83
|
+
nights,
|
|
82
84
|
notes,
|
|
83
85
|
tags
|
|
84
86
|
} = steps[i];
|
|
@@ -92,10 +94,11 @@ function* expenseReport(options) {
|
|
|
92
94
|
line.push(format.description(
|
|
93
95
|
[from, to].join(' - '),
|
|
94
96
|
format.distance(distance, 1, units, true),
|
|
95
|
-
currency
|
|
97
|
+
format.amount(mileageRate / 100, 2, currency)
|
|
96
98
|
));
|
|
97
99
|
line.push(date);
|
|
98
100
|
line.push(format.distance(distance * mileageRate / 100, 2, units));
|
|
101
|
+
line.push(currency);
|
|
99
102
|
line.push('mileage');
|
|
100
103
|
|
|
101
104
|
lines.push(prepare(line));
|
|
@@ -103,9 +106,10 @@ function* expenseReport(options) {
|
|
|
103
106
|
if (costRoute) {
|
|
104
107
|
const line = [];
|
|
105
108
|
|
|
106
|
-
line.push(format.description([from, to].join(' - ')
|
|
109
|
+
line.push(format.description([from, to].join(' - ')));
|
|
107
110
|
line.push(date);
|
|
108
111
|
line.push(format.amount(costRoute / 100, 2));
|
|
112
|
+
line.push(currency);
|
|
109
113
|
line.push('tolls');
|
|
110
114
|
|
|
111
115
|
lines.push(prepare(line));
|
|
@@ -113,9 +117,11 @@ function* expenseReport(options) {
|
|
|
113
117
|
if (cost) {
|
|
114
118
|
const line = [];
|
|
115
119
|
|
|
116
|
-
line.push(format.description(name || address, tags,
|
|
120
|
+
line.push(format.description(name || address, tags,
|
|
121
|
+
nights > 1 && format.amount(cost / 100, 2, currency)));
|
|
117
122
|
line.push(date);
|
|
118
|
-
line.push(format.amount(cost / 100, 2));
|
|
123
|
+
line.push(format.amount(cost / (nights || 1) / 100, 2));
|
|
124
|
+
line.push(currency);
|
|
119
125
|
line.push(getType(steps[i]));
|
|
120
126
|
line.push(notes);
|
|
121
127
|
|
package/lib/format.js
CHANGED
|
@@ -9,9 +9,13 @@ function pad(n) {
|
|
|
9
9
|
return n < 10 ? '0' + n : n;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function amount(amt, precision) {
|
|
12
|
+
function amount(amt, precision, currency) {
|
|
13
13
|
precision = precision || 0;
|
|
14
|
-
|
|
14
|
+
const result = amt.toFixed(precision);
|
|
15
|
+
if (currency) {
|
|
16
|
+
return `${result} ${currency}`;
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
function date(d) {
|