zugferd_code_lists/zugferd_2_3_3/
linereason.rs

1#![allow(non_camel_case_types)]
2
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
5pub enum LineReason {
6    /// Regular item position (standard case)
7    RegularItemPositionStandardCase,
8    /// Subtotal or group
9    SubtotalOrGroup,
10    /// For information only
11    ForInformationOnly,
12}
13
14impl crate::Code for LineReason {
15    fn code(self) -> &'static str {
16        match self {
17            LineReason::RegularItemPositionStandardCase => "DETAIL",
18            LineReason::SubtotalOrGroup => "GROUP",
19            LineReason::ForInformationOnly => "INFORMATION",
20        }
21    }
22}
23
24impl crate::Description for LineReason {
25    fn description(self) -> &'static str {
26        match self {
27            LineReason::RegularItemPositionStandardCase => "Regular item position (standard case)",
28            LineReason::SubtotalOrGroup => "Subtotal or group",
29            LineReason::ForInformationOnly => "For information only",
30        }
31    }
32}
33
34impl crate::FromCode for LineReason {
35    fn from_code(code: &str) -> Option<Self>
36    where
37        Self: Sized,
38    {
39        match code {
40            "DETAIL" => Some(LineReason::RegularItemPositionStandardCase),
41            "GROUP" => Some(LineReason::SubtotalOrGroup),
42            "INFORMATION" => Some(LineReason::ForInformationOnly),
43            _ => None,
44        }
45    }
46}