tandemdrive / ocpi-tariffs

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

Simplifing / normalizing tariffs #58

Open rudolphfroger opened 1 year ago

rudolphfroger commented 1 year ago

It would be great if the tool could simplify tariffs by removing everything which has no effect.

Example with price components which do nothing:

{
  "id": "EXAMPLE",
  "currency": "EUR",
  "elements": [
    {
      "price_components": [
        {
          "type": "FLAT",
          "price": 0,
          "step_size": 1
        },
        {
          "type": "TIME",
          "price": 0,
          "step_size": 1
        },
        {
          "type": "ENERGY",
          "price": 0.54,
          "step_size": 1
        }
      ]
    }
  ],
  "last_updated": "2023-10-04T07:15:01.745Z"
}

Is equal to:

{
  "id": "EXAMPLE",
  "currency": "EUR",
  "elements": [
    {
      "price_components": [
        {
          "type": "ENERGY",
          "price": 0.54,
          "step_size": 1
        }
      ]
    }
  ],
  "last_updated": "2023-10-04T07:15:01.745Z"
}

Another typical example are restrictions which do not restrict anything. Such as:

Also having more generic tariff elements (for a certain dimension) specified before more restricting elements makes the latter one unnecessary.

I expect that tariffs with these no-op components and no-op restrictions exist because the OCPI tariff structure is generated in a way which always specified these things.