tandemdrive / ocpi-tariffs

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

Parking tariff with grace period not working #52

Closed jmluy closed 1 year ago

jmluy commented 1 year ago

When I have a tariff that's supposed to be free for the 30 minutes, it doesn't seem to take into account the restrictions in min_duration and max_duration.

{
  "country_code": "NL",
  "party_id": "TDR",
  "id": "TDR1",
  "currency": "EUR",
  "elements": [
    {
      "price_components": [
        {
          "type": "PARKING_TIME",
          "price": 0.0,
          "vat": 0.0,
          "step_size": 1
        }
      ],
      "restrictions": {
        "min_duration": 0,
        "max_duration": 1800
      }
    },
    {
      "price_components": [
        {
          "type": "PARKING_TIME",
          "price": 3.0,
          "vat": 0.0,
          "step_size": 300
        }
      ],
      "restrictions": {
        "min_duration": 1800
      }
    },
    {
      "price_components": [
        {
          "type": "FLAT",
          "price": 0.50,
          "vat": 20.0,
          "step_size": 1
        },
        {
          "type": "ENERGY",
          "price": 0.25,
          "vat": 10.0,
          "step_size": 1
        }
      ]
    }
  ],
  "end_date_time": "2019-06-30T23:59:59Z",
  "last_updated": "2018-12-17T17:15:01Z"
}
remkop22 commented 1 year ago

Hi @jmluy,

Thanks for your report!

I've reproduced the problem and indeed found that a min_duration or max_duration restriction does not work correctly together with PARKING_TIME. The problem was that the actual charging duration of the session was being compared to the restriction instead of the total duration of the session.

I'll implement a fix as soon as possible.

jmluy commented 1 year ago

Does this update the tool at https://tools.tandemdrive.com/?

remkop22 commented 1 year ago

I'll be making a release today, it will then update the tool.

remkop22 commented 1 year ago

@jmluy It's live at https://tools.tandemdrive.com/

Let me know if the tool now produces the results that you are expecting with this fix.

jmluy commented 1 year ago

@jmluy It's live at https://tools.tandemdrive.com/

Let me know if the tool now produces the results that you are expecting with this fix.

Thanks, will try to check this.