bo4e_core/enums/
calculation_method.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
11#[non_exhaustive]
12pub enum CalculationMethod {
13 #[serde(rename = "STUFEN")]
15 Steps,
16
17 #[serde(rename = "ZONEN")]
19 Zones,
20
21 #[serde(rename = "VORZONEN_GP")]
23 PreZoneBasePrice,
24
25 #[serde(rename = "SIGMOID")]
27 Sigmoid,
28
29 #[serde(rename = "BLINDARBEIT_GT_50_PROZENT")]
31 ReactivePowerAbove50Percent,
32
33 #[serde(rename = "BLINDARBEIT_GT_40_PROZENT")]
35 ReactivePowerAbove40Percent,
36
37 #[serde(rename = "BLINDARBEIT_MIT_FREIMENGE")]
39 ReactivePowerWithFreeAllowance,
40
41 #[serde(rename = "AP_GP_ZONEN")]
43 WorkingAndBasePriceZoned,
44
45 #[serde(rename = "LP_INSTALL_LEISTUNG")]
47 CapacityChargeInstalledCapacity,
48
49 #[serde(rename = "AP_TRANSPORT_ODER_VERTEILNETZ")]
51 WorkingPriceTransportOrDistribution,
52
53 #[serde(rename = "AP_TRANSPORT_ODER_VERTEILNETZ_ORTSVERTEILNETZ_SIGMOID")]
55 WorkingPriceTransportOrDistributionLocalSigmoid,
56
57 #[serde(rename = "LP_JAHRESVERBRAUCH")]
59 CapacityChargeAnnualConsumption,
60
61 #[serde(rename = "LP_TRANSPORT_ODER_VERTEILNETZ")]
63 CapacityPriceTransportOrDistribution,
64
65 #[serde(rename = "LP_TRANSPORT_ODER_VERTEILNETZ_ORTSVERTEILNETZ_SIGMOID")]
67 CapacityPriceTransportOrDistributionLocalSigmoid,
68
69 #[serde(rename = "FUNKTIONEN")]
71 Functions,
72
73 #[serde(rename = "VERBRAUCH_UEBER_SLP_GRENZE_FUNKTIONSBEZOGEN_WEITERE_BERECHNUNG_ALS_LGK")]
75 ConsumptionAboveSLPThresholdFunctionBasedLGK,
76}
77
78impl CalculationMethod {
79 pub fn german_name(&self) -> &'static str {
81 match self {
82 Self::Steps => "Stufen",
83 Self::Zones => "Zonen",
84 Self::PreZoneBasePrice => "Vorzonengrundpreis",
85 Self::Sigmoid => "Sigmoid",
86 Self::ReactivePowerAbove50Percent => "Blindarbeit oberhalb 50% der Wirkarbeit",
87 Self::ReactivePowerAbove40Percent => "Blindarbeit oberhalb 40% der Wirkarbeit",
88 Self::ReactivePowerWithFreeAllowance => "Blindarbeit mit Freimenge",
89 Self::WorkingAndBasePriceZoned => "Arbeits- und Grundpreis gezont",
90 Self::CapacityChargeInstalledCapacity => {
91 "Leistungsentgelt auf Grundlage der installierten Leistung"
92 }
93 Self::WorkingPriceTransportOrDistribution => {
94 "AP auf Grundlage Transport- oder Verteilnetz"
95 }
96 Self::WorkingPriceTransportOrDistributionLocalSigmoid => {
97 "AP auf Grundlage Transport- oder Verteilnetz, Ortsverteilnetz über Sigmoid"
98 }
99 Self::CapacityChargeAnnualConsumption => {
100 "Leistungsentgelt auf Grundlage des Jahresverbrauchs"
101 }
102 Self::CapacityPriceTransportOrDistribution => {
103 "LP auf Grundlage Transport- oder Verteilnetz"
104 }
105 Self::CapacityPriceTransportOrDistributionLocalSigmoid => {
106 "LP auf Grundlage Transport- oder Verteilnetz, Ortsverteilnetz über Sigmoid"
107 }
108 Self::Functions => "Funktionen",
109 Self::ConsumptionAboveSLPThresholdFunctionBasedLGK => {
110 "Verbrauch über SLP-Grenze funktionsbezogen als LGK"
111 }
112 }
113 }
114}
115
116#[cfg(test)]
117mod tests {
118 use super::*;
119
120 #[test]
121 fn test_serialize() {
122 assert_eq!(
123 serde_json::to_string(&CalculationMethod::Steps).unwrap(),
124 r#""STUFEN""#
125 );
126 assert_eq!(
127 serde_json::to_string(&CalculationMethod::Zones).unwrap(),
128 r#""ZONEN""#
129 );
130 }
131
132 #[test]
133 fn test_deserialize() {
134 assert_eq!(
135 serde_json::from_str::<CalculationMethod>(r#""SIGMOID""#).unwrap(),
136 CalculationMethod::Sigmoid
137 );
138 }
139
140 #[test]
141 fn test_roundtrip() {
142 for method in [
143 CalculationMethod::Steps,
144 CalculationMethod::Zones,
145 CalculationMethod::PreZoneBasePrice,
146 CalculationMethod::Sigmoid,
147 CalculationMethod::ReactivePowerAbove50Percent,
148 CalculationMethod::ReactivePowerAbove40Percent,
149 CalculationMethod::ReactivePowerWithFreeAllowance,
150 CalculationMethod::WorkingAndBasePriceZoned,
151 CalculationMethod::CapacityChargeInstalledCapacity,
152 CalculationMethod::WorkingPriceTransportOrDistribution,
153 CalculationMethod::WorkingPriceTransportOrDistributionLocalSigmoid,
154 CalculationMethod::CapacityChargeAnnualConsumption,
155 CalculationMethod::CapacityPriceTransportOrDistribution,
156 CalculationMethod::CapacityPriceTransportOrDistributionLocalSigmoid,
157 CalculationMethod::Functions,
158 CalculationMethod::ConsumptionAboveSLPThresholdFunctionBasedLGK,
159 ] {
160 let json = serde_json::to_string(&method).unwrap();
161 let parsed: CalculationMethod = serde_json::from_str(&json).unwrap();
162 assert_eq!(method, parsed);
163 }
164 }
165}