zugferd_code_lists/zugferd_2_3_3/
allowance.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 Allowance {
7    /// Bonus for works ahead of schedule
8    BonusForWorksAheadSchedule,
9    /// Other bonus
10    OtherBonus,
11    /// Manufacturer’s consumer discount
12    ManufacturerSConsumerDiscount,
13    /// Due to military status
14    DueToMilitaryStatus,
15    /// Due to work accident
16    DueToWorkAccident,
17    /// Special agreement
18    SpecialAgreement,
19    /// Production error discount
20    ProductionErrorDiscount,
21    /// New outlet discount
22    NewOutletDiscount,
23    /// Sample discount
24    SampleDiscount,
25    /// End-of-range discount
26    EndRangeDiscount,
27    /// Incoterm discount
28    IncotermDiscount,
29    /// Point of sales threshold allowance
30    PointSalesThresholdAllowance,
31    /// Material surcharge/deduction
32    MaterialSurchargeDeduction,
33    /// Discount
34    Discount,
35    /// Special rebate
36    SpecialRebate,
37    /// Fixed long term
38    FixedLongTerm,
39    /// Temporary
40    Temporary,
41    /// Standard
42    Standard,
43    /// Yearly turnover
44    YearlyTurnover,
45}
46
47impl std::fmt::Display for Allowance {
48    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49        write!(f, "{}", <Self as crate::Code>::code(*self))
50    }
51}
52
53impl std::str::FromStr for Allowance {
54    type Err = ();
55    fn from_str(s: &str) -> Result<Self, Self::Err> {
56        <Self as crate::FromCode>::from_code(s).ok_or(())
57    }
58}
59
60impl crate::Code for Allowance {
61    fn code(self) -> &'static str {
62        match self {
63            Allowance::BonusForWorksAheadSchedule => "41",
64            Allowance::OtherBonus => "42",
65            Allowance::ManufacturerSConsumerDiscount => "60",
66            Allowance::DueToMilitaryStatus => "62",
67            Allowance::DueToWorkAccident => "63",
68            Allowance::SpecialAgreement => "64",
69            Allowance::ProductionErrorDiscount => "65",
70            Allowance::NewOutletDiscount => "66",
71            Allowance::SampleDiscount => "67",
72            Allowance::EndRangeDiscount => "68",
73            Allowance::IncotermDiscount => "70",
74            Allowance::PointSalesThresholdAllowance => "71",
75            Allowance::MaterialSurchargeDeduction => "88",
76            Allowance::Discount => "95",
77            Allowance::SpecialRebate => "100",
78            Allowance::FixedLongTerm => "102",
79            Allowance::Temporary => "103",
80            Allowance::Standard => "104",
81            Allowance::YearlyTurnover => "105",
82        }
83    }
84}
85
86impl crate::Description for Allowance {
87    fn description(self) -> &'static str {
88        match self {
89            Allowance::BonusForWorksAheadSchedule => "Bonus for works ahead of schedule",
90            Allowance::OtherBonus => "Other bonus",
91            Allowance::ManufacturerSConsumerDiscount => "Manufacturer’s consumer discount",
92            Allowance::DueToMilitaryStatus => "Due to military status",
93            Allowance::DueToWorkAccident => "Due to work accident",
94            Allowance::SpecialAgreement => "Special agreement",
95            Allowance::ProductionErrorDiscount => "Production error discount",
96            Allowance::NewOutletDiscount => "New outlet discount",
97            Allowance::SampleDiscount => "Sample discount",
98            Allowance::EndRangeDiscount => "End-of-range discount",
99            Allowance::IncotermDiscount => "Incoterm discount",
100            Allowance::PointSalesThresholdAllowance => "Point of sales threshold allowance",
101            Allowance::MaterialSurchargeDeduction => "Material surcharge/deduction",
102            Allowance::Discount => "Discount",
103            Allowance::SpecialRebate => "Special rebate",
104            Allowance::FixedLongTerm => "Fixed long term",
105            Allowance::Temporary => "Temporary",
106            Allowance::Standard => "Standard",
107            Allowance::YearlyTurnover => "Yearly turnover",
108        }
109    }
110}
111
112impl crate::FromCode for Allowance {
113    fn from_code(code: &str) -> Option<Self>
114    where
115        Self: Sized,
116    {
117        match code {
118            "41" => Some(Allowance::BonusForWorksAheadSchedule),
119            "42" => Some(Allowance::OtherBonus),
120            "60" => Some(Allowance::ManufacturerSConsumerDiscount),
121            "62" => Some(Allowance::DueToMilitaryStatus),
122            "63" => Some(Allowance::DueToWorkAccident),
123            "64" => Some(Allowance::SpecialAgreement),
124            "65" => Some(Allowance::ProductionErrorDiscount),
125            "66" => Some(Allowance::NewOutletDiscount),
126            "67" => Some(Allowance::SampleDiscount),
127            "68" => Some(Allowance::EndRangeDiscount),
128            "70" => Some(Allowance::IncotermDiscount),
129            "71" => Some(Allowance::PointSalesThresholdAllowance),
130            "88" => Some(Allowance::MaterialSurchargeDeduction),
131            "95" => Some(Allowance::Discount),
132            "100" => Some(Allowance::SpecialRebate),
133            "102" => Some(Allowance::FixedLongTerm),
134            "103" => Some(Allowance::Temporary),
135            "104" => Some(Allowance::Standard),
136            "105" => Some(Allowance::YearlyTurnover),
137            _ => None,
138        }
139    }
140}