Guest organisation
OCPI
Learn reference
Guest organisation
OCPI
Learn reference

A retry creates a second CDR ID

Advanced · 4 min

OCPI 2.1.1, 2.2.1 and 2.3.0

Showing OCPI 2.2.1. Physical and billing-system events are authored examples.

Step 2 of 2 · Charged twice for one charge
cdrsCPOsendseMSPreceives

Authored problem

cdrsCPOsendseMSPreceivesDriverActor

Authored problem

Legend

The line follows the selected step. Actor dots identify the parties; they show no conformance verdict.

Step 2 of 2 · Paused

Selected step

All 3 actors

CPO · eMSP · Driver

Selected exchange

In this authored example the connection drops before the CPO sees the answer, and its billing system sends the same visit again under a new CDR id, CDR-NL-GCH-88402. The eMSP stores two CDRs and bills the customer twice.

CPO → eMSP · cdrs

Authored observation

One charge is now billed twice, because a retry created a second CDR instead of re-sending the first.

The duplicate customer charge is an authored billing-system observation, not a rule that every second CDR for a Session must fail. Sent CDRs cannot be changed or deleted. To correct a sent CDR, send a Credit CDR with a different ID, credit = true, credit_reference_id naming the original and negative original total_cost. A fresh corrected CDR may follow. In the reading ChargerDojo uses, which the spec does not settle, re-sending the same CDR with the same owner, id and content is a retry the receiver accepts; different content under the same owner and id is the change the spec forbids.

Sources (4)
"Although there is no requirement to send CDRs in (semi-) realtime, it is seen as good practice to send them as soon as possible. But if there is an agreement between parties to send them, for example, once a month, that is also allowed by OCPI."OCPI 2.2.1 CDRs module · #mod_cdrs_cdrs_module"Because a CDR is for billing purposes, it cannot be changed or replaced once sent to the eMSP. Changes are simply not allowed."OCPI 2.2.1 CDRs module · #mod_cdrs_flow_and_lifecyclecountry_code · CiString(2) · cardinality 1: ISO-3166 alpha-2 country code of the CPO that 'owns' this CDR. party_id · CiString(3) · cardinality 1: ID of the CPO that 'owns' this CDR (following the ISO-15118 standard). id · CiString(39) · cardinality 1: Uniquely identifies the CDR, the ID SHALL be unique per `country_code`/`party_id` combination. This field is longer than the usual 36 characters to allow for credit CDRs to have something appended to the original ID. Normal (non-credit) CDRs SHALL only have an ID with a maximum length of 36. start_date_time · DateTime · cardinality 1: Start timestamp of the charging session, or in-case of a reservation (before the start of a session) the start of the reservation. end_date_time · DateTime · cardinality 1: The timestamp when the session was completed/finished, charging might have finished before the session ends, for example: EV is full, but parking cost also has to be paid. session_id · CiString(36) · cardinality ?: Unique ID of the Session for which this CDR is sent. Is only allowed to be omitted when the CPO has not implemented the Sessions module or this CDR is the result of a reservation that never became a charging session, thus no OCPI Session. cdr_token · CdrToken · cardinality 1: Token used to start this charging session, including all the relevant information to identify the unique token. auth_method · AuthMethod · cardinality 1: Method used for authentication. Multiple <mod_cdrs_authmethod_enum,AuthMethods>> are possible during a charging sessions, for example when the session was started with a reservation: ReserveNow: `COMMAND`. When the driver arrives and starts charging using a Token that is whitelisted: `WHITELIST`. The last method SHALL be used in the CDR. authorization_reference · CiString(36) · cardinality ?: Reference to the authorization given by the eMSP. When the eMSP provided an `authorization_reference` in either: real-time authorization, StartSession or ReserveNow, this field SHALL contain the same value. When different `authorization_reference` values have been given by the eMSP that are relevant to this Session, the last given value SHALL be used here. cdr_location · CdrLocation · cardinality 1: Location where the charging session took place, including only the relevant EVSE and Connector. meter_id · string(255) · cardinality ?: Identification of the Meter inside the Charge Point. currency · string(3) · cardinality 1: Currency of the CDR in ISO 4217 Code. tariffs · Tariff · cardinality *: List of relevant Tariffs, see: Tariff. When relevant, a _Free of Charge_ tariff should also be in this list, and point to a defined _Free of Charge_ Tariff. charging_periods · ChargingPeriod · cardinality +: List of Charging Periods that make up this charging session. signed_data · SignedData · cardinality ?: Signed data that belongs to this charging Session. total_cost · Price · cardinality 1: Total sum of all the costs of this transaction in the specified currency. total_fixed_cost · Price · cardinality ?: Total sum of all the fixed costs in the specified currency, except fixed price components of parking and reservation. The cost not depending on amount of time/energy used etc. Can contain costs like a start tariff. total_energy · number · cardinality 1: Total energy charged, in kWh. total_energy_cost · Price · cardinality ?: Total sum of all the cost of all the energy used, in the specified currency. total_time · number · cardinality 1: Total duration of the charging session (including the duration of charging and not charging), in hours. total_time_cost · Price · cardinality ?: Total sum of all the cost related to duration of charging during this transaction, in the specified currency. total_parking_time · number · cardinality ?: Total duration of the charging session where the EV was not charging (no energy was transferred between EVSE and EV), in hours. total_parking_cost · Price · cardinality ?: Total sum of all the cost related to parking of this transaction, including fixed price components, in the specified currency. total_reservation_cost · Price · cardinality ?: Total sum of all the cost related to a reservation of a Charge Point, including fixed price components, in the specified currency. remark · string(255) · cardinality ?: Optional remark, can be used to provide additional human readable information to the CDR, for example: reason why a transaction was stopped. invoice_reference_id · CiString(39) · cardinality ?: This field can be used to reference an invoice, that will later be send for this CDR. Making it easier to link a CDR to a given invoice. Maybe even group CDRs that will be on the same invoice. credit · boolean · cardinality ?: When set to `true`, this is a Credit CDR, and the field `credit_reference_id` needs to be set as well. credit_reference_id · CiString(39) · cardinality ?: Is required to be set for a Credit CDR. This SHALL contain the `id` of the CDR for which this is a Credit CDR. home_charging_compensation · boolean · cardinality ?: When set to `true`, this CDR is for a charging session using the home charger of the EV Driver for which the energy cost needs to be financial compensated to the EV Driver. last_updated · DateTime · cardinality 1: Timestamp when this CDR was last updated (or created).OCPI 2.2.1 CDRs module · #mod_cdrs_cdr_object"As CDRs are used for billing and can be seen as a kind of invoice, they cannot be deleted. Instead, they have to be credited. When a CPO wants to make changes to a CDR that was already sent to the eMSP, the CPO has to send a Credit CDR for the first CDR. This credit CDR SHALL have a different CDR.id which can be a completely different number, or it can be the id of the original CDR with something appended like for example: `-C` to make it unique again. To indicate that a CDR is a Credit CDR, the `credit` field has to be set to `true`. The Credit CDR references the old CDR via the `credit_reference_id` field, which SHALL contain the `id` of the original CDR. The Credit CDR will contain all the data of the original CDR. Only the values in the `total_cost` field SHALL contain the negative amounts of the original CDR. After having sent the Credit CDR, the CPO can send a new CDR with a new unique ID and the fields: `credit` and `credit_reference_id` omitted."OCPI 2.2.1 CDRs module · #mod_cdrs_credit_cdrs
Why this matters

The CPO creates the billing-relevant CDR after charging ends. Delivery may be delayed by agreement, including monthly delivery.

Explore the cdrs module →

This outcome is written for the lesson. A sandbox run cannot produce it.