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

/// textbezug for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Textbezug {
    /// Internetseite
    #[serde(rename = "Z13")]
    Internetseite,
}

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

/// produktIdentifikation.funktion for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ProduktpaketDatenFunktion {
    /// Produktidentifikation
    #[serde(rename = "5")]
    Produktidentifikation,
}

/// produktIdentifikation.typ for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ProduktpaketDatenTyp {
    /// Produkt
    #[serde(rename = "Z11")]
    Produkt,
}

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

/// pruefidentifikator for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Pruefidentifikator {
    /// GPKE / Anmeldung erzeugende Marktlokation
    #[serde(rename = "55077")]
    GpkeAnmeldungErzeugendeMarktlokation,
}

/// transaktionsgrund for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsgrund {
    /// - Kunde bleibt an der Marktlokation, hat nur den Marktpartner gewechselt - Ma...
    #[serde(rename = "E03")]
    KundeBleibtMarktlokationMarktpartnerGewechseltMarktpartnerKunden,
}

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

/// transaktionsgrundErgaenzung for PID 55077
#[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_codepflege for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungCodeCodepflege {
    /// DE, BDEW (Bundesverband der Energie- und Wasserwirtschaft e.V.)
    #[serde(rename = "293")]
    DeBdewBundesverbandEnergieWasserwirtschaftEV,
}

/// merkmal.codeliste for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungCodeliste {
    /// EDI@Energy Codeliste der europäischen Ländercodes
    #[serde(rename = "LAND")]
    EdiEnergyCodelisteEuropaeischenLaendercodes,
}

/// merkmal.klasse for PID 55077
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungKlasse {
    /// Land der Förderung
    #[serde(rename = "Z23")]
    LandFoerderung,
}

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

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProduktpaketDatenProduktIdentifikation {
    /// Required (X). (an..3)
    pub funktion: Option<ProduktpaketDatenFunktion>,
    /// Required (X [292]). (an..35)
    pub id: Option<String>,
    /// Required (x). (an..3)
    pub typ: Option<ProduktpaketDatenTyp>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProduktpaketDatenZeitscheibe {
    /// Required (X [914] ∧ [937]). (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<String>,
    /// Required (X). (an..3)
    pub code_codepflege: Option<ZuordnungCodeCodepflege>,
    /// Required (X). (an..17)
    pub codeliste: Option<ZuordnungCodeliste>,
    /// Required (unknown). ()
    pub codepflege: Option<String>,
    /// Required (unknown). ()
    pub dimension: Option<String>,
    /// Required (unknown). ()
    pub eigenschaft: Option<String>,
    /// Required (X). (an..3)
    pub klasse: Option<ZuordnungKlasse>,
    /// Required (unknown). ()
    pub qualifier: 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,
}

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

/// Freitext for PID 55077 — Anmeldung erz. MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Freitext {
    /// Required (X). (an..512)
    pub text: Option<String>,
    /// Required (X). (an..17)
    pub text_referenz: Option<String>,
    /// Optional. (an..512)
    pub text_zeile2: Option<String>,
    /// Optional. (an..512)
    pub text_zeile3: Option<String>,
    /// Optional. (an..512)
    pub text_zeile4: Option<String>,
    /// Optional. (an..512)
    pub text_zeile5: Option<String>,
    /// Required (X). (an..3)
    pub textbezug: Option<Textbezug>,
    /// Required (unknown). ()
    pub textfunktion: Option<String>,
}

/// Marktlokation for PID 55077 — Anmeldung erz. MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktlokation {
    /// Required (Muss [2061] ∧ ([476] ⊻ [478])). ()
    pub codeliste_code: Option<String>,
    /// Required (Muss [2061] ∧ ([476] ⊻ [478])). ()
    pub codepflege_code: Option<String>,
    /// Optional. (an..256)
    pub lokation_zeitraum_id: Option<String>,
    /// Required (X [950]). (an..35)
    pub marktlokations_id: Option<String>,
    pub zeitscheibe: Option<MarktlokationZeitscheibe>,
}

/// Marktteilnehmer for PID 55077 — Anmeldung 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>,
}

/// Nachricht for PID 55077 — Anmeldung erz. MaLo.
#[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>,
}

/// ProduktpaketDaten for PID 55077 — Anmeldung erz. MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ProduktpaketDaten {
    pub produkt_identifikation: Option<ProduktpaketDatenProduktIdentifikation>,
    pub zeitscheibe: Option<ProduktpaketDatenZeitscheibe>,
}

/// Prozessdaten for PID 55077 — Anmeldung erz. MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    /// Required (unknown). ()
    pub bearbeitungsstand: Option<String>,
    /// Required (X [UB1]). (an..35)
    pub gueltig_ab: 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>,
}

/// Tranche for PID 55077 — Anmeldung erz. MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Tranche {
    /// Required (Muss [2061] ∧ [477]). ()
    pub codeliste_code: Option<String>,
    /// Required (Muss [2061] ∧ [477]). ()
    pub codepflege_code: Option<String>,
    /// Optional. (an..256)
    pub lokation_zeitraum_id: Option<String>,
    /// Required (X [950]). (an..35)
    pub tranche_id: Option<String>,
}

/// Zuordnung for PID 55077 — Anmeldung erz. MaLo.
#[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 55077 transaction — Anmeldung erz. MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    pub freitext: Option<Freitext>,
    /// Required (Muss [2061] ∧ ([476] ⊻ [478])).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub marktlokation: Option<Vec<Marktlokation>>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub produktpaket_daten: Option<Vec<ProduktpaketDaten>>,
    pub prozessdaten: Option<Prozessdaten>,
    /// Required (Muss [2061] ∧ [477]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub tranche: Option<Vec<Tranche>>,
    pub zuordnung: Option<Zuordnung>,
}

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