zugferd_code_lists/zugferd_2_3_2/
incoterms.rs1#![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 INCOTERMS {
7 DeliveryArrangedBySupplier,
9 DeliveryArrangedByLogisticServiceProvider,
11 CostAndFreight,
13 CostInsuranceAndFreight,
15 CarriageAndInsurancePaidToInsertNamedPlaceDestination,
17 CarriagePaidToInsertNamedPlaceDestination,
19 DeliveredAtPlaceInsertNamedPlaceDestination,
21 DeliveredDutyPaidInsertNamedPlaceDestination,
23 DeliveredAtPlaceUnloadedInsertNamedPlaceUnloading,
25 ExWorksInsertNamedPlaceDelivery,
27 FreeAlongsideShipInsertNamedPortShipment,
29 FreeCarrierInsertNamedPlaceDelivery,
31 FreeOnBoardInsertNamedPortShipment,
33}
34
35impl std::fmt::Display for INCOTERMS {
36 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 write!(f, "{}", <Self as crate::Code>::code(*self))
38 }
39}
40
41impl std::str::FromStr for INCOTERMS {
42 type Err = crate::ParseError<Self>;
43 fn from_str(s: &str) -> Result<Self, Self::Err> {
44 <Self as crate::FromCode>::from_code(s)
45 .ok_or_else(|| crate::ParseError::<Self>::new(s.to_owned()))
46 }
47}
48
49impl crate::Code for INCOTERMS {
50 fn code(self) -> &'static str {
51 match self {
52 INCOTERMS::DeliveryArrangedBySupplier => "1",
53 INCOTERMS::DeliveryArrangedByLogisticServiceProvider => "2",
54 INCOTERMS::CostAndFreight => "CFR",
55 INCOTERMS::CostInsuranceAndFreight => "CIF",
56 INCOTERMS::CarriageAndInsurancePaidToInsertNamedPlaceDestination => "CIP",
57 INCOTERMS::CarriagePaidToInsertNamedPlaceDestination => "CPT",
58 INCOTERMS::DeliveredAtPlaceInsertNamedPlaceDestination => "DAP",
59 INCOTERMS::DeliveredDutyPaidInsertNamedPlaceDestination => "DDP",
60 INCOTERMS::DeliveredAtPlaceUnloadedInsertNamedPlaceUnloading => "DPU",
61 INCOTERMS::ExWorksInsertNamedPlaceDelivery => "EXW",
62 INCOTERMS::FreeAlongsideShipInsertNamedPortShipment => "FAS",
63 INCOTERMS::FreeCarrierInsertNamedPlaceDelivery => "FCA",
64 INCOTERMS::FreeOnBoardInsertNamedPortShipment => "FOB",
65 }
66 }
67}
68
69impl crate::Description for INCOTERMS {
70 fn description(self) -> &'static str {
71 match self {
72 INCOTERMS::DeliveryArrangedBySupplier => "Delivery arranged by supplier",
73 INCOTERMS::DeliveryArrangedByLogisticServiceProvider => {
74 "Delivery arranged by logistic service provider"
75 }
76 INCOTERMS::CostAndFreight => "Cost and Freight",
77 INCOTERMS::CostInsuranceAndFreight => "Cost, Insurance and Freight",
78 INCOTERMS::CarriageAndInsurancePaidToInsertNamedPlaceDestination => {
79 "Carriage and Insurance Paid to (insert named place of destination)"
80 }
81 INCOTERMS::CarriagePaidToInsertNamedPlaceDestination => {
82 "Carriage Paid To (insert named place of destination)"
83 }
84 INCOTERMS::DeliveredAtPlaceInsertNamedPlaceDestination => {
85 "Delivered At Place (insert named place of destination)"
86 }
87 INCOTERMS::DeliveredDutyPaidInsertNamedPlaceDestination => {
88 "Delivered Duty Paid (insert named place of destination)"
89 }
90 INCOTERMS::DeliveredAtPlaceUnloadedInsertNamedPlaceUnloading => {
91 "Delivered At Place Unloaded (insert named place of unloading)"
92 }
93 INCOTERMS::ExWorksInsertNamedPlaceDelivery => {
94 "Ex Works (insert named place of delivery)"
95 }
96 INCOTERMS::FreeAlongsideShipInsertNamedPortShipment => {
97 "Free Alongside Ship (insert named port of shipment)"
98 }
99 INCOTERMS::FreeCarrierInsertNamedPlaceDelivery => {
100 "Free Carrier (insert named place of delivery)"
101 }
102 INCOTERMS::FreeOnBoardInsertNamedPortShipment => {
103 " Free On Board (insert named port of shipment)"
104 }
105 }
106 }
107}
108
109impl crate::FromCode for INCOTERMS {
110 fn from_code(code: &str) -> Option<Self>
111 where
112 Self: Sized,
113 {
114 match code {
115 "1" => Some(INCOTERMS::DeliveryArrangedBySupplier),
116 "2" => Some(INCOTERMS::DeliveryArrangedByLogisticServiceProvider),
117 "CFR" => Some(INCOTERMS::CostAndFreight),
118 "CIF" => Some(INCOTERMS::CostInsuranceAndFreight),
119 "CIP" => Some(INCOTERMS::CarriageAndInsurancePaidToInsertNamedPlaceDestination),
120 "CPT" => Some(INCOTERMS::CarriagePaidToInsertNamedPlaceDestination),
121 "DAP" => Some(INCOTERMS::DeliveredAtPlaceInsertNamedPlaceDestination),
122 "DDP" => Some(INCOTERMS::DeliveredDutyPaidInsertNamedPlaceDestination),
123 "DPU" => Some(INCOTERMS::DeliveredAtPlaceUnloadedInsertNamedPlaceUnloading),
124 "EXW" => Some(INCOTERMS::ExWorksInsertNamedPlaceDelivery),
125 "FAS" => Some(INCOTERMS::FreeAlongsideShipInsertNamedPortShipment),
126 "FCA" => Some(INCOTERMS::FreeCarrierInsertNamedPlaceDelivery),
127 "FOB" => Some(INCOTERMS::FreeOnBoardInsertNamedPortShipment),
128 _ => None,
129 }
130 }
131}