@furkot/export-expense-report 0.0.1 → 0.0.3

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.
@@ -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
  ];
@@ -77,9 +78,12 @@ function* expenseReport(options) {
77
78
  arrival_time,
78
79
  cost,
79
80
  costRoute,
81
+ day,
80
82
  distance,
81
83
  name,
84
+ nights,
82
85
  notes,
86
+ per_diem,
83
87
  tags
84
88
  } = steps[i];
85
89
  const to = name || address;
@@ -92,10 +96,11 @@ function* expenseReport(options) {
92
96
  line.push(format.description(
93
97
  [from, to].join(' - '),
94
98
  format.distance(distance, 1, units, true),
95
- currency
99
+ format.amount(mileageRate / 100, 2, currency)
96
100
  ));
97
101
  line.push(date);
98
102
  line.push(format.distance(distance * mileageRate / 100, 2, units));
103
+ line.push(currency);
99
104
  line.push('mileage');
100
105
 
101
106
  lines.push(prepare(line));
@@ -103,9 +108,10 @@ function* expenseReport(options) {
103
108
  if (costRoute) {
104
109
  const line = [];
105
110
 
106
- line.push(format.description([from, to].join(' - '), currency));
111
+ line.push(format.description([from, to].join(' - ')));
107
112
  line.push(date);
108
113
  line.push(format.amount(costRoute / 100, 2));
114
+ line.push(currency);
109
115
  line.push('tolls');
110
116
 
111
117
  lines.push(prepare(line));
@@ -113,14 +119,32 @@ function* expenseReport(options) {
113
119
  if (cost) {
114
120
  const line = [];
115
121
 
116
- line.push(format.description(name || address, tags, currency));
122
+ line.push(format.description(name || address, tags,
123
+ nights > 1 &&
124
+ [
125
+ format.amount(cost / 100, 2, currency),
126
+ `${day + 1}/${nights}`
127
+ ]));
117
128
  line.push(date);
118
- line.push(format.amount(cost / 100, 2));
129
+ line.push(format.amount(cost / (nights || 1) / 100, 2));
130
+ line.push(currency);
119
131
  line.push(getType(steps[i]));
120
132
  line.push(notes);
121
133
 
122
134
  lines.push(prepare(line));
123
135
  }
136
+ if (per_diem) {
137
+ const line = [];
138
+
139
+ line.push(format.description(address || name, tags));
140
+ line.push(date);
141
+ line.push(format.amount(per_diem / 100, 2));
142
+ line.push(currency);
143
+ line.push('per diem');
144
+ line.push(notes);
145
+
146
+ lines.push(prepare(line));
147
+ }
124
148
 
125
149
  from = to;
126
150
  return lines;
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
- return amt.toFixed(precision);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furkot/export-expense-report",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Generate CSV expense report from Furkot trip data.",
5
5
  "author": {
6
6
  "name": "Natalia Kowalczyk",