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 crate::Code for Allowance {
48    fn code(self) -> &'static str {
49        match self {
50            Allowance::BonusForWorksAheadSchedule => "41",
51            Allowance::OtherBonus => "42",
52            Allowance::ManufacturerSConsumerDiscount => "60",
53            Allowance::DueToMilitaryStatus => "62",
54            Allowance::DueToWorkAccident => "63",
55            Allowance::SpecialAgreement => "64",
56            Allowance::ProductionErrorDiscount => "65",
57            Allowance::NewOutletDiscount => "66",
58            Allowance::SampleDiscount => "67",
59            Allowance::EndRangeDiscount => "68",
60            Allowance::IncotermDiscount => "70",
61            Allowance::PointSalesThresholdAllowance => "71",
62            Allowance::MaterialSurchargeDeduction => "88",
63            Allowance::Discount => "95",
64            Allowance::SpecialRebate => "100",
65            Allowance::FixedLongTerm => "102",
66            Allowance::Temporary => "103",
67            Allowance::Standard => "104",
68            Allowance::YearlyTurnover => "105",
69        }
70    }
71}
72
73impl crate::Description for Allowance {
74    fn description(self) -> &'static str {
75        match self {
76            Allowance::BonusForWorksAheadSchedule => "Bonus for works ahead of schedule",
77            Allowance::OtherBonus => "Other bonus",
78            Allowance::ManufacturerSConsumerDiscount => "Manufacturer’s consumer discount",
79            Allowance::DueToMilitaryStatus => "Due to military status",
80            Allowance::DueToWorkAccident => "Due to work accident",
81            Allowance::SpecialAgreement => "Special agreement",
82            Allowance::ProductionErrorDiscount => "Production error discount",
83            Allowance::NewOutletDiscount => "New outlet discount",
84            Allowance::SampleDiscount => "Sample discount",
85            Allowance::EndRangeDiscount => "End-of-range discount",
86            Allowance::IncotermDiscount => "Incoterm discount",
87            Allowance::PointSalesThresholdAllowance => "Point of sales threshold allowance",
88            Allowance::MaterialSurchargeDeduction => "Material surcharge/deduction",
89            Allowance::Discount => "Discount",
90            Allowance::SpecialRebate => "Special rebate",
91            Allowance::FixedLongTerm => "Fixed long term",
92            Allowance::Temporary => "Temporary",
93            Allowance::Standard => "Standard",
94            Allowance::YearlyTurnover => "Yearly turnover",
95        }
96    }
97}
98
99impl crate::FromCode for Allowance {
100    fn from_code(code: &str) -> Option<Self>
101    where
102        Self: Sized,
103    {
104        match code {
105            "41" => Some(Allowance::BonusForWorksAheadSchedule),
106            "42" => Some(Allowance::OtherBonus),
107            "60" => Some(Allowance::ManufacturerSConsumerDiscount),
108            "62" => Some(Allowance::DueToMilitaryStatus),
109            "63" => Some(Allowance::DueToWorkAccident),
110            "64" => Some(Allowance::SpecialAgreement),
111            "65" => Some(Allowance::ProductionErrorDiscount),
112            "66" => Some(Allowance::NewOutletDiscount),
113            "67" => Some(Allowance::SampleDiscount),
114            "68" => Some(Allowance::EndRangeDiscount),
115            "70" => Some(Allowance::IncotermDiscount),
116            "71" => Some(Allowance::PointSalesThresholdAllowance),
117            "88" => Some(Allowance::MaterialSurchargeDeduction),
118            "95" => Some(Allowance::Discount),
119            "100" => Some(Allowance::SpecialRebate),
120            "102" => Some(Allowance::FixedLongTerm),
121            "103" => Some(Allowance::Temporary),
122            "104" => Some(Allowance::Standard),
123            "105" => Some(Allowance::YearlyTurnover),
124            _ => None,
125        }
126    }
127}