Skip to main content

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