10 releases (5 breaking)

0.6.0 Jun 4, 2024
0.5.2 Mar 12, 2024
0.5.1 Nov 16, 2023
0.5.0 Jul 11, 2023
0.1.0 Mar 28, 2023

#319 in Parser implementations

Download history 20/week @ 2024-02-21 3/week @ 2024-02-28 93/week @ 2024-03-06 86/week @ 2024-03-13 1/week @ 2024-03-20 13/week @ 2024-03-27 27/week @ 2024-04-03 80/week @ 2024-05-29 54/week @ 2024-06-05

134 downloads per month

MIT/Apache

110KB
2.5K SLoC

OCPI tariffs CLI

This crate provides a binary for doing calculations with OCPI tariffs. Specifically for the OCPI 2.2.1 and OCPI 2.1.1 version.

Installation

First install Rust and then install the OCPI tariffs command line tool:

cargo install ocpi-tariffs-cli

Usage

The binary can be directly executed using ocpi-tariffs. Execute ocpi-tariffs --help for a list of subcommands.

Subcomamands

Analyze

To price a tariff and CDR (Charge detail record) and see a breakdown of the separate periods use analyze:

Analyze a given charge detail record (CDR) against either a provided tariff
structure or a tariff that is contained in the CDR itself.

This command will show you a breakdown of all the calculated costs.

Usage: ocpi-tariffs analyze [OPTIONS]

Options:
  -c, --cdr <CDR>
          A path to the charge detail record in json format.

          If no path is provided the CDR is read from standard in.

  -t, --tariff <TARIFF>
          A path to the tariff structure in json format.

          If no path is provided, then the tariff is inferred to be contained
          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

          [default: Europe/Amsterdam]

  -h, --help
          Print help (see a summary with '-h')

Validate

To price a tariff and CDR and check if the calculation differs from the original CDR use validate:

Validate a given charge detail record (CDR) against either a provided tariff
structure or a tariff that is contained in the CDR itself.

This command will show the differences between the calculated totals and the
totals contained in the provided CDR.

Usage: ocpi-tariffs validate [OPTIONS]

Options:
  -c, --cdr <CDR>
          A path to the charge detail record in json format.

          If no path is provided the CDR is read from standard in.

  -t, --tariff <TARIFF>
          A path to the tariff structure in json format.

          If no path is provided, then the tariff is inferred to be contained
          inside the provided CDR. If the CDR contains multiple tariff
          structures, the first valid tariff will be used.

  -z, --timezone <TIMEZONE>
          Timezone for evaluating any local times contained in the tariff
          structure

          [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')

Dependencies

~5–14MB
~155K SLoC