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

/// anredeCode for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AnredeCode {
    /// Struktur von Personennamen
    #[serde(rename = "Z01")]
    StrukturPersonennamen,
    /// Struktur der Firmenbezeichnung
    #[serde(rename = "Z02")]
    StrukturFirmenbezeichnung,
}

/// partnerrolle for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Partnerrolle {
    /// Messlokationsadresse
    #[serde(rename = "Z03")]
    Messlokationsadresse,
}

/// kommunikationsart for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kommunikationsart {
    /// Telefon
    #[serde(rename = "TE")]
    Telefon,
    /// Elektronische Post
    #[serde(rename = "EM")]
    ElektronischePost,
}

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

/// rffQualifierGeraet for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RffQualifierGeraet {
    /// Gerätenummer des Zählers
    #[serde(rename = "MG")]
    Geraetenummer,
    /// Smartmeter-Gateway
    #[serde(rename = "Z14")]
    SmartmeterGateway,
    /// Anwendungsreferenznummer
    #[serde(rename = "AGK")]
    Anwendungsreferenznummer,
}

/// pruefidentifikator for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Pruefidentifikator {
    /// GPKE / Änderung Daten der MeLo vom MSB an NB
    #[serde(rename = "55643")]
    GpkeAenderungDatenMeloMsbNb,
}

/// transaktionsgrund for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsgrund {
    /// Änderung Daten der MeLo
    #[serde(rename = "ZX7")]
    AenderungDatenMelo,
}

/// transaktionsgrundDetail for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TransaktionsgrundDetail {
    /// Der LFN wird einer Marktlokation vollständig zugeordnet (vollständige (100%ig...
    #[serde(rename = "ZW0")]
    LfnMarktlokationVollstaendigZugeordnetVollstaendige100IgeZuordnungDieser,
    /// Der LFN wird einer bestehenden Tranche vollständig zugeordnet (vollständige (...
    #[serde(rename = "ZW1")]
    LfnBestehendenTrancheVollstaendigZugeordnetVollstaendige100IgeZuordnung,
    /// Der LFN wird einer neu zu bildenden Tranche zugeordnet (anteiliger Zuordnungs...
    #[serde(rename = "ZW2")]
    LfnNeuBildendenTrancheZugeordnetAnteiligerZuordnungsvorgangBildungNeuer,
    /// Erzeugende Marktlokation
    #[serde(rename = "ZW3")]
    ErzeugendeMarktlokation,
    /// Verbrauchende Marktlokation
    #[serde(rename = "ZW4")]
    VerbrauchendeMarktlokation,
    /// Tranche
    #[serde(rename = "ZW5")]
    Tranche,
    /// Pauschale Marktlokation
    #[serde(rename = "ZW6")]
    PauschaleMarktlokation,
    /// Gemessene Marktlokation
    #[serde(rename = "ZW7")]
    GemesseneMarktlokation,
    /// Fall 1
    #[serde(rename = "ZW8")]
    Fall1,
    /// Fall 2
    #[serde(rename = "ZW9")]
    Fall2,
    /// Fall 3
    #[serde(rename = "ZX0")]
    Fall3,
    /// Fall 4
    #[serde(rename = "ZX1")]
    Fall4,
    /// ruhende Marktlokation
    #[serde(rename = "ZAP")]
    RuhendeMarktlokation,
    /// Die Stilllegung der MeLo hat auch die Stilllegung einer MaLo zur Folge
    #[serde(rename = "ZZB")]
    StilllegungMeloStilllegungMaloFolgeDieserCodeErst142026GueltigDavor,
    /// Die Stilllegung der MeLo hat keine Stilllegung einer MaLo zur Folge
    #[serde(rename = "ZZC")]
    StilllegungMeloKeineStilllegungMaloFolgeDieserCodeErst142026Gueltig,
}

/// transaktionsgrundErgaenzung for PID 55643
#[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 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungCode {
    /// Zählertyp
    #[serde(rename = "E13")]
    Zaehlertyp,
    /// Befestigungsart Zähleinrichtung
    #[serde(rename = "Z28")]
    BefestigungsartZaehleinrichtung,
    /// Messwerterfassung an der Zähleinrichtung
    #[serde(rename = "E12")]
    MesswerterfassungZaehleinrichtung,
}

/// merkmal.eigenschaft for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungEigenschaft {
    /// EDL40
    #[serde(rename = "Z01")]
    Edl40,
    /// EDL21
    #[serde(rename = "Z02")]
    Edl21,
    /// sonstiger EHZ
    #[serde(rename = "Z03")]
    SonstigerEhz,
    /// Standard
    #[serde(rename = "Z04")]
    Standard,
    /// MeDa-Zähler
    #[serde(rename = "Z05")]
    MedaZaehler,
    /// vorhanden
    #[serde(rename = "Z06")]
    Vorhanden,
    /// nicht vorhanden
    #[serde(rename = "Z07")]
    NichtVorhanden,
}

/// merkmal.qualifier for PID 55643
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungQualifier {
    /// analoger Haushaltszähler (Drehstrom)
    #[serde(rename = "AHZ")]
    AnalogerHaushaltszaehlerDrehstrom,
    /// analoger Wechselstromzähler
    #[serde(rename = "WSZ")]
    AnalogerWechselstromzaehler,
    /// Lastgangzähler
    #[serde(rename = "LAZ")]
    Lastgangzaehler,
    /// Maximumzähler
    #[serde(rename = "MAZ")]
    Maximumzaehler,
    /// moderne Messeinrichtung nach MsbG
    #[serde(rename = "MME")]
    ModerneMesseinrichtungMsbg,
    /// elektronischer Haushaltszähler
    #[serde(rename = "EHZ")]
    ElektronischerHaushaltszaehler,
    /// Individuelle Abstimmung (Sonderausstattung)
    #[serde(rename = "IVA")]
    SonderausstattungGehoertZBGasEncoder,
    /// Gerätenummer
    #[serde(rename = "Z30")]
    Geraetenummer,
    /// Eintarif
    #[serde(rename = "ETZ")]
    Eintarif,
    /// Zweitarif
    #[serde(rename = "ZTZ")]
    Zweitarif,
    /// Mehrtarif
    #[serde(rename = "NTZ")]
    Mehrtarif,
    /// Einrichtungszähler
    #[serde(rename = "ERZ")]
    Einrichtungszaehler,
    /// Zweirichtungszähler
    #[serde(rename = "ZRZ")]
    Zweirichtungszaehler,
    /// Fernschaltung der Zähleinrichtung
    #[serde(rename = "Z58")]
    FernschaltungZaehleinrichtung,
    /// Stecktechnik (Befestigungs- und Kontaktierungseinrichtung)
    #[serde(rename = "BKE")]
    StecktechnikBefestigungsKontaktierungseinrichtung,
    /// 3-Dreipunktaufhängung
    #[serde(rename = "DPA")]
    Code3Dreipunktaufhaengung,
    /// Hutschiene
    #[serde(rename = "HUT")]
    Hutschiene,
    /// fernauslesbare Zähler
    #[serde(rename = "AMR")]
    FernauslesbareZaehler,
    /// manuell ausgelesene Zähler
    #[serde(rename = "MMR")]
    ManuellAusgeleseneZaehler,
}

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

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

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

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

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ZaehlerDatenZeitscheibe {
    /// 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 (unknown). ()
    pub code_codepflege: Option<String>,
    /// Required (unknown). ()
    pub codeliste: Option<String>,
    /// Required (unknown). ()
    pub codepflege: Option<String>,
    /// Required (X [136]). (an..35)
    pub eigenschaft: Option<ZuordnungEigenschaft>,
    /// Required (unknown). ()
    pub eigenschaft_2: Option<String>,
    /// Required (unknown). ()
    pub klasse: Option<String>,
    /// Required (X). (an..3)
    pub qualifier: Option<ZuordnungQualifier>,
}

/// Map key for Geschaeftspartner instances.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum GeschaeftspartnerKey {
    #[serde(rename = "Z03")]
    Z03,
    #[serde(rename = "Z05")]
    Z05,
    #[serde(rename = "Z07")]
    Z07,
    #[serde(rename = "Z08")]
    Z08,
}

impl std::fmt::Display for GeschaeftspartnerKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Z03 => write!(f, "Z03"),
            Self::Z05 => write!(f, "Z05"),
            Self::Z07 => write!(f, "Z07"),
            Self::Z08 => write!(f, "Z08"),
        }
    }
}

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

/// Geschaeftspartner for PID 55643 — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Geschaeftspartner {
    /// Required (X). (an..70)
    pub anrede: Option<String>,
    /// Required (X). (an..3)
    pub anrede_code: Option<AnredeCode>,
    /// Required (X). (an..35)
    pub hausnummer: Option<String>,
    /// Required (X). ()
    pub identifikation: Option<String>,
    /// Required (X). (an..3)
    pub land: Option<String>,
    /// Required (X). (an..70)
    pub nachname: Option<String>,
    /// Required (X). (an..70)
    pub name_zeile3: Option<String>,
    /// Required (X). (an..70)
    pub name_zeile4: Option<String>,
    /// Required (X). (an..35)
    pub ort: Option<String>,
    /// Required (X). (an..3)
    pub partnerrolle: Option<Partnerrolle>,
    /// Required (X). (an..17)
    pub postleitzahl: Option<String>,
    /// Required (X). ()
    pub region: Option<String>,
    /// Required (S [166] M [212]). (an..35)
    pub strasse: Option<String>,
    /// Required (X). (an..35)
    pub strasse_zeile2: Option<String>,
    /// Required (X). (an..35)
    pub strasse_zeile4: Option<String>,
    /// Required (X). (an..70)
    pub vorname: Option<String>,
    pub zeitscheibe: Option<GeschaeftspartnerZeitscheibe>,
    /// Required (S [336]). (an..35)
    pub zusatzinfo: Option<String>,
    /// Required (X). (an..35)
    pub zusatzinfo_zeile2: Option<String>,
    /// Required (X). (an..35)
    pub zusatzinfo_zeile3: Option<String>,
    /// Required (X). (an..35)
    pub zusatzinfo_zeile4: Option<String>,
    /// Required (X). (an..35)
    pub zusatzinfo_zeile5: Option<String>,
}

/// Kontakt for PID 55643 — Änderung Daten der MeLo.
#[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). (an..512)
    pub kommunikationsnummer: Option<String>,
}

/// Marktteilnehmer for PID 55643 — Änderung Daten der MeLo.
#[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 55643 — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Messlokation {
    /// Required (X). ()
    pub codeliste_code: Option<String>,
    /// Required (X [951]). (an..35)
    pub messlokations_id: Option<String>,
    /// Required (X). ()
    pub referenz: Option<String>,
    /// Required (X [914] ∧ [937] [22]). (an..10)
    pub seq_zeitscheibe_z18: Option<String>,
    pub zeitscheibe: Option<MesslokationZeitscheibe>,
}

/// Nachricht for PID 55643 — Änderung Daten der MeLo.
#[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>,
}

/// ObisKennzahl for PID 55643 — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ObisKennzahl {
    /// Required (X). (an..70)
    pub konfigurations_id: Option<String>,
    pub produkt_identifikation: Option<ObisKennzahlProduktIdentifikation>,
    /// Required (X). (an..70)
    pub rff_geraet_nummer: Option<String>,
    /// Required (X [204]). (an..3)
    pub rff_qualifier_geraet: Option<RffQualifierGeraet>,
    pub zeitscheibe: Option<ObisKennzahlZeitscheibe>,
}

/// Prozessdaten for PID 55643 — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    /// Required (unknown). ()
    pub aenderungszeitpunkt: Option<String>,
    /// Required (unknown). ()
    pub eingangsdatum: Option<String>,
    /// Required (X). (an..70)
    pub pruefidentifikator: Option<Pruefidentifikator>,
    /// Required (unknown). ()
    pub status_code: Option<String>,
    /// Required (X). (an..3)
    pub transaktionsgrund: Option<Transaktionsgrund>,
    /// Optional. (an..3)
    pub transaktionsgrund_detail: Option<TransaktionsgrundDetail>,
    /// Optional. (an..3)
    pub transaktionsgrund_ergaenzung: Option<TransaktionsgrundErgaenzung>,
    /// Required (X). (an..35)
    pub vorgang_id: Option<String>,
}

/// ZaehlerDaten for PID 55643 — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ZaehlerDaten {
    /// Required (X). (an..70)
    pub referenz: Option<String>,
    pub zeitscheibe: Option<ZaehlerDatenZeitscheibe>,
}

/// Zuordnung for PID 55643 — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Zuordnung {
    pub merkmal: Option<ZuordnungMerkmal>,
    /// Required (unknown). ()
    pub zugeordneter_mp: Option<String>,
}

/// PID 55643 transaction — Änderung Daten der MeLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub geschaeftspartner: Option<BTreeMap<GeschaeftspartnerKey, Geschaeftspartner>>,
    pub kontakt: Option<Kontakt>,
    /// 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 obis_kennzahl: Option<Vec<ObisKennzahl>>,
    pub prozessdaten: Option<Prozessdaten>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub zaehler_daten: Option<Vec<ZaehlerDaten>>,
    pub zuordnung: Option<Zuordnung>,
}

/// PID 55643 message-level — Änderung Daten der MeLo.
#[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>,
}

/// Complete interchange for PID 55643 — Änderung Daten der MeLo.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
