Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new dashboard for reporting to Dutch tax & matching of Titles/labels now match pie-charts in Charging stats #998

Merged
merged 5 commits into from
Oct 13, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grafana/dashboards/reports/dutch-tax.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "WITH data AS (\n SELECT\n round(extract(epoch FROM start_date)) * 1000 AS start_date_ts,\n car.id as car_id,\n -- Columns\n drives.id as drive_id,\n start_date,\n start_km,\n end_date,\n end_km,\n CONCAT_WS(', ', nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), ''), start_address.city) AS start_address,\n CONCAT_WS(', ', nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), ''), end_address.city) AS end_address,\n duration_min,\n distance\n FROM drives\n LEFT JOIN addresses start_address ON start_address_id = start_address.id\n LEFT JOIN addresses end_address ON end_address_id = end_address.id\n LEFT JOIN cars car ON car.id = drives.car_id\n WHERE $__timeFilter(start_date) AND drives.car_id = $car_id\n ORDER BY drive_id DESC\n)\nSELECT\n start_date_ts,\n car_id,\n -- Columns\n drive_id,\n start_date as start_date,\n convert_km(start_km::numeric, '$length_unit') AS start_km_$length_unit,\n start_address,\n end_date as end_date,\n convert_km(end_km::numeric, '$length_unit') AS end_km_$length_unit,\n end_address,\n duration_min,\n convert_km(distance::numeric, '$length_unit') AS distance_$length_unit\nFROM data;",
"rawSql": "WITH data AS (\n SELECT\n drives.id as drive_id,\n round(extract(epoch FROM start_date)) * 1000 AS start_date_ts,\n round(extract(epoch FROM end_date)) * 1000 AS end_date_ts,\n start_km,\n end_km,\n COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city)) AS start_address,\n COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)) AS end_address,\n duration_min,\n distance\n FROM drives\n LEFT JOIN addresses start_address ON start_address_id = start_address.id\n LEFT JOIN addresses end_address ON end_address_id = end_address.id\n LEFT JOIN geofences start_geofence ON start_geofence_id = start_geofence.id\n LEFT JOIN geofences end_geofence ON end_geofence_id = end_geofence.id\n LEFT JOIN cars car ON car.id = drives.car_id\n WHERE $__timeFilter(start_date) AND drives.car_id = $car_id\n ORDER BY drive_id DESC\n)\nSELECT\n drive_id,\n start_date_ts,\n convert_km(start_km::numeric, '$length_unit') as start_$length_unit,\n start_address,\n end_date_ts,\n convert_km(end_km::numeric, '$length_unit') as end_$length_unit,\n end_address,\n duration_min,\n convert_km(distance::numeric, '$length_unit') AS distance_$length_unit\nFROM data;",
Copy link
Contributor Author

@roadrash2108 roadrash2108 Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was intentionally that I didn't show geofences as the requirement in #989 was to have the address - so I anticipated, that a geofence or location-name wouldn't be valid for the tax-authority....

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I assumed that the same behaviour as in the Drive dashboard would be useful.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adriankumpf : Did you see my concerns regarding "missing start of drives", and the issue where a late start of logging has the consequence that start_km of drive x is not equal to end_km for drive x-1....

It can (will) result in missing km in a tax report - similar to how the current "trip" report goes from start_km of first drive to end_km of last drive... And that is obviously not always the sum of the logged drives...

  • So perhaps a way to cluster subsequent drives with the same tag (same logical trips)???

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You always have to expect that trips can be recorded incompletely or even missing completely. A manual follow-up check will always be necessary imo.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my point - adding the end_km from the previous drive could be of value... It probably shouldn't be visible in a standard report - but when exporting to excel it could be used to quickly do this validation - and adjust in there, since adjust the start_km directly in the database is probably not without implications (or perhaps it is fine to adjust the start_km - and we should aim to allow for that in the frontend?)

"refId": "A",
"select": [
[
Expand Down