zugferd_code_lists/zugferd_2_3_2/
linereason.rs

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