// 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 55042
#[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 55042
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Partnerrolle {
    /// Messlokationsadresse
    #[serde(rename = "Z03")]
    Messlokationsadresse,
}

/// kommunikationsart for PID 55042
#[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 55042
#[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 55042
#[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,
}

/// pruefidentifikator for PID 55042
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Pruefidentifikator {
    /// WiM Strom / Anmeldung MSB
    #[serde(rename = "55042")]
    WimStromAnmeldungMsb,
}

/// transaktionsgrund for PID 55042
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsgrund {
    /// Kunde verlässt oder bezieht eine schon bestehende Marktlokation
    #[serde(rename = "E01")]
    KundeVerlaesstBestehendeMarktlokation,
    /// Kunde bezieht erstmals eine Marktlokation (z. B. Neubau)
    #[serde(rename = "E02")]
    KundeBeziehtErstmalsMarktlokationZBNeubau,
    /// - Kunde bleibt an der Marktlokation, hat nur den Marktpartner gewechselt - Ma...
    #[serde(rename = "E03")]
    KundeBleibtMarktlokationMarktpartnerGewechseltMarktpartnerKunden,
    /// Übernahme aufgrund nicht erfolgtem iMS-Einbau
    #[serde(rename = "ZJ4")]
    UebernahmeAufgrundNichtErfolgtemImsEinbau,
}

/// transaktionsgrundDetail for PID 55042
#[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,
}

/// transaktionsgrundLieferende for PID 55042
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TransaktionsgrundLieferende {
    /// 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,
}

/// geraeteCode for PID 55042
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum GeraeteCode {
    /// Gerätenummer
    #[serde(rename = "Z30")]
    Geraetenummer,
}

/// zaehlertypMerkmal for PID 55042
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZaehlertypMerkmal {
    /// Zählertyp
    #[serde(rename = "E13")]
    Zaehlertyp,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GeschaeftspartnerAdresse {
    /// Optional. (an..35)
    pub hausnummer: Option<String>,
    /// Required (X). (an..3)
    pub landescode: Option<String>,
    /// Required (X). (an..35)
    pub ort: Option<String>,
    /// Required (X). (an..17)
    pub postleitzahl: Option<String>,
    /// Required (S [166] M [212]). (an..35)
    pub strasse: Option<String>,
}

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

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

/// 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 55042 — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Geschaeftspartner {
    pub adresse: Option<GeschaeftspartnerAdresse>,
    /// Optional. (an..70)
    pub anrede: Option<String>,
    /// Required (X). (an..3)
    pub anrede_code: Option<AnredeCode>,
    /// Required (Soll [165]). ()
    pub geschaeftspartner_id: Option<String>,
    /// Required (X). (an..70)
    pub name1: Option<String>,
    /// Optional. (an..70)
    pub name2: Option<String>,
    /// Optional. (an..70)
    pub name_zeile3: Option<String>,
    /// Optional. (an..70)
    pub name_zeile4: Option<String>,
    /// Required (X). (an..3)
    pub partnerrolle: Option<Partnerrolle>,
    /// Required (Soll [165]). ()
    pub region: Option<String>,
    /// Optional. (an..35)
    pub strasse_zeile4: Option<String>,
    /// Optional. (an..35)
    pub strasse_zusatz: Option<String>,
    /// Required (K). (an..35)
    pub zusatzinfo: Option<String>,
    /// Optional. (an..35)
    pub zusatzinfo_zeile2: Option<String>,
    /// Optional. (an..35)
    pub zusatzinfo_zeile3: Option<String>,
    /// Optional. (an..35)
    pub zusatzinfo_zeile4: Option<String>,
    /// Optional. (an..35)
    pub zusatzinfo_zeile5: Option<String>,
}

/// Kontakt for PID 55042 — Anmeldung MSB.
#[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>,
}

/// Marktlokation for PID 55042 — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktlokation {
    /// Required (Muss ([77] ∧ [78]) ∧ [349] Kann). ()
    pub codeliste_code: Option<String>,
    /// Required (X [950]). (an..35)
    pub marktlokations_id: Option<String>,
    pub zeitscheibe: Option<MarktlokationZeitscheibe>,
}

/// Marktteilnehmer for PID 55042 — Anmeldung MSB.
#[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 55042 — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Messlokation {
    /// Required (Muss ([77] ∧ [78]) ∧ [347] ∧ [2061] Kann [2061]). ()
    pub codeliste_code: Option<String>,
    /// Required (X [951]). (an..35)
    pub messlokations_id: Option<String>,
    pub zeitscheibe: Option<MesslokationZeitscheibe>,
}

/// Nachricht for PID 55042 — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Required (X [931] [494]). (an..35)
    pub erstellungsdatum: Option<String>,
    /// Optional. ()
    pub nachrichtennummer: Option<String>,
    /// Optional. ()
    pub nachrichtentyp: Option<String>,
}

/// Prozessdaten for PID 55042 — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    /// Required (X [UB1]). (an..35)
    pub geplanter_lieferbeginn: Option<String>,
    /// Required (X). (an..70)
    pub pruefidentifikator: Option<Pruefidentifikator>,
    /// Required (X). (an..3)
    pub transaktionsgrund: Option<Transaktionsgrund>,
    /// Optional. (an..3)
    pub transaktionsgrund_detail: Option<TransaktionsgrundDetail>,
    /// Optional. (an..3)
    pub transaktionsgrund_lieferende: Option<TransaktionsgrundLieferende>,
    /// Required (X). (an..35)
    pub vorgang_id: Option<String>,
}

/// Zaehler for PID 55042 — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Zaehler {
    /// Required (X). (an..3)
    pub geraete_code: Option<GeraeteCode>,
    /// Required (X). (an..35)
    pub geraete_nummer: Option<String>,
    /// Required (X). (an..17)
    pub zaehlertyp_merkmal: Option<ZaehlertypMerkmal>,
}

/// PID 55042 transaction — Anmeldung MSB.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (Soll [165]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub geschaeftspartner: Option<BTreeMap<GeschaeftspartnerKey, Geschaeftspartner>>,
    pub kontakt: Option<Kontakt>,
    /// Required (Muss ([77] ∧ [78]) ∧ [349] Kann).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub marktlokation: Option<Vec<Marktlokation>>,
    /// Required (Muss ([77] ∧ [78]) ∧ [347] ∧ [2061] Kann [2061]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub messlokation: Option<Vec<Messlokation>>,
    pub prozessdaten: Option<Prozessdaten>,
    /// Required (Muss [78] ∧ [347] ∧ [349]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub zaehler: Option<Vec<Zaehler>>,
}

/// PID 55042 message-level — Anmeldung MSB.
#[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 55042 — Anmeldung MSB.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
