@furkot/export-expense-report 0.0.2 → 0.0.4
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 +26 -5
- package/package.json +1 -1
package/lib/expense-report.js
CHANGED
|
@@ -55,7 +55,8 @@ function* expenseReport(options) {
|
|
|
55
55
|
metadata: {
|
|
56
56
|
currency,
|
|
57
57
|
units,
|
|
58
|
-
mileageRate
|
|
58
|
+
mileageRate,
|
|
59
|
+
mode: tripMode
|
|
59
60
|
},
|
|
60
61
|
routes
|
|
61
62
|
} = options;
|
|
@@ -78,23 +79,27 @@ function* expenseReport(options) {
|
|
|
78
79
|
arrival_time,
|
|
79
80
|
cost,
|
|
80
81
|
costRoute,
|
|
82
|
+
day,
|
|
81
83
|
distance,
|
|
84
|
+
mode,
|
|
82
85
|
name,
|
|
83
86
|
nights,
|
|
84
87
|
notes,
|
|
88
|
+
per_diem,
|
|
85
89
|
tags
|
|
86
90
|
} = steps[i];
|
|
87
91
|
const to = name || address;
|
|
88
92
|
const date = format.date(new Date(arrival_time));
|
|
93
|
+
const inTripMode = mode === undefined || mode === tripMode;
|
|
89
94
|
const lines = [];
|
|
90
95
|
|
|
91
|
-
if (mileageRate && distance) {
|
|
96
|
+
if (mileageRate && distance && inTripMode) {
|
|
92
97
|
const line = [];
|
|
93
98
|
|
|
94
99
|
line.push(format.description(
|
|
95
100
|
[from, to].join(' - '),
|
|
96
101
|
format.distance(distance, 1, units, true),
|
|
97
|
-
format.amount(mileageRate / 100,
|
|
102
|
+
format.amount(mileageRate / 100, 3, currency)
|
|
98
103
|
));
|
|
99
104
|
line.push(date);
|
|
100
105
|
line.push(format.distance(distance * mileageRate / 100, 2, units));
|
|
@@ -110,7 +115,7 @@ function* expenseReport(options) {
|
|
|
110
115
|
line.push(date);
|
|
111
116
|
line.push(format.amount(costRoute / 100, 2));
|
|
112
117
|
line.push(currency);
|
|
113
|
-
line.push('tolls');
|
|
118
|
+
line.push(inTripMode ? 'tolls' : 'transportation');
|
|
114
119
|
|
|
115
120
|
lines.push(prepare(line));
|
|
116
121
|
}
|
|
@@ -118,7 +123,11 @@ function* expenseReport(options) {
|
|
|
118
123
|
const line = [];
|
|
119
124
|
|
|
120
125
|
line.push(format.description(name || address, tags,
|
|
121
|
-
nights > 1 &&
|
|
126
|
+
nights > 1 &&
|
|
127
|
+
[
|
|
128
|
+
format.amount(cost / 100, 2, currency),
|
|
129
|
+
`${day + 1}/${nights}`
|
|
130
|
+
]));
|
|
122
131
|
line.push(date);
|
|
123
132
|
line.push(format.amount(cost / (nights || 1) / 100, 2));
|
|
124
133
|
line.push(currency);
|
|
@@ -127,6 +136,18 @@ function* expenseReport(options) {
|
|
|
127
136
|
|
|
128
137
|
lines.push(prepare(line));
|
|
129
138
|
}
|
|
139
|
+
if (per_diem) {
|
|
140
|
+
const line = [];
|
|
141
|
+
|
|
142
|
+
line.push(format.description(address || name, tags));
|
|
143
|
+
line.push(date);
|
|
144
|
+
line.push(format.amount(per_diem / 100, 2));
|
|
145
|
+
line.push(currency);
|
|
146
|
+
line.push('per diem');
|
|
147
|
+
line.push(notes);
|
|
148
|
+
|
|
149
|
+
lines.push(prepare(line));
|
|
150
|
+
}
|
|
130
151
|
|
|
131
152
|
from = to;
|
|
132
153
|
return lines;
|