// 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;

/// kommunikationsart for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kommunikationsart {
    /// Elektronische Post
    #[serde(rename = "EM")]
    ElektronischePost,
    /// Telefax
    #[serde(rename = "FX")]
    Telefax,
    /// Telefon
    #[serde(rename = "TE")]
    Telefon,
    /// weiteres Telefon
    #[serde(rename = "AJ")]
    WeiteresTelefon,
    /// Handy
    #[serde(rename = "AL")]
    Handy,
}

/// kontaktfunktion for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kontaktfunktion {
    /// Informationskontakt
    #[serde(rename = "IC")]
    Informationskontakt,
}

/// mengenQualifier for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MengenQualifier {
    /// Leistung der Marktlokation
    #[serde(rename = "Z10")]
    LeistungMarktlokation,
    /// Veranschlagte Jahresmenge Gesamt/Jahresverbrauchsprognose für spezifische Arb...
    #[serde(rename = "265")]
    VeranschlagteJahresmengeGesamtJahresverbrauchsprognoseSpezifischeArbeit,
    /// Veranschlagte Jahresmenge Gesamt
    #[serde(rename = "31")]
    VeranschlagteJahresmengeGesamt,
}

/// mengeneinheit for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Mengeneinheit {
    /// kWh/K (Kilowatt-Stunde/Kelvin)
    #[serde(rename = "Z16")]
    KwhKKilowattStundeKelvin,
    /// Kilowatt
    #[serde(rename = "KWT")]
    Kilowatt,
    /// Kilowattstunde
    #[serde(rename = "KWH")]
    Kilowattstunde,
}

/// marktrolle for PID 55672
#[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 55672
#[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,
}

/// ideQualifier for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum IdeQualifier {
    /// Transaktion
    #[serde(rename = "24")]
    Transaktion,
}

/// pruefidentifikator for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Pruefidentifikator {
    /// GPKE / Abrechnungsdaten Bilanzkreisabrechnung erzeugender MaLo an LF
    #[serde(rename = "55672")]
    GpkeAbrechnungsdatenBilanzkreisabrechnungErzeugenderMaloLf,
}

/// transaktionsgrund for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsgrund {
    /// Abrechnungsdaten BK-Abrechnung erzeugender Malo
    #[serde(rename = "ZX2")]
    AbrechnungsdatenBkAbrechnungErzeugenderMalo,
    /// Korrektur Abrechnungsdaten BK-Abrechnung erzeugender MaLo
    #[serde(rename = "ZAO")]
    KorrekturAbrechnungsdatenBkAbrechnungErzeugenderMalo,
}

/// transaktionsgrundDetail for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TransaktionsgrundDetail {
    /// Erzeugende Marktlokation
    #[serde(rename = "ZW3")]
    ErzeugendeMarktlokation,
    /// Tranche
    #[serde(rename = "ZW5")]
    Tranche,
}

/// transaktionsgrundErgaenzung for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TransaktionsgrundErgaenzung {
    /// Kunde verlässt eine schon bestehende Marktlokation
    #[serde(rename = "E01")]
    KundeVerlaesstBestehendeMarktlokation,
    /// - Kunde bleibt an der Marktlokation, hat nur den Marktpartner gewechselt - Ma...
    #[serde(rename = "E03")]
    KundeBleibtMarktlokationMarktpartnerGewechseltMarktpartnerKunden,
}

/// merkmal.code for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungCode {
    /// Zugeordneter Marktpartner
    #[serde(rename = "ZB3")]
    ZugeordneterMarktpartner,
    /// Summenzeitreihentyp
    #[serde(rename = "Z21")]
    Summenzeitreihentyp,
    /// NB
    #[serde(rename = "ZA8")]
    Nb,
    /// ÜNB
    #[serde(rename = "ZA9")]
    Uenb,
    /// Prognose auf Basis von Werten
    #[serde(rename = "ZC0")]
    PrognoseBasisWerten,
    /// Prognose auf Basis von Profilen
    #[serde(rename = "ZA6")]
    PrognoseBasisProfilen,
    /// Profilschar
    #[serde(rename = "Z12")]
    Profilschar,
    /// synthetisches Verfahren
    #[serde(rename = "E01")]
    SynthetischesVerfahren,
}

/// merkmal.code_codepflege for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungCodeCodepflege {
    /// Vergeben vom Händler (hier Netzbetreiber)
    #[serde(rename = "89")]
    VergebenHaendlerHierNetzbetreiber,
    /// DE, BDEW (Bundesverband der Energie- und Wasserwirtschaft e.V.)
    #[serde(rename = "293")]
    DeBdewBundesverbandEnergieWasserwirtschaftEV,
}

/// merkmal.klasse for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungKlasse {
    /// Regelzone
    #[serde(rename = "Z18")]
    Regelzone,
}

/// merkmal.qualifier for PID 55672
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungQualifier {
    /// ÜNB
    #[serde(rename = "Z90")]
    Uenb,
    /// Beispielcode
    #[serde(rename = "XYZ")]
    DieserCodeAnwendungDurchZulaessigenCodeNbGueltigenListe,
    /// SLP/SEP
    #[serde(rename = "E02")]
    SlpSep,
    /// TLP/TEP
    #[serde(rename = "E14")]
    TlpTep,
    /// TEP mit Referenzmessung
    #[serde(rename = "Z36")]
    TepReferenzmessung,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KontaktKontakt {
    /// Required (X). (an..256)
    pub name: Option<String>,
    /// Required (X). ()
    pub nummer: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MarktlokationZeitscheibe {
    /// Required (X [914] ∧ [937] [22]). (an..10)
    pub referenz: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MesslokationZeitscheibe {
    /// Required (X [914] ∧ [937] [22]). (an..10)
    pub referenz: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProfilDatenZeitscheibe {
    /// Required (X [914] ∧ [937] [22]). (an..10)
    pub referenz: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReferenzprofilZeitscheibe {
    /// Required (X [914] ∧ [937] [22]). (an..10)
    pub referenz: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ZuordnungMerkmal {
    /// Required (X). (an..17)
    pub code: Option<ZuordnungCode>,
    /// Required (X). (an..3)
    pub code_codepflege: Option<ZuordnungCodeCodepflege>,
    /// Required (X [58]). (an..17)
    pub codeliste: Option<String>,
    /// Required (unknown). ()
    pub dimension: Option<String>,
    /// Required (X). (an..3)
    pub klasse: Option<ZuordnungKlasse>,
    /// Required (X). (an..3)
    pub qualifier: Option<ZuordnungQualifier>,
}

/// 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"),
        }
    }
}

/// Kontakt for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Kontakt {
    /// Required (X [1P0..1]). (an..3)
    pub kommunikationsart: Option<Kommunikationsart>,
    /// Required (X (([939] [321]) ∨ ([940] [322])) ∧ [514]). (an..512)
    pub kommunikationsnummer: Option<String>,
    pub kontakt: Option<KontaktKontakt>,
    /// Required (X). (an..3)
    pub kontaktfunktion: Option<Kontaktfunktion>,
}

/// Marktlokation for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktlokation {
    /// Required (X). ()
    pub codeliste_code: Option<String>,
    /// Required (X). ()
    pub codepflege_code: Option<String>,
    /// Required (X). (an..256)
    pub lokation_zeitraum_id: Option<String>,
    /// Required (X [950]). (an..35)
    pub marktlokations_id: Option<String>,
    pub zeitscheibe: Option<MarktlokationZeitscheibe>,
}

/// MarktlokationMengen for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct MarktlokationMengen {
    /// Required (X [902]). (an..35)
    pub menge: Option<String>,
    /// Required (X [102]). (an..3)
    pub mengen_qualifier: Option<MengenQualifier>,
    /// Required (X [103]). (an..8)
    pub mengeneinheit: Option<Mengeneinheit>,
}

/// Marktteilnehmer for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktteilnehmer {
    /// Required (unknown). ()
    pub codeliste_code: Option<String>,
    /// Required (X). (an..3)
    pub marktrolle: Option<Marktrolle>,
    /// Required (X). (an..35)
    pub rollencodenummer: Option<String>,
    /// Required (X). (an..3)
    pub rollencodetyp: Option<Rollencodetyp>,
}

/// Messlokation for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Messlokation {
    pub zeitscheibe: Option<MesslokationZeitscheibe>,
}

/// Nachricht for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Optional. (an..35)
    pub erstellungsdatum: Option<String>,
    /// Optional. ()
    pub nachrichtennummer: Option<String>,
    /// Optional. ()
    pub nachrichtentyp: Option<String>,
}

/// ProfilDaten for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ProfilDaten {
    pub zeitscheibe: Option<ProfilDatenZeitscheibe>,
}

/// Prozessdaten for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    /// Required (unknown). ()
    pub bearbeitungsstand: Option<String>,
    /// Required (X). (an..3)
    pub ide_qualifier: Option<IdeQualifier>,
    /// Required (X). (an..70)
    pub pruefidentifikator: Option<Pruefidentifikator>,
    /// Required (X). (an..3)
    pub transaktionsgrund: Option<Transaktionsgrund>,
    /// Required (X). (an..3)
    pub transaktionsgrund_detail: Option<TransaktionsgrundDetail>,
    /// Optional. (an..3)
    pub transaktionsgrund_ergaenzung: Option<TransaktionsgrundErgaenzung>,
    /// Required (X). (an..35)
    pub vorgang_id: Option<String>,
}

/// Referenzprofil for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Referenzprofil {
    pub zeitscheibe: Option<ReferenzprofilZeitscheibe>,
}

/// Tranche for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Tranche {
    /// Required (X). ()
    pub codeliste_code: Option<String>,
    /// Required (X). ()
    pub codepflege_code: Option<String>,
    /// Required (X). (an..256)
    pub lokation_zeitraum_id: Option<String>,
    /// Required (X [950]). (an..35)
    pub tranche_id: Option<String>,
}

/// Zuordnung for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Zuordnung {
    pub merkmal: Option<ZuordnungMerkmal>,
    /// Required (X). (an..17)
    pub zugeordneter_mp: Option<String>,
}

/// PID 55672 transaction — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub marktlokation: Option<Vec<Marktlokation>>,
    pub marktlokation_mengen: Option<MarktlokationMengen>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub messlokation: Option<Vec<Messlokation>>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub profil_daten: Option<Vec<ProfilDaten>>,
    pub prozessdaten: Option<Prozessdaten>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub referenzprofil: Option<Vec<Referenzprofil>>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub tranche: Option<Vec<Tranche>>,
    pub zuordnung: Option<Zuordnung>,
}

/// PID 55672 message-level — Abr.-Daten BK-Abr. erz. Malo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Message {
    pub kontakt: Option<Kontakt>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub marktteilnehmer: Option<BTreeMap<MarktteilnehmerKey, Marktteilnehmer>>,
    pub nachricht: Option<Nachricht>,
}

/// Complete interchange for PID 55672 — Abr.-Daten BK-Abr. erz. Malo.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
