zugferd_code_lists/zugferd_2_3_3/
linereason.rs1#![allow(non_camel_case_types)]
2
3#[cfg_attr(feature = "specta", derive(specta::Type))]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
6pub enum LineReason {
7 RegularItemPositionStandardCase,
9 SubtotalOrGroup,
11 ForInformationOnly,
13}
14
15impl std::fmt::Display for LineReason {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 write!(f, "{}", <Self as crate::Code>::code(*self))
18 }
19}
20
21impl std::str::FromStr for LineReason {
22 type Err = ();
23 fn from_str(s: &str) -> Result<Self, Self::Err> {
24 <Self as crate::FromCode>::from_code(s).ok_or(())
25 }
26}
27
28impl crate::Code for LineReason {
29 fn code(self) -> &'static str {
30 match self {
31 LineReason::RegularItemPositionStandardCase => "DETAIL",
32 LineReason::SubtotalOrGroup => "GROUP",
33 LineReason::ForInformationOnly => "INFORMATION",
34 }
35 }
36}
37
38impl crate::Description for LineReason {
39 fn description(self) -> &'static str {
40 match self {
41 LineReason::RegularItemPositionStandardCase => "Regular item position (standard case)",
42 LineReason::SubtotalOrGroup => "Subtotal or group",
43 LineReason::ForInformationOnly => "For information only",
44 }
45 }
46}
47
48impl crate::FromCode for LineReason {
49 fn from_code(code: &str) -> Option<Self>
50 where
51 Self: Sized,
52 {
53 match code {
54 "DETAIL" => Some(LineReason::RegularItemPositionStandardCase),
55 "GROUP" => Some(LineReason::SubtotalOrGroup),
56 "INFORMATION" => Some(LineReason::ForInformationOnly),
57 _ => None,
58 }
59 }
60}