// 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 17134
#[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,
    /// Lieferanschrift
    #[serde(rename = "DP")]
    Lieferanschrift,
    /// Lieferant
    #[serde(rename = "SU")]
    Lieferant,
    /// Übertragungsnetzbetreiber
    #[serde(rename = "Z31")]
    Uebertragungsnetzbetreiber,
    /// Messstellenbetreiber
    #[serde(rename = "DEB")]
    Messstellenbetreiber,
}

/// ortQualifier for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum OrtQualifier {
    /// Meldepunkt
    #[serde(rename = "172")]
    Meldepunkt,
}

/// rollencodetyp for PID 17134
#[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,
}

/// merkmal.code for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MerkmalCode {
    /// Prozentual
    #[serde(rename = "ZD1")]
    Prozentual,
    /// mittels Berechnungsformel
    #[serde(rename = "ZC4")]
    MittelsBerechnungsformel,
}

/// merkmal.qualifier for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MerkmalQualifier {
    /// Basis zur Bildung der Tranchengröße
    #[serde(rename = "Z37")]
    BasisBildungTranchengroesse,
}

/// merkmal.code for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MerkmalZ37Code {
    /// Prozentual
    #[serde(rename = "ZD1")]
    Prozentual,
    /// mittels Berechnungsformel
    #[serde(rename = "ZC4")]
    MittelsBerechnungsformel,
}

/// merkmal.qualifier for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MerkmalZ37Qualifier {
    /// Basis zur Bildung der Tranchengröße
    #[serde(rename = "Z37")]
    BasisBildungTranchengroesse,
}

/// merkmal.qualifier for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MerkmalZ39Qualifier {
    /// Code der Zählzeitdefinition
    #[serde(rename = "Z39")]
    CodeZaehlzeitdefinition,
    /// Keine Zählzeit für Messprodukt erforderlich
    #[serde(rename = "Z41")]
    KeineZaehlzeitMessproduktErforderlich,
}

/// abonnement for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Abonnement {
    /// Start Abo
    #[serde(rename = "Z01")]
    StartAbo,
    /// Ende Abo
    #[serde(rename = "Z02")]
    EndeAbo,
    /// ohne Abo
    #[serde(rename = "Z03")]
    OhneAbo,
}

/// dokumenttyp for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Dokumenttyp {
    /// Prozessdatenbericht
    #[serde(rename = "7")]
    Prozessdatenbericht,
    /// Bilanzkreiszuordnungsliste
    #[serde(rename = "E40")]
    Bilanzkreiszuordnungsliste,
    /// Clearingliste
    #[serde(rename = "Z05")]
    Clearingliste,
    /// Zeitreihen im Rahmen der Bilanzkreisabrechnung
    #[serde(rename = "BK")]
    ZeitreihenRahmenBilanzkreisabrechnung,
    /// Geräteübernahme
    #[serde(rename = "Z10")]
    Geraeteuebernahme,
    /// Weiterverpflichtung zum Betrieb der Messlokation
    #[serde(rename = "Z11")]
    WeiterverpflichtungBetriebMesslokation,
    /// Änderung der Technik der Lokation
    #[serde(rename = "Z12")]
    AenderungTechnikLokation,
    /// Gerätewechselabsicht
    #[serde(rename = "Z13")]
    Geraetewechselabsicht,
    /// Stammdaten der Markt- oder Messlokation
    #[serde(rename = "Z14")]
    StammdatenMarktMesslokation,
    /// normiertes Profil/Profilschar
    #[serde(rename = "Z19")]
    NormiertesProfilProfilschar,
    /// Allokationsliste (MMMA)
    #[serde(rename = "Z24")]
    AllokationslisteMmma,
    /// Energiemenge und Leistungsmaximum
    #[serde(rename = "Z28")]
    EnergiemengeLeistungsmaximum,
    /// Abrechnung des Messstellenbetriebs vom MSB an den LF
    #[serde(rename = "Z29")]
    AbrechnungMessstellenbetriebsMsbLf,
    /// Änderung Prognosegrundlage
    #[serde(rename = "Z30")]
    AenderungPrognosegrundlage,
    /// Änderung Gerätekonfiguration
    #[serde(rename = "Z31")]
    AenderungGeraetekonfiguration,
    /// Reklamation von Werten
    #[serde(rename = "Z34")]
    ReklamationWerten,
    /// Redispatch Einzelzeitreihe Ausfallarbeit
    #[serde(rename = "Z45")]
    RedispatchEinzelzeitreiheAusfallarbeit,
    /// Lastgang Marktlokation, Tranche
    #[serde(rename = "Z48")]
    LastgangMarktlokationTranche,
    /// Sperrung
    #[serde(rename = "Z51")]
    Sperrung,
    /// Entsperrung
    #[serde(rename = "Z52")]
    Entsperrung,
    /// Reklamation der Übersicht der Definitionen oder einer Definition
    #[serde(rename = "Z55")]
    ReklamationUebersichtDefinitionenDefinition,
    /// Änderung individueller Konfiguration
    #[serde(rename = "Z56")]
    AenderungIndividuellerKonfiguration,
    /// Übermittlung von Werten an ESA
    #[serde(rename = "Z57")]
    UebermittlungWertenEsa,
    /// Reklamation Profil/Profilschar
    #[serde(rename = "Z58")]
    ReklamationProfilProfilschar,
    /// Stammdaten der Marktlokation
    #[serde(rename = "Z61")]
    StammdatenMarktlokation,
    /// Stammdaten der Messlokation
    #[serde(rename = "Z62")]
    StammdatenMesslokation,
    /// Änderung
    #[serde(rename = "Z68")]
    Aenderung,
    /// Beendigung einer Konfiguration
    #[serde(rename = "Z72")]
    BeendigungKonfiguration,
    /// Bestellung einer Konfiguration
    #[serde(rename = "Z73")]
    BestellungKonfiguration,
    /// Bestellung eines Angebots einer Konfiguration
    #[serde(rename = "Z74")]
    BestellungAngebotsKonfiguration,
    /// Reklamation einer Konfiguration
    #[serde(rename = "Z76")]
    ReklamationKonfiguration,
    /// Bestellung Änderung Abrechnungsdaten
    #[serde(rename = "Z91")]
    BestellungAenderungAbrechnungsdaten,
    /// Einrichtung Konfiguration aufgrund Zuordnung LF
    #[serde(rename = "Z92")]
    EinrichtungKonfigurationAufgrundZuordnungLf,
    /// Bestellung eines Angebots Änderung der Technik der Lokation
    #[serde(rename = "Z93")]
    BestellungAngebotsAenderungTechnikLokation,
}

/// unsKennung for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum UnsKennung {
    /// Trennung von Positions- und Summenteil
    #[serde(rename = "S")]
    TrennungPositionsSummenteil,
}

/// produktIdentifikation2.codeListe for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PositionCodeListe {
    /// EDI@Energy Codeliste der Verwendungszwecke
    #[serde(rename = "Z16")]
    EdiEnergyCodelisteVerwendungszwecke,
}

/// artikeltyp for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Artikeltyp {
    /// Produkt
    #[serde(rename = "Z11")]
    Produkt,
}

/// beschreibung for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Beschreibung {
    /// Neukonfiguration
    #[serde(rename = "Z64")]
    Neukonfiguration,
    /// Konfiguration unverändert
    #[serde(rename = "Z65")]
    KonfigurationUnveraendert,
}

/// einheit for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Einheit {
    /// Prozent
    #[serde(rename = "P1")]
    Prozent,
}

/// handlungCode for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum HandlungCode {
    /// Erforderliches Produkt der Marktlokation
    #[serde(rename = "Z54")]
    ErforderlichesProduktMarktlokation,
    /// Erforderliches Produkt der Tranche
    #[serde(rename = "Z16")]
    ErforderlichesProduktTranche,
    /// Erforderliches Produkt der Messlokation
    #[serde(rename = "Z19")]
    ErforderlichesProduktMesslokation,
}

/// mengenQualifier for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MengenQualifier {
    /// Aufteilungsmenge
    #[serde(rename = "11")]
    Aufteilungsmenge,
}

/// exRefName for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ExRefName {
    /// Tranche
    #[serde(rename = "Z20")]
    Tranche,
    /// Messlokation
    #[serde(rename = "Z19")]
    Messlokation,
}

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

/// referenz for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ReferenzReferenz {
    /// Einrichtung Konfiguration aufgrund Zuordnung LF von NB an MSB
    #[serde(rename = "17134")]
    EinrichtungKonfigurationAufgrundZuordnungLfNbMsb,
}

/// qualifier for PID 17134
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TeilnehmerReferenzQualifier {
    /// Tranche
    #[serde(rename = "Z20")]
    Tranche,
    /// Marktlokation Kundenanlage
    #[serde(rename = "Z59")]
    MarktlokationKundenanlage,
    /// Marktlokation
    #[serde(rename = "Z18")]
    Marktlokation,
    /// Marktlokation Kundenanlage
    #[serde(rename = "Z59")]
    MarktlokationKundenanlage2,
    /// Marktlokation
    #[serde(rename = "Z18")]
    Marktlokation2,
    /// Marktlokation Kundenanlage
    #[serde(rename = "Z59")]
    MarktlokationKundenanlage3,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MerkmalMerkmal {
    /// Required (X [594]). (an..17)
    pub code: Option<MerkmalCode>,
    /// Required (X). (an..3)
    pub qualifier: Option<MerkmalQualifier>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MerkmalZ37Merkmal {
    /// Required (X [594]). (an..17)
    pub code: Option<MerkmalZ37Code>,
    /// Required (X). (an..3)
    pub qualifier: Option<MerkmalZ37Qualifier>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MerkmalZ39Merkmal {
    /// Required (X [77]). (an..17)
    pub code: Option<String>,
    /// Required (X). (an..3)
    pub qualifier: Option<MerkmalZ39Qualifier>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PositionProduktIdentifikation {
    /// Required (X [95]). (an..35)
    pub id: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PositionProduktIdentifikation2 {
    /// Required (X). (an..17)
    pub code_liste: Option<PositionCodeListe>,
    /// Required (X [198]). (an..3)
    pub typ: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PositionProduktIdentifikation3 {
    /// Required (X). (an..17)
    pub code_liste: Option<PositionCodeListe>,
    /// Required (X [199]). (an..3)
    pub typ: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PositionProduktIdentifikation4 {
    /// Required (X). (an..17)
    pub code_liste: Option<PositionCodeListe>,
    /// Required (X [200]). (an..3)
    pub typ: Option<String>,
}

/// 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,
    /// Lieferanschrift
    #[serde(rename = "DP")]
    Dp,
    /// Lieferant
    #[serde(rename = "SU")]
    Su,
    /// Übertragungsnetzbetreiber
    #[serde(rename = "Z31")]
    Z31,
    /// Messstellenbetreiber
    #[serde(rename = "DEB")]
    Deb,
}

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"),
            Self::Dp => write!(f, "DP"),
            Self::Su => write!(f, "SU"),
            Self::Z31 => write!(f, "Z31"),
            Self::Deb => write!(f, "DEB"),
        }
    }
}

/// Marktteilnehmer for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktteilnehmer {
    /// Required (unknown). ()
    pub anrede: Option<String>,
    /// Required (unknown). ()
    pub hausnummer: Option<String>,
    /// Required (unknown). ()
    pub land: Option<String>,
    /// Required (X). (an..3)
    pub marktrolle: Option<Marktrolle>,
    /// Required (X [950] [521]). (an..35)
    pub meldepunkt_id: Option<String>,
    /// Required (unknown). ()
    pub nachname: Option<String>,
    /// Required (unknown). ()
    pub namenformat: Option<String>,
    /// Required (unknown). ()
    pub namenformat_code: Option<String>,
    /// Required (unknown). ()
    pub ort: Option<String>,
    /// Required (X). (an..3)
    pub ort_qualifier: Option<OrtQualifier>,
    /// Required (unknown). ()
    pub postleitzahl: Option<String>,
    /// Required (unknown). ()
    pub region: Option<String>,
    /// Required (X [61]). (an..35)
    pub rollencodenummer: Option<String>,
    /// Required (X). (an..3)
    pub rollencodetyp: Option<Rollencodetyp>,
    /// Required (unknown). ()
    pub strasse: Option<String>,
    /// Required (unknown). ()
    pub strasse2: Option<String>,
    /// Required (unknown). ()
    pub strasse4: Option<String>,
    /// Required (unknown). ()
    pub titel: Option<String>,
    /// Required (unknown). ()
    pub vorname: Option<String>,
    /// Required (unknown). ()
    pub zusatzinfo: Option<String>,
    /// Required (unknown). ()
    pub zusatzinfo2: Option<String>,
    /// Required (unknown). ()
    pub zusatzinfo3: Option<String>,
    /// Required (unknown). ()
    pub zusatzinfo4: Option<String>,
    /// Required (unknown). ()
    pub zusatzinfo5: Option<String>,
}

/// Merkmal for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Merkmal {
    pub merkmal: Option<MerkmalMerkmal>,
    /// Required (X). ()
    pub merkmal_wert: Option<String>,
    /// Required (X). ()
    pub messgroesse: Option<String>,
}

/// MerkmalZ37 for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct MerkmalZ37 {
    pub merkmal: Option<MerkmalZ37Merkmal>,
    /// Required (X). ()
    pub messgroesse: Option<String>,
}

/// MerkmalZ39 for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct MerkmalZ39 {
    pub merkmal: Option<MerkmalZ39Merkmal>,
    /// Required (X). ()
    pub messgroesse: Option<String>,
}

/// Nachricht for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Optional. (an..3)
    pub abonnement: Option<Abonnement>,
    /// Optional. (an..35)
    pub auftragsdatum: Option<String>,
    /// Required (unknown). ()
    pub beschreibungsformat: Option<String>,
    /// Optional. (an..70)
    pub dokumentennummer: Option<String>,
    /// Optional. (an..3)
    pub dokumenttyp: Option<Dokumenttyp>,
    /// Optional. (an..35)
    pub erstellungsdatum: Option<String>,
    /// Required (unknown). ()
    pub freitext_hinweis1: Option<String>,
    /// Required (unknown). ()
    pub freitext_hinweis2: Option<String>,
    /// Required (unknown). ()
    pub freitext_hinweis3: Option<String>,
    /// Required (unknown). ()
    pub ftx_funktion: Option<String>,
    /// Required (unknown). ()
    pub ftx_referenz: Option<String>,
    /// Required (unknown). ()
    pub ftx_referenz_code_liste: Option<String>,
    /// Optional. (an..35)
    pub sperrdatum: Option<String>,
    /// Optional. (a1)
    pub uns_kennung: Option<UnsKennung>,
}

/// Position for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Position {
    /// Required (X). (an..3)
    pub artikeltyp: Option<Artikeltyp>,
    /// Required (X [165]). (an..3)
    pub beschreibung: Option<Beschreibung>,
    /// Required (unknown). ()
    pub beschreibungsformat: Option<String>,
    /// Required (X). (an..8)
    pub einheit: Option<Einheit>,
    /// Required (X). (an..3)
    pub handlung_code: Option<HandlungCode>,
    /// Required (X [914] ∧ [930] ∧ [955]). (an..35)
    pub menge: Option<String>,
    /// Required (X). (an..3)
    pub mengen_qualifier: Option<MengenQualifier>,
    /// Required (X [911]). (an..6)
    pub positionsnummer: Option<String>,
    pub produkt_identifikation: Option<PositionProduktIdentifikation>,
    pub produkt_identifikation2: Option<PositionProduktIdentifikation2>,
    pub produkt_identifikation3: Option<PositionProduktIdentifikation3>,
    pub produkt_identifikation4: Option<PositionProduktIdentifikation4>,
}

/// PositionReferenz for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct PositionReferenz {
    /// Required (X). (an..3)
    pub ex_ref_name: Option<ExRefName>,
    /// Required (X [950]). (an..70)
    pub ex_ref_wert: Option<String>,
}

/// Referenz for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Referenz {
    /// Required (X). (an..3)
    pub qualifier: Option<ReferenzQualifier>,
    /// Required (X). (an..70)
    pub referenz: Option<ReferenzReferenz>,
}

/// TeilnehmerReferenz for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct TeilnehmerReferenz {
    /// Required (X). (an..3)
    pub qualifier: Option<TeilnehmerReferenzQualifier>,
    /// Required (X [950]). (an..70)
    pub referenz: Option<String>,
}

/// PID 17134 transaction — Einrichtung Konfiguration  Zuordnung LF von NB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (X).
    pub merkmal: Option<Merkmal>,
    /// Required (X).
    pub merkmal_z37: Option<MerkmalZ37>,
    /// Required (X).
    pub merkmal_z39: Option<MerkmalZ39>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub position: Option<Vec<Position>>,
    pub position_referenz: Option<PositionReferenz>,
}

/// PID 17134 message-level — Einrichtung Konfiguration  Zuordnung LF von NB.
#[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>>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub teilnehmer_referenz: Option<Vec<TeilnehmerReferenz>>,
}

/// Complete interchange for PID 17134 — Einrichtung Konfiguration  Zuordnung LF von NB.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
