// Auto-generated by automapper-generator. Do not edit.

#![allow(dead_code, unused_imports, non_camel_case_types)]

use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

/// marktrolle for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Marktrolle {
    /// Dokumenten-/Nachrichtenaussteller bzw. -absender
    #[serde(rename = "MS")]
    DokumentenNachrichtenausstellerAbsender,
    /// Nachrichtenempfänger
    #[serde(rename = "MR")]
    Nachrichtenempfaenger,
}

/// rollencodetyp for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Rollencodetyp {
    /// GS1
    #[serde(rename = "9")]
    Gs1,
    /// DE, BDEW (Bundesverband der Energie- und Wasserwirtschaft e.V.)
    #[serde(rename = "293")]
    DeBdewBundesverbandEnergieWasserwirtschaftEV,
}

/// dokumenttyp for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Dokumenttyp {
    /// Prozessdatenbericht
    #[serde(rename = "7")]
    Prozessdatenbericht,
    /// Lieferschein
    #[serde(rename = "270")]
    Lieferschein,
    /// Zeitreihen im Rahmen der Bilanzkreisabrechnung
    #[serde(rename = "BK")]
    ZeitreihenRahmenBilanzkreisabrechnung,
    /// normiertes Profil
    #[serde(rename = "Z06")]
    NormiertesProfil,
    /// EEG-Überführungszeitreihe
    #[serde(rename = "Z15")]
    EegUeberfuehrungszeitreihe,
    /// Profilschar
    #[serde(rename = "Z16")]
    Profilschar,
    /// Vergangenheitswerte für TEP mit Referenzmessung
    #[serde(rename = "Z20")]
    VergangenheitswerteTepReferenzmessung,
    /// Gasbeschaffenheitsdaten
    #[serde(rename = "Z21")]
    Gasbeschaffenheitsdaten,
    /// Bilanzierte Menge (MMMA)
    #[serde(rename = "Z23")]
    BilanzierteMengeMmma,
    /// Allokationsliste (MMMA)
    #[serde(rename = "Z24")]
    AllokationslisteMmma,
    /// Bewegungsdaten im Kalenderjahr vor Lieferbeginn
    #[serde(rename = "Z27")]
    BewegungsdatenKalenderjahrVorLieferbeginn,
    /// Energiemenge und Leistungsmaximum
    #[serde(rename = "Z28")]
    EnergiemengeLeistungsmaximum,
    /// Tägliche Summenzeitreihe
    #[serde(rename = "Z39")]
    TaeglicheSummenzeitreihe,
    /// Lieferschein Grund- / Arbeitspreis
    #[serde(rename = "Z41")]
    LieferscheinGrundArbeitspreis,
    /// Lieferschein Arbeits- / Leistungspreis
    #[serde(rename = "Z42")]
    LieferscheinArbeitsLeistungspreis,
    /// Redispatch Ausfallarbeitsüberführungszeitreihe
    #[serde(rename = "Z43")]
    RedispatchAusfallarbeitsueberfuehrungszeitreihe,
    /// Redispatch Übermittlung von meteorologischen Daten
    #[serde(rename = "Z44")]
    RedispatchUebermittlungMeteorologischenDaten,
    /// Redispatch Einzelzeitreihe Ausfallarbeit
    #[serde(rename = "Z45")]
    RedispatchEinzelzeitreiheAusfallarbeit,
    /// Redispatch Ausfallarbeitssummenzeitreihe
    #[serde(rename = "Z46")]
    RedispatchAusfallarbeitssummenzeitreihe,
    /// Lastgang Marktlokation, Tranche
    #[serde(rename = "Z48")]
    LastgangMarktlokationTranche,
    /// Redispatch EEG-Überführungszeitreihe aufgrund Ausfallarbeit
    #[serde(rename = "Z50")]
    RedispatchEegUeberfuehrungszeitreiheAufgrundAusfallarbeit,
    /// Redispatch tägliche Ausfallarbeitsüberführungszeitreihe
    #[serde(rename = "Z69")]
    RedispatchTaeglicheAusfallarbeitsueberfuehrungszeitreihe,
    /// Werte nach Typ 2
    #[serde(rename = "Z83")]
    WerteTyp2,
    /// Grundlage POG-Ermittlung
    #[serde(rename = "Z85")]
    GrundlagePogErmittlung,
}

/// nachrichtenfunktion for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Nachrichtenfunktion {
    /// Original
    #[serde(rename = "9")]
    Original,
    /// Storno
    #[serde(rename = "1")]
    Storno,
}

/// unsKennung for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum UnsKennung {
    /// Trennung von Kopf- und Positionsteil
    #[serde(rename = "D")]
    TrennungKopfPositionsteil,
}

/// sg9.produktIdentifikation.typ for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PositionSg9Typ {
    /// OBIS-Kennzahl
    #[serde(rename = "SRW")]
    ObisKennzahl,
    /// BDEW OBIS-ähnliche Kennzahl
    #[serde(rename = "Z02")]
    BdewObisAehnlicheKennzahl,
}

/// qualifier for PID 13016
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Qualifier {
    /// Beantragungsnummer
    #[serde(rename = "AGI")]
    Beantragungsnummer,
    /// Prüfidentifikator
    #[serde(rename = "Z13")]
    Pruefidentifikator,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MesswertSg10 {
    /// Required (X). (an..3)
    pub ablesedatum_format: Option<String>,
    /// Required (X [UB1] ∧ [495]). (an..35)
    pub abrechnungszeitraum: Option<String>,
    /// Required (X [UB1] ∧ [495]). (an..35)
    pub beginn: Option<String>,
    /// Optional. (an..8)
    pub einheit: Option<String>,
    /// Required (X [UB1] ∧ [495]). (an..35)
    pub ende: Option<String>,
    /// Required (X [69]). (an..3)
    pub messwert_qualifier: Option<String>,
    /// Required (unknown). ()
    pub status_energiemenge: Option<String>,
    /// Required (X [5P0..1]). (an..3)
    pub status_energiemenge_grund: Option<String>,
    /// Required (unknown). ()
    pub status_korrektur: Option<String>,
    /// Required (X [5P0..1]). (an..3)
    pub status_korrektur_grund: Option<String>,
    /// Required (unknown). ()
    pub status_messwertqualitaet: Option<String>,
    /// Required (X [5P0..1]). (an..3)
    pub status_messwertqualitaet_grund: Option<String>,
    /// Required (unknown). ()
    pub status_plausibilisierung: Option<String>,
    /// Required (X [5P0..1]). (an..3)
    pub status_plausibilisierung_grund: Option<String>,
    /// Required (X [902] ∧ [906]). (an..35)
    pub wert: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PositionSg9ProduktIdentifikation {
    /// Required (X ([69] ∧ [501] ∧ [566]) ⊻ ([91] ∧ [501])). (an..35)
    pub id: Option<String>,
    /// Required (X [79]). (an..3)
    pub typ: Option<PositionSg9Typ>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PositionSg9 {
    /// Required (X [908]). (an..6)
    pub positionsnummer: Option<String>,
    pub produkt_identifikation: Option<PositionSg9ProduktIdentifikation>,
}

/// Map key for Marktteilnehmer instances.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum MarktteilnehmerKey {
    /// Dokumenten-/Nachrichtenaussteller bzw. -absender
    #[serde(rename = "MS")]
    Ms,
    /// Nachrichtenempfänger
    #[serde(rename = "MR")]
    Mr,
}

impl std::fmt::Display for MarktteilnehmerKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Ms => write!(f, "MS"),
            Self::Mr => write!(f, "MR"),
        }
    }
}

/// Marktteilnehmer for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktteilnehmer {
    /// Required (X). (an..3)
    pub marktrolle: Option<Marktrolle>,
    /// Required (X [117]). (an..35)
    pub rollencodenummer: Option<String>,
    /// Required (X). (an..3)
    pub rollencodetyp: Option<Rollencodetyp>,
}

/// Messlokation for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Messlokation {
    /// Required (X [950] [514]). (an..35)
    pub lokations_id: Option<String>,
}

/// Messwert for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Messwert {
    pub sg10: Option<Vec<MesswertSg10>>,
}

/// Nachricht for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Optional. (an..35)
    pub dokumentennummer: Option<String>,
    /// Optional. (an..3)
    pub dokumenttyp: Option<Dokumenttyp>,
    /// Optional. (an..35)
    pub erstellungsdatum: Option<String>,
    /// Optional. (an..3)
    pub nachrichtenfunktion: Option<Nachrichtenfunktion>,
    /// Optional. (a1)
    pub uns_kennung: Option<UnsKennung>,
}

/// Position for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Position {
    pub sg9: Option<Vec<PositionSg9>>,
}

/// Prozessdaten for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
}

/// Referenz for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Referenz {
    /// Required (unknown). ()
    pub lieferdatum: Option<String>,
    /// Required (X). (an..3)
    pub qualifier: Option<Qualifier>,
    /// Required (X [528] ∨ [553]). (an..70)
    pub referenz: Option<String>,
}

/// PID 13016 transaction — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (X).
    pub messlokation: Option<Messlokation>,
    pub messwert: Option<Messwert>,
    pub position: Option<Position>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub prozessdaten: Option<Vec<Prozessdaten>>,
}

/// PID 13016 message-level — Energie-menge u. Leistungs-max. (Strom).
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Message {
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub marktteilnehmer: Option<BTreeMap<MarktteilnehmerKey, Marktteilnehmer>>,
    pub nachricht: Option<Nachricht>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub referenz: Option<Vec<Referenz>>,
}

/// Complete interchange for PID 13016 — Energie-menge u. Leistungs-max. (Strom).
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
