Skip to main content

bo4e_core/enums/
customer_group.rs

1//! Customer group (Kundengruppe) enumeration.
2
3use serde::{Deserialize, Serialize};
4
5/// Customer group for a market location (based on standard load profiles).
6///
7/// German: Kundengruppe
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
10#[cfg_attr(feature = "json-schema", schemars(rename = "Kundengruppe"))]
11#[non_exhaustive]
12pub enum CustomerGroup {
13    // RLM profiles (metered)
14    /// Customer with registering power measurement (no SLP)
15    #[serde(rename = "RLM")]
16    Rlm,
17
18    /// Municipal consumption point with power measurement
19    #[serde(rename = "RLM_KOMMUNAL")]
20    RlmMunicipal,
21
22    /// Municipal consumption point without power measurement
23    #[serde(rename = "SLP_KOMMUNAL")]
24    SlpMunicipal,
25
26    // Electricity SLP profiles (G - commercial)
27    /// General commercial (G0)
28    #[serde(rename = "SLP_S_G0")]
29    SlpElectricityG0,
30
31    /// Weekdays (G1)
32    #[serde(rename = "SLP_S_G1")]
33    SlpElectricityG1,
34
35    /// Evening consumption (G2)
36    #[serde(rename = "SLP_S_G2")]
37    SlpElectricityG2,
38
39    /// Continuous commercial (G3)
40    #[serde(rename = "SLP_S_G3")]
41    SlpElectricityG3,
42
43    /// Shop, hairdresser (G4)
44    #[serde(rename = "SLP_S_G4")]
45    SlpElectricityG4,
46
47    /// Bakery with bakehouse (G5)
48    #[serde(rename = "SLP_S_G5")]
49    SlpElectricityG5,
50
51    /// Weekend operation (G6)
52    #[serde(rename = "SLP_S_G6")]
53    SlpElectricityG6,
54
55    /// Mobile phone base station (G7)
56    #[serde(rename = "SLP_S_G7")]
57    SlpElectricityG7,
58
59    // Electricity SLP profiles (L - agriculture)
60    /// Agriculture general (L0)
61    #[serde(rename = "SLP_S_L0")]
62    SlpElectricityL0,
63
64    /// Agriculture with dairy/sideline animal breeding (L1)
65    #[serde(rename = "SLP_S_L1")]
66    SlpElectricityL1,
67
68    /// Other agricultural businesses (L2)
69    #[serde(rename = "SLP_S_L2")]
70    SlpElectricityL2,
71
72    // Electricity SLP profiles (H - household)
73    /// Household general (H0)
74    #[serde(rename = "SLP_S_H0")]
75    SlpElectricityH0,
76
77    // Electricity SLP profiles (special)
78    /// Street lighting (SB)
79    #[serde(rename = "SLP_S_SB")]
80    SlpElectricitySb,
81
82    /// Night storage heating (HZ)
83    #[serde(rename = "SLP_S_HZ")]
84    SlpElectricityHz,
85
86    /// Heat pump (WP)
87    #[serde(rename = "SLP_S_WP")]
88    SlpElectricityWp,
89
90    /// Electric mobility (EM)
91    #[serde(rename = "SLP_S_EM")]
92    SlpElectricityEm,
93
94    /// Night storage heating common measurement (HZ_GEM)
95    #[serde(rename = "SLP_S_HZ_GEM")]
96    SlpElectricityHzGem,
97
98    // Gas SLP profiles
99    /// Territorial authorities, credit institutions, insurance, non-profit organizations & public facilities
100    #[serde(rename = "SLP_G_GKO")]
101    SlpGasGko,
102
103    /// Standard customer group for gas
104    #[serde(rename = "SLP_G_STANDARD")]
105    SlpGasStandard,
106
107    /// Retail, wholesale
108    #[serde(rename = "SLP_G_GHA")]
109    SlpGasGha,
110
111    /// Metal, automotive
112    #[serde(rename = "SLP_G_GMK")]
113    SlpGasGmk,
114
115    /// Other operational services
116    #[serde(rename = "SLP_G_GBD")]
117    SlpGasGbd,
118
119    /// Accommodation
120    #[serde(rename = "SLP_G_GGA")]
121    SlpGasGga,
122
123    /// Restaurants
124    #[serde(rename = "SLP_G_GBH")]
125    SlpGasGbh,
126
127    /// Bakeries
128    #[serde(rename = "SLP_G_GBA")]
129    SlpGasGba,
130
131    /// Laundries
132    #[serde(rename = "SLP_G_GWA")]
133    SlpGasGwa,
134
135    /// Horticulture
136    #[serde(rename = "SLP_G_GGB")]
137    SlpGasGgb,
138
139    /// Paper and printing
140    #[serde(rename = "SLP_G_GPD")]
141    SlpGasGpd,
142
143    /// Household-like commercial enterprises
144    #[serde(rename = "SLP_G_GMF")]
145    SlpGasGmf,
146
147    /// Single-family household
148    #[serde(rename = "SLP_G_HEF")]
149    SlpGasHef,
150
151    /// Multi-family household
152    #[serde(rename = "SLP_G_HMF")]
153    SlpGasHmf,
154
155    /// Cooking gas
156    #[serde(rename = "SLP_G_HKO")]
157    SlpGasHko,
158}
159
160impl CustomerGroup {
161    /// Returns the German name.
162    pub fn german_name(&self) -> &'static str {
163        match self {
164            Self::Rlm => "RLM",
165            Self::RlmMunicipal => "RLM Kommunal",
166            Self::SlpMunicipal => "SLP Kommunal",
167            Self::SlpElectricityG0 => "Gewerbe allgemein",
168            Self::SlpElectricityG1 => "Werktags",
169            Self::SlpElectricityG2 => "Verbrauch in Abendstunden",
170            Self::SlpElectricityG3 => "Gewerbe durchlaufend",
171            Self::SlpElectricityG4 => "Laden, Friseur",
172            Self::SlpElectricityG5 => "Baeckerei mit Backstube",
173            Self::SlpElectricityG6 => "Wochenendbetrieb",
174            Self::SlpElectricityG7 => "Mobilfunksendestation",
175            Self::SlpElectricityL0 => "Landwirtschaft allgemein",
176            Self::SlpElectricityL1 => "Landwirtschaft mit Milchwirtschaft",
177            Self::SlpElectricityL2 => "Uebrige Landwirtschaftsbetriebe",
178            Self::SlpElectricityH0 => "Haushalt allgemein",
179            Self::SlpElectricitySb => "Strassenbeleuchtung",
180            Self::SlpElectricityHz => "Nachtspeicherheizung",
181            Self::SlpElectricityWp => "Waermepumpe",
182            Self::SlpElectricityEm => "Elektromobilitaet",
183            Self::SlpElectricityHzGem => "Nachtspeicherheizung gemeinsame Messung",
184            Self::SlpGasGko => "Gebietskoerperschaften, Kreditinstitute, Versicherungen",
185            Self::SlpGasStandard => "Standardkundengruppe Gas",
186            Self::SlpGasGha => "Einzelhandel, Grosshandel",
187            Self::SlpGasGmk => "Metall, Kfz",
188            Self::SlpGasGbd => "sonst. betr. Dienstleistungen",
189            Self::SlpGasGga => "Beherbergung",
190            Self::SlpGasGbh => "Gaststaetten",
191            Self::SlpGasGba => "Baeckereien",
192            Self::SlpGasGwa => "Waeschereien",
193            Self::SlpGasGgb => "Gartenbau",
194            Self::SlpGasGpd => "Papier und Druck",
195            Self::SlpGasGmf => "haushaltsaehnliche Gewerbebetriebe",
196            Self::SlpGasHef => "Einfamilienhaushalt",
197            Self::SlpGasHmf => "Mehrfamilienhaushalt",
198            Self::SlpGasHko => "Kochgas",
199        }
200    }
201}
202
203#[cfg(test)]
204mod tests {
205    use super::*;
206
207    #[test]
208    fn test_serialize() {
209        assert_eq!(
210            serde_json::to_string(&CustomerGroup::Rlm).unwrap(),
211            r#""RLM""#
212        );
213        assert_eq!(
214            serde_json::to_string(&CustomerGroup::SlpElectricityH0).unwrap(),
215            r#""SLP_S_H0""#
216        );
217    }
218
219    #[test]
220    fn test_deserialize() {
221        assert_eq!(
222            serde_json::from_str::<CustomerGroup>(r#""RLM""#).unwrap(),
223            CustomerGroup::Rlm
224        );
225        assert_eq!(
226            serde_json::from_str::<CustomerGroup>(r#""SLP_G_HEF""#).unwrap(),
227            CustomerGroup::SlpGasHef
228        );
229    }
230
231    #[test]
232    fn test_roundtrip() {
233        for group in [
234            CustomerGroup::Rlm,
235            CustomerGroup::RlmMunicipal,
236            CustomerGroup::SlpMunicipal,
237            CustomerGroup::SlpElectricityG0,
238            CustomerGroup::SlpElectricityH0,
239            CustomerGroup::SlpGasStandard,
240            CustomerGroup::SlpGasHef,
241        ] {
242            let json = serde_json::to_string(&group).unwrap();
243            let parsed: CustomerGroup = serde_json::from_str(&json).unwrap();
244            assert_eq!(group, parsed);
245        }
246    }
247}