Skip to content

Commit

Permalink
[ISSUE-434] Increase charge cost scale / kWh
Browse files Browse the repository at this point in the history
  • Loading branch information
baylanger committed Feb 12, 2020
1 parent 59295ce commit af72905
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/teslamate_web/templates/geo_fence/form.html.leex
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
<div class="field">
<div class="control">
<%= text_input f, :cost_per_kwh, class: "input",
type: :number, inputmode: :decimal, min: 0.0, step: 0.01,
placeholder: "0.00",
type: :number, inputmode: :decimal, min: 0.0, step: 0.0001,
placeholder: "0.0000",
phx_hook: "SetLangAttr"
%>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule TeslaMate.Repo.Migrations.LocationBasedChargeCostIncreaseScale do
use Ecto.Migration

def change do
alter table(:geofences) do
modify(:cost_per_kwh, :decimal, precision: 6, scale: 4)
end
end
end

4 changes: 2 additions & 2 deletions test/teslamate/locations/geofences_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule TeslaMate.LocationsGeofencesTest do
latitude: 53.514521,
longitude: 14.350144,
radius: 43,
cost_per_kwh: 0.79
cost_per_kwh: 0.0079
}
@invalid_attrs %{
name: nil,
Expand Down Expand Up @@ -268,7 +268,7 @@ defmodule TeslaMate.LocationsGeofencesTest do
assert geofence.latitude == 53.514521
assert geofence.longitude == 14.350144
assert geofence.radius == 43
assert geofence.cost_per_kwh == Decimal.from_float(0.79)
assert geofence.cost_per_kwh == Decimal.from_float(0.0079)
assert geofence.sleep_mode_blacklist == [car]
assert geofence.sleep_mode_whitelist == [car]

Expand Down
4 changes: 2 additions & 2 deletions test/teslamate/log/log_charging_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ defmodule TeslaMate.LogChargingTest do

assert cproc.charge_energy_added == 12.77
assert cproc.charge_energy_used == 12.455230833333333
assert cproc.cost == Decimal.new("3.11380770833333325")
assert cproc.cost == Decimal.new("3.1138077083333332500")
end

test "charge cost can be zero" do
Expand All @@ -426,7 +426,7 @@ defmodule TeslaMate.LogChargingTest do

assert cproc.charge_energy_added == nil
assert cproc.charge_energy_used == 12.576319999999997
assert cproc.cost == Decimal.new("0E-17")
assert cproc.cost == Decimal.new("0E-19")
end

test "sets charge cost to zero if free supercharging is enabled" do
Expand Down

0 comments on commit af72905

Please sign in to comment.