zugferd_code_lists/zugferd_2_3_3/
timecii.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 TimeCII {
7    /// Date of invoice
8    DateInvoice,
9    /// Date of delivery of goods to establishments/domicile/site
10    DateDeliveryGoodsToEstablishmentsDomicileSite,
11    /// Payment date
12    PaymentDate,
13}
14
15impl std::fmt::Display for TimeCII {
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 TimeCII {
22    type Err = crate::ParseError<Self>;
23    fn from_str(s: &str) -> Result<Self, Self::Err> {
24        <Self as crate::FromCode>::from_code(s)
25            .ok_or_else(|| crate::ParseError::<Self>::new(s.to_owned()))
26    }
27}
28
29impl crate::Code for TimeCII {
30    fn code(self) -> &'static str {
31        match self {
32            TimeCII::DateInvoice => "5",
33            TimeCII::DateDeliveryGoodsToEstablishmentsDomicileSite => "29",
34            TimeCII::PaymentDate => "72",
35        }
36    }
37}
38
39impl crate::Description for TimeCII {
40    fn description(self) -> &'static str {
41        match self {
42            TimeCII::DateInvoice => "Date of invoice",
43            TimeCII::DateDeliveryGoodsToEstablishmentsDomicileSite => {
44                "Date of delivery of goods to establishments/domicile/site"
45            }
46            TimeCII::PaymentDate => "Payment date",
47        }
48    }
49}
50
51impl crate::FromCode for TimeCII {
52    fn from_code(code: &str) -> Option<Self>
53    where
54        Self: Sized,
55    {
56        match code {
57            "5" => Some(TimeCII::DateInvoice),
58            "29" => Some(TimeCII::DateDeliveryGoodsToEstablishmentsDomicileSite),
59            "72" => Some(TimeCII::PaymentDate),
60            _ => None,
61        }
62    }
63}