fleetmap-reports 1.0.595 → 1.0.597

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.595",
3
+ "version": "1.0.597",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -204,7 +204,7 @@ async function exportFuelConsumptionReportToPDF (userData, reportData) {
204
204
  r.date,
205
205
  (r.distance / 1000).toFixed(1),
206
206
  r.spentFuel > 0 ? r.spentFuel : 0,
207
- lang === 'pt-BR' ? r.avgConsumption.byLiters : r.avgConsumption.byKms,
207
+ lang === 'pt-BR' ? (r.avgConsumption.byLiters).toFixed(1) : (r.avgConsumption.byKms).toFixed(1),
208
208
  new Date(r.duration).toLocaleTimeString(),
209
209
  (r.endOdometer / 1000).toFixed(1),
210
210
  r.refueling
@@ -32,7 +32,7 @@ async function createRefuelingReport (from, to, userData, traccar) {
32
32
  }
33
33
 
34
34
  const fuelServicesData = []
35
- if (userData.withOdooServices) {
35
+ if (devices.some(d => d.attributes.odooId)) {
36
36
  fuelServicesData.push(...(await odoo.getOdooFuelServices(traccar, from, to)))
37
37
  }
38
38
 
@@ -122,7 +122,7 @@ function coordsDistance (lon1, lat1, lon2, lat2) {
122
122
  async function calculateRefuelingPositions (userData, d, data) {
123
123
  const refuelingPositions = []
124
124
 
125
- if (userData.withOdooServices && d.attributes.odooId) {
125
+ if (d.attributes.odooId && !data.route[0].attributes.fuel) {
126
126
  console.log(data.fuelServices)
127
127
  data.fuelServices.forEach(s => {
128
128
  const serviceDate = new Date(s.date)
@@ -133,7 +133,7 @@ async function calculateRefuelingPositions (userData, d, data) {
133
133
  const quantity = s.liter
134
134
 
135
135
  if (routeBeforeService.length) {
136
- refuelingPositions.push({ date: s.date, diff: Number.parseFloat(quantity), cost: s.amount })
136
+ refuelingPositions.push({ position: routeBeforeService.slice(-1)[0], date: s.date, diff: Number.parseFloat(quantity), cost: s.amount })
137
137
  }
138
138
  })
139
139
  } else {