1use crate::tax::TaxSystem;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Profile {
6 En16931,
8 PeppolBis3,
10 Pint,
12 PintMy,
14}
15
16impl Profile {
17 pub fn slug(self) -> &'static str {
18 match self {
19 Self::En16931 => "en16931",
20 Self::PeppolBis3 => "peppol",
21 Self::Pint => "pint",
22 Self::PintMy => "pint-my",
23 }
24 }
25
26 pub fn parse(s: &str) -> Option<Self> {
27 match s.trim().to_ascii_lowercase().as_str() {
28 "en16931" | "en-16931" | "core" => Some(Self::En16931),
29 "peppol" | "bis3" | "peppol-bis-3" => Some(Self::PeppolBis3),
30 "pint" => Some(Self::Pint),
31 "pint-my" | "pintmy" | "my" => Some(Self::PintMy),
32 _ => None,
33 }
34 }
35
36 pub fn specification_id(self) -> &'static str {
37 match self {
38 Self::En16931 => "urn:cen.eu:en16931:2017",
39 Self::PeppolBis3 => {
40 "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0"
41 }
42 Self::Pint => "urn:peppol:pint:billing-1",
43 Self::PintMy => "urn:peppol:pint:billing-1@my-1",
44 }
45 }
46
47 pub fn tax_systems(self) -> &'static [TaxSystem] {
49 match self {
50 Self::En16931 | Self::PeppolBis3 => &[TaxSystem::Vat],
51 Self::Pint | Self::PintMy => &[
52 TaxSystem::Vat,
53 TaxSystem::Gst,
54 TaxSystem::Sst,
55 TaxSystem::Consumption,
56 ],
57 }
58 }
59
60 pub fn allows(self, system: TaxSystem) -> bool {
61 self.tax_systems().contains(&system)
62 }
63}