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