zugferd_code_lists/zugferd_2_3_2/
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 = ();
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 TimeCII {
29    fn code(self) -> &'static str {
30        match self {
31            TimeCII::DateInvoice => "5",
32            TimeCII::DateDeliveryGoodsToEstablishmentsDomicileSite => "29",
33            TimeCII::PaymentDate => "72",
34        }
35    }
36}
37
38impl crate::Description for TimeCII {
39    fn description(self) -> &'static str {
40        match self {
41            TimeCII::DateInvoice => "Date of invoice",
42            TimeCII::DateDeliveryGoodsToEstablishmentsDomicileSite => {
43                "Date of delivery of goods to establishments/domicile/site"
44            }
45            TimeCII::PaymentDate => "Payment date",
46        }
47    }
48}
49
50impl crate::FromCode for TimeCII {
51    fn from_code(code: &str) -> Option<Self>
52    where
53        Self: Sized,
54    {
55        match code {
56            "5" => Some(TimeCII::DateInvoice),
57            "29" => Some(TimeCII::DateDeliveryGoodsToEstablishmentsDomicileSite),
58            "72" => Some(TimeCII::PaymentDate),
59            _ => None,
60        }
61    }
62}