Skip to content

Commit

Permalink
Implement OCPI 2.1.1 (#47)
Browse files Browse the repository at this point in the history
* use ocpi-versioning

* move weekdays to unversioned types

* use --all-features for github workflows

* update cli and conversions

* add 211 version to the cli

* update cli readme to include ocpi version flag

* update main readme

* add doc comments for `ocpi-version` flag

* formatting

* update changelog

* use `detect` by default
  • Loading branch information
remkop22 authored Jun 7, 2023
1 parent 6892c9e commit cb598f7
Show file tree
Hide file tree
Showing 22 changed files with 716 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- run: cargo build --workspace --verbose
- run: cargo build --workspace --all-features --verbose

test:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- run: cargo test --workspace --verbose
- run: cargo test --workspace --all-features --verbose

clippy:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## Unreleased

Added library support for OCPI 2.1.1 that can be enabled with feature flag `ocpi-v211`.

Added cli support for OCPI 2.1.1 that can be used by specifying `--ocpi-version v211` or `--ocpi-version detect`.

## 0.3.2 2023-05-30

Fixed a bug in step-size calculation for energy dimension.
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ members = ["cli", "ocpi-tariffs"]
[workspace.dependencies]
chrono-tz = { version = "0.8.2", default-features = false }
serde_json = { version = "1.0", default-features = false }
serde = { version = "1.0", features = ["derive"] }
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
This project provides software for doing calculations with [OCPI](https://evroaming.org/ocpi-background/)
[tariffs](https://github.com/ocpi/ocpi/blob/2.2.1/mod_tariffs.asciidoc#1-tariffs-module).
Specifically for the [`OCPI 2.2.1`](https://evroaming.org/app/uploads/2021/11/OCPI-2.2.1.pdf)
version.
and [`OCPI 2.1.1`](https://github.com/ocpi/ocpi/releases/download/2.1.1-d2/OCPI_2.1.1-d2.pdf) version.

You can test the tariff tool [online](https://tools.tandemdrive.com/).

Expand Down Expand Up @@ -66,11 +66,6 @@ foundation](https://evroaming.org/).
- Produce human consumable receipts which specify the different cost components
that led to the calculated total price.

- Support OCPI version 2.1.1

The tariff structure of version 2.1.1 is (mostly?) a subset of the structure
of 2.2.1 so in practice we expect this project to also be usable on 2.1.1.

## Tariff structure overview

```mermaid
Expand Down
3 changes: 2 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ chrono-tz.workspace = true
chrono = { version = "0.4.24", default-features = false, features = ["alloc", "serde"] }
clap = { version = "4.3.0", features = ["derive"] }
console = { version = "0.15.7" }
ocpi-tariffs = { version = "0.3.2", path = "../ocpi-tariffs" }
ocpi-tariffs = { version = "0.3.2", path = "../ocpi-tariffs", features = ["ocpi-v211"] }
serde_json.workspace = true
serde.workspace = true
tabled = { version = "0.12.0", features = ["color"] }
27 changes: 25 additions & 2 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

This crate provides a binary for doing calculations with [OCPI](https://evroaming.org/ocpi-background/)
[tariffs](https://github.com/ocpi/ocpi/blob/2.2.1/mod_tariffs.asciidoc#1-tariffs-module).
Specifically for the [`OCPI 2.2.1`](https://evroaming.org/app/uploads/2021/11/OCPI-2.2.1.pdf)
version.
Specifically for the [`OCPI 2.2.1`](https://evroaming.org/app/uploads/2021/11/OCPI-2.2.1.pdf)
and [`OCPI 2.1.1`](https://github.com/ocpi/ocpi/releases/download/2.1.1-d2/OCPI_2.1.1-d2.pdf) version.

## Installation

Expand Down Expand Up @@ -48,6 +48,18 @@ Options:
inside the provided CDR. If the CDR contains multiple tariff
structures, the first valid tariff will be used.
-o, --ocpi-version <OCPI_VERSION>
The OCPI version that should be used for the input structures.
If the input consists of version 2.1.1 structures they will be converted to 2.2.1 structures.
The actual calculation and output will always be according to OCPI 2.2.1.
use `detect` to let to tool try to find the matching version.
[default: v221]
[possible values: v221, v211, detect]
-z, --timezone <TIMEZONE>
Timezone for evaluating any local times contained in the tariff
structure
Expand Down Expand Up @@ -91,6 +103,17 @@ Options:
[default: Europe/Amsterdam]
-o, --ocpi-version <OCPI_VERSION>
The OCPI version that should be used for the input structures.
If the input consists of version 2.1.1 structures they will be converted to 2.2.1 structures.
The actual calculation and output will always be according to OCPI 2.2.1.
use `detect` to let to tool try to find the matching version.
[default: v221]
[possible values: v221, v211, detect]
-h, --help
Print help (see a summary with '-h')
```
Loading

0 comments on commit cb598f7

Please sign in to comment.