bo4e_core/enums/
concession_fee_customer_group.rs

1//! Concession fee customer group (KundengruppeKA) enumeration.
2
3use serde::{Deserialize, Serialize};
4
5/// Customer group classification for concession fee calculation.
6///
7/// An enumeration for classifying the level of concession fees.
8///
9/// German: KundengruppeKA (Kundengruppe Konzessionsabgabe)
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
11#[non_exhaustive]
12pub enum ConcessionFeeCustomerGroup {
13    // Electricity tariff groups
14    /// Electricity off-peak/low load (Strom Schwachlast)
15    #[serde(rename = "S_SCHWACHLAST")]
16    ElectricityOffPeak,
17
18    /// Electricity tariff up to 25,000 kWh
19    #[serde(rename = "S_TARIF_25000")]
20    ElectricityTariff25000,
21
22    /// Electricity tariff up to 100,000 kWh
23    #[serde(rename = "S_TARIF_100000")]
24    ElectricityTariff100000,
25
26    /// Electricity tariff up to 500,000 kWh
27    #[serde(rename = "S_TARIF_500000")]
28    ElectricityTariff500000,
29
30    /// Electricity tariff above 500,000 kWh
31    #[serde(rename = "S_TARIF_G_500000")]
32    ElectricityTariffAbove500000,
33
34    /// Electricity special contract customer (Strom Sonderkunde)
35    #[serde(rename = "S_SONDERKUNDE")]
36    ElectricitySpecialCustomer,
37
38    // Gas cooking/hot water tariff groups
39    /// Gas cooking/hot water up to 25,000 kWh
40    #[serde(rename = "G_KOWA_25000")]
41    GasCookingHotWater25000,
42
43    /// Gas cooking/hot water up to 100,000 kWh
44    #[serde(rename = "G_KOWA_100000")]
45    GasCookingHotWater100000,
46
47    /// Gas cooking/hot water up to 500,000 kWh
48    #[serde(rename = "G_KOWA_500000")]
49    GasCookingHotWater500000,
50
51    /// Gas cooking/hot water above 500,000 kWh
52    #[serde(rename = "G_KOWA_G_500000")]
53    GasCookingHotWaterAbove500000,
54
55    // Gas tariff groups
56    /// Gas tariff up to 25,000 kWh
57    #[serde(rename = "G_TARIF_25000")]
58    GasTariff25000,
59
60    /// Gas tariff up to 100,000 kWh
61    #[serde(rename = "G_TARIF_100000")]
62    GasTariff100000,
63
64    /// Gas tariff up to 500,000 kWh
65    #[serde(rename = "G_TARIF_500000")]
66    GasTariff500000,
67
68    /// Gas tariff above 500,000 kWh
69    #[serde(rename = "G_TARIF_G_500000")]
70    GasTariffAbove500000,
71
72    /// Gas special contract customer (Gas Sonderkunde)
73    #[serde(rename = "G_SONDERKUNDE")]
74    GasSpecialCustomer,
75
76    // Special categories for both electricity and gas
77    /// Special KAS - applies to both electricity and gas
78    #[serde(rename = "SONDER_KAS")]
79    SpecialKAS,
80
81    /// Special SAS - applies to both electricity and gas
82    #[serde(rename = "SONDER_SAS")]
83    SpecialSAS,
84
85    /// Special TAS - applies to both electricity and gas
86    #[serde(rename = "SONDER_TAS")]
87    SpecialTAS,
88
89    /// Special TKS - applies to gas
90    #[serde(rename = "SONDER_TKS")]
91    SpecialTKS,
92
93    /// Special TSS - applies to electricity
94    #[serde(rename = "SONDER_TSS")]
95    SpecialTSS,
96}
97
98impl ConcessionFeeCustomerGroup {
99    /// Returns the German name.
100    pub fn german_name(&self) -> &'static str {
101        match self {
102            Self::ElectricityOffPeak => "Strom Schwachlast",
103            Self::ElectricityTariff25000 => "Strom Tarif bis 25.000 kWh",
104            Self::ElectricityTariff100000 => "Strom Tarif bis 100.000 kWh",
105            Self::ElectricityTariff500000 => "Strom Tarif bis 500.000 kWh",
106            Self::ElectricityTariffAbove500000 => "Strom Tarif über 500.000 kWh",
107            Self::ElectricitySpecialCustomer => "Strom Sonderkunde",
108            Self::GasCookingHotWater25000 => "Gas Kochen/Warmwasser bis 25.000 kWh",
109            Self::GasCookingHotWater100000 => "Gas Kochen/Warmwasser bis 100.000 kWh",
110            Self::GasCookingHotWater500000 => "Gas Kochen/Warmwasser bis 500.000 kWh",
111            Self::GasCookingHotWaterAbove500000 => "Gas Kochen/Warmwasser über 500.000 kWh",
112            Self::GasTariff25000 => "Gas Tarif bis 25.000 kWh",
113            Self::GasTariff100000 => "Gas Tarif bis 100.000 kWh",
114            Self::GasTariff500000 => "Gas Tarif bis 500.000 kWh",
115            Self::GasTariffAbove500000 => "Gas Tarif über 500.000 kWh",
116            Self::GasSpecialCustomer => "Gas Sonderkunde",
117            Self::SpecialKAS => "Sonder KAS",
118            Self::SpecialSAS => "Sonder SAS",
119            Self::SpecialTAS => "Sonder TAS",
120            Self::SpecialTKS => "Sonder TKS (Gas)",
121            Self::SpecialTSS => "Sonder TSS (Strom)",
122        }
123    }
124
125    /// Returns true if this group applies to electricity.
126    pub fn is_electricity(&self) -> bool {
127        matches!(
128            self,
129            Self::ElectricityOffPeak
130                | Self::ElectricityTariff25000
131                | Self::ElectricityTariff100000
132                | Self::ElectricityTariff500000
133                | Self::ElectricityTariffAbove500000
134                | Self::ElectricitySpecialCustomer
135                | Self::SpecialKAS
136                | Self::SpecialSAS
137                | Self::SpecialTAS
138                | Self::SpecialTSS
139        )
140    }
141
142    /// Returns true if this group applies to gas.
143    pub fn is_gas(&self) -> bool {
144        matches!(
145            self,
146            Self::GasCookingHotWater25000
147                | Self::GasCookingHotWater100000
148                | Self::GasCookingHotWater500000
149                | Self::GasCookingHotWaterAbove500000
150                | Self::GasTariff25000
151                | Self::GasTariff100000
152                | Self::GasTariff500000
153                | Self::GasTariffAbove500000
154                | Self::GasSpecialCustomer
155                | Self::SpecialKAS
156                | Self::SpecialSAS
157                | Self::SpecialTAS
158                | Self::SpecialTKS
159        )
160    }
161}
162
163#[cfg(test)]
164mod tests {
165    use super::*;
166
167    #[test]
168    fn test_serialize() {
169        assert_eq!(
170            serde_json::to_string(&ConcessionFeeCustomerGroup::ElectricityOffPeak).unwrap(),
171            r#""S_SCHWACHLAST""#
172        );
173        assert_eq!(
174            serde_json::to_string(&ConcessionFeeCustomerGroup::GasTariff25000).unwrap(),
175            r#""G_TARIF_25000""#
176        );
177    }
178
179    #[test]
180    fn test_roundtrip() {
181        for group in [
182            ConcessionFeeCustomerGroup::ElectricityOffPeak,
183            ConcessionFeeCustomerGroup::ElectricityTariff25000,
184            ConcessionFeeCustomerGroup::ElectricityTariff100000,
185            ConcessionFeeCustomerGroup::ElectricityTariff500000,
186            ConcessionFeeCustomerGroup::ElectricityTariffAbove500000,
187            ConcessionFeeCustomerGroup::ElectricitySpecialCustomer,
188            ConcessionFeeCustomerGroup::GasCookingHotWater25000,
189            ConcessionFeeCustomerGroup::GasCookingHotWater100000,
190            ConcessionFeeCustomerGroup::GasCookingHotWater500000,
191            ConcessionFeeCustomerGroup::GasCookingHotWaterAbove500000,
192            ConcessionFeeCustomerGroup::GasTariff25000,
193            ConcessionFeeCustomerGroup::GasTariff100000,
194            ConcessionFeeCustomerGroup::GasTariff500000,
195            ConcessionFeeCustomerGroup::GasTariffAbove500000,
196            ConcessionFeeCustomerGroup::GasSpecialCustomer,
197            ConcessionFeeCustomerGroup::SpecialKAS,
198            ConcessionFeeCustomerGroup::SpecialSAS,
199            ConcessionFeeCustomerGroup::SpecialTAS,
200            ConcessionFeeCustomerGroup::SpecialTKS,
201            ConcessionFeeCustomerGroup::SpecialTSS,
202        ] {
203            let json = serde_json::to_string(&group).unwrap();
204            let parsed: ConcessionFeeCustomerGroup = serde_json::from_str(&json).unwrap();
205            assert_eq!(group, parsed);
206        }
207    }
208
209    #[test]
210    fn test_is_electricity() {
211        assert!(ConcessionFeeCustomerGroup::ElectricityOffPeak.is_electricity());
212        assert!(ConcessionFeeCustomerGroup::SpecialTSS.is_electricity());
213        assert!(!ConcessionFeeCustomerGroup::GasTariff25000.is_electricity());
214    }
215
216    #[test]
217    fn test_is_gas() {
218        assert!(ConcessionFeeCustomerGroup::GasTariff25000.is_gas());
219        assert!(ConcessionFeeCustomerGroup::SpecialTKS.is_gas());
220        assert!(!ConcessionFeeCustomerGroup::ElectricityOffPeak.is_gas());
221    }
222}