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

Cost per KwH have a max value at 99 #4410

Open
1 task done
jlestel opened this issue Nov 30, 2024 · 1 comment
Open
1 task done

Cost per KwH have a max value at 99 #4410

jlestel opened this issue Nov 30, 2024 · 1 comment
Labels
area:teslamate Related to TeslaMate core enhancement New feature or request

Comments

@jlestel
Copy link
Contributor

jlestel commented Nov 30, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Can't set a cost per KwH above 99

Expected Behavior

There is countries where the cost per KwH can be above 99 in the local currency.

Steps To Reproduce

Set a cost per kwh at 101 in a geofence
Saved value is 99

Relevant log output

2024-11-30 15:44:41.153 [error] GenServer #PID<0.40937.0> terminating
** (Postgrex.Error) ERROR 22003 (numeric_value_out_of_range) numeric field overflow
A field with precision 6, scale 4 must round to an absolute value less than 10^2.
(ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1096: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto 3.12.4) lib/ecto/repo/schema.ex:834: Ecto.Repo.Schema.apply/4
(ecto 3.12.4) lib/ecto/repo/schema.ex:505: anonymous fn/15 in Ecto.Repo.Schema.do_update/4
(teslamate 1.31.1) lib/teslamate/locations.ex:196: anonymous fn/3 in TeslaMate.Locations.update_geofence/2
(ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1400: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection 2.7.0) lib/db_connection.ex:1756: DBConnection.run_transaction/4
(teslamate 1.31.1) lib/teslamate_web/live/geofence_live/form.ex:158: TeslaMateWeb.GeoFenceLive.Form.save/1
(teslamate 1.31.1) lib/teslamate_web/live/geofence_live/form.ex:62: TeslaMateWeb.GeoFenceLive.Form.handle_event/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-GAzGMUiOkUHEzS8B", event: "event", payload: %{"event" => "save", "type" => "form", "value" => "leaflet-base-layers_29=on&geo_fence%5Blatitude%5D=47.508335&geo_fence%5Blongitude%5D=19.064648&geo_fence%5Bradius%5D=20&geo_fence%5Bname%5D=Lehel&geo_fence%5Bbilling_type%5D=per_kwh&geo_fence%5Bcost_per_unit%5D=199.0000&geo_fence%5Bsession_fee%5D=0.00"}, ref: "13", join_ref: "11"}

Screenshots

Capture d’écran 2024-11-30 à 3 49 41 PM

Additional data

I was thinking about modifying the field to be able to go up to 9999.9999
modify(:cost_per_kwh, :decimal, precision: 8, scale: 4)

But there would still be some countries that could not enter their costs:

Here are the top 10 of those that represent the most for 0.1$:

Iranian Rial (IRR): About 4,250 IRR for 0.1 USD.
Vietnamese Dong (VND): About 2,430 VND for 0.1 USD.
Indonesian Rupiah (IDR): About 1,570 IDR for 0.1 USD.
Laotian Kip (LAK): About 2,060 LAK for 0.1 USD.
Sierra Leonean Leone (SLL): About 2,100 SLL for 0.1 USD.
Uzbekistani Som (UZS): About 1,220 UZS for 0.1 USD.
Guinean Franc (GNF): About 870 GNF for 0.1 USD.
Paraguayan Guarani (PYG): About 730 PYG for 0.1 USD.
Cambodian Riel (KHR): About 410 KHR for 0.1 USD.
Tanzanian Shilling (TZS): About 250 TZS for 0.1 USD.

To make it work worldwide, you would need to go up to 99999.9999
modify(:cost_per_kwh, :decimal, precision: 9, scale: 4)

Type of installation

Docker

Version

1.31.1

@kexplo
Copy link

kexplo commented Dec 4, 2024

+1, I agree. It would be nice if it changes to use the bigger precision as default.

@JakobLichterfeld JakobLichterfeld added enhancement New feature or request area:teslamate Related to TeslaMate core labels Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:teslamate Related to TeslaMate core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants