tandemdrive / ocpi-tariffs

OCPI tariff calculations
Apache License 2.0
38 stars 9 forks source link

Doesn't see restrictions #57

Closed gridar closed 1 year ago

gridar commented 1 year ago

Hello Thanks for openning your tariff calculator to the community !

I was testing it and saw a bug: If you use a time restriction on a energy price component, it doesn't affect the Totals array For exemple : here is a charge that start at 20h, take until 21h to charge 10kwh, then until 22h to charge an other 10kwh :

"start_date_time": "2015-06-29T20:00:00Z",
"end_date_time": "2015-06-29T22:00:00Z",
"charging_periods": [
    {
      "start_date_time": "2015-06-29T20:00:00Z",
      "dimensions": [
        {
          "type": "ENERGY",
          "volume": 10
        }
      ]
    },
    {
      "start_date_time": "2015-06-29T21:00:00Z",
      "dimensions": [
        {
          "type": "ENERGY",
          "volume": 10
        }
      ]
    }
  ],

and here is a tariff that change the kwh's price after 21h :

"elements": [
    {
      "restriction": {
        "end_time": "21:00"
      },
      "price_components": [{
        "type": "ENERGY",
        "price": 1,
        "step_size": 1
      }]
    },
    {
      "price_components": [{
        "type": "ENERGY",
        "price": 10,
        "step_size": 1
      }]
    }
  ],

but the output will still be 20 for the kwhs instead of 110 (10 for 10kwh before 21h and 100 for 10kwh after 21h)

Cheers !

rudolphfroger commented 1 year ago

Thanks for reporting this. The tool should take restrictions into account so something seems to be wrong. We'll look into this next week.

remopas-ds commented 1 year ago

Hi @gridar

I've looked into your example and noticed a small typo in the tariff. In the first tariff element, restriction should be restrictions. Arguably, the tool should have warned you about this, but currently it just thinks there are no restrictions at all. I'll have a look if I can add some kind of warning for cases like these.

Amending your example and trying it out in the tool, the results seem like I would expect.

Do note that the web-tool has the Europe/Amsterdam time zone selected by default. The results you are expecting seem be to in UTC timezone.

It would be great if you could run your example in this configuration and confirm if the results are as if you expect. If not, please let us know and we can try to improve the tool.

Thanks!

gridar commented 1 year ago

Oh you're right ! I changed the exemple to use restrictions and set the times in Europe/Amsterdam and it is working great. Thanks