zugferd_code_lists/zugferd_2_3_3/
linereason.rs

1#![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    /// Regular item position (standard case)
8    RegularItemPositionStandardCase,
9    /// Subtotal or group
10    SubtotalOrGroup,
11    /// For information only
12    ForInformationOnly,
13}
14
15impl crate::Code for LineReason {
16    fn code(self) -> &'static str {
17        match self {
18            LineReason::RegularItemPositionStandardCase => "DETAIL",
19            LineReason::SubtotalOrGroup => "GROUP",
20            LineReason::ForInformationOnly => "INFORMATION",
21        }
22    }
23}
24
25impl crate::Description for LineReason {
26    fn description(self) -> &'static str {
27        match self {
28            LineReason::RegularItemPositionStandardCase => "Regular item position (standard case)",
29            LineReason::SubtotalOrGroup => "Subtotal or group",
30            LineReason::ForInformationOnly => "For information only",
31        }
32    }
33}
34
35impl crate::FromCode for LineReason {
36    fn from_code(code: &str) -> Option<Self>
37    where
38        Self: Sized,
39    {
40        match code {
41            "DETAIL" => Some(LineReason::RegularItemPositionStandardCase),
42            "GROUP" => Some(LineReason::SubtotalOrGroup),
43            "INFORMATION" => Some(LineReason::ForInformationOnly),
44            _ => None,
45        }
46    }
47}