stripe/resources/generated/
tax_calculation_line_item.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::ids::TaxCalculationLineItemId;
6use crate::params::Object;
7use serde::{Deserialize, Serialize};
8
9/// The resource representing a Stripe "TaxProductResourceTaxCalculationLineItem".
10#[derive(Clone, Debug, Default, Deserialize, Serialize)]
11pub struct TaxCalculationLineItem {
12    /// Unique identifier for the object.
13    pub id: TaxCalculationLineItemId,
14
15    /// The line item amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
16    ///
17    /// If `tax_behavior=inclusive`, then this amount includes taxes.
18    /// Otherwise, taxes were calculated on top of this amount.
19    pub amount: i64,
20
21    /// The amount of tax calculated for this line item, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
22    pub amount_tax: i64,
23
24    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
25    pub livemode: bool,
26
27    /// The ID of an existing [Product](https://stripe.com/docs/api/products/object).
28    pub product: Option<String>,
29
30    /// The number of units of the item being purchased.
31    ///
32    /// For reversals, this is the quantity reversed.
33    pub quantity: u64,
34
35    /// A custom identifier for this line item.
36    pub reference: Option<String>,
37
38    /// Specifies whether the `amount` includes taxes.
39    ///
40    /// If `tax_behavior=inclusive`, then the amount includes taxes.
41    pub tax_behavior: TaxCalculationLineItemTaxBehavior,
42
43    /// Detailed account of taxes relevant to this line item.
44    pub tax_breakdown: Option<Vec<TaxProductResourceLineItemTaxBreakdown>>,
45
46    /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for this resource.
47    pub tax_code: String,
48}
49
50impl Object for TaxCalculationLineItem {
51    type Id = TaxCalculationLineItemId;
52    fn id(&self) -> Self::Id {
53        self.id.clone()
54    }
55    fn object(&self) -> &'static str {
56        "tax.calculation_line_item"
57    }
58}
59
60#[derive(Clone, Debug, Default, Deserialize, Serialize)]
61pub struct TaxProductResourceLineItemTaxBreakdown {
62    /// The amount of tax, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
63    pub amount: i64,
64
65    pub jurisdiction: TaxProductResourceJurisdiction,
66
67    /// Indicates whether the jurisdiction was determined by the origin (merchant's address) or destination (customer's address).
68    pub sourcing: TaxProductResourceLineItemTaxBreakdownSourcing,
69
70    /// Details regarding the rate for this tax.
71    ///
72    /// This field will be `null` when the tax is not imposed, for example if the product is exempt from tax.
73    pub tax_rate_details: Option<TaxProductResourceLineItemTaxRateDetails>,
74
75    /// The reasoning behind this tax, for example, if the product is tax exempt.
76    ///
77    /// The possible values for this field may be extended as new tax rules are supported.
78    pub taxability_reason: TaxProductResourceLineItemTaxBreakdownTaxabilityReason,
79
80    /// The amount on which tax is calculated, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
81    pub taxable_amount: i64,
82}
83
84#[derive(Clone, Debug, Default, Deserialize, Serialize)]
85pub struct TaxProductResourceJurisdiction {
86    /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
87    pub country: String,
88
89    /// A human-readable name for the jurisdiction imposing the tax.
90    pub display_name: String,
91
92    /// Indicates the level of the jurisdiction imposing the tax.
93    pub level: TaxProductResourceJurisdictionLevel,
94
95    /// [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix.
96    ///
97    /// For example, "NY" for New York, United States.
98    pub state: Option<String>,
99}
100
101#[derive(Clone, Debug, Default, Deserialize, Serialize)]
102pub struct TaxProductResourceLineItemTaxRateDetails {
103    /// A localized display name for tax type, intended to be human-readable.
104    ///
105    /// For example, "Local Sales and Use Tax", "Value-added tax (VAT)", or "Umsatzsteuer (USt.)".
106    pub display_name: String,
107
108    /// The tax rate percentage as a string.
109    ///
110    /// For example, 8.5% is represented as "8.5".
111    pub percentage_decimal: String,
112
113    /// The tax type, such as `vat` or `sales_tax`.
114    pub tax_type: TaxProductResourceLineItemTaxRateDetailsTaxType,
115}
116
117/// An enum representing the possible values of an `TaxCalculationLineItem`'s `tax_behavior` field.
118#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
119#[serde(rename_all = "snake_case")]
120pub enum TaxCalculationLineItemTaxBehavior {
121    Exclusive,
122    Inclusive,
123}
124
125impl TaxCalculationLineItemTaxBehavior {
126    pub fn as_str(self) -> &'static str {
127        match self {
128            TaxCalculationLineItemTaxBehavior::Exclusive => "exclusive",
129            TaxCalculationLineItemTaxBehavior::Inclusive => "inclusive",
130        }
131    }
132}
133
134impl AsRef<str> for TaxCalculationLineItemTaxBehavior {
135    fn as_ref(&self) -> &str {
136        self.as_str()
137    }
138}
139
140impl std::fmt::Display for TaxCalculationLineItemTaxBehavior {
141    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
142        self.as_str().fmt(f)
143    }
144}
145impl std::default::Default for TaxCalculationLineItemTaxBehavior {
146    fn default() -> Self {
147        Self::Exclusive
148    }
149}
150
151/// An enum representing the possible values of an `TaxProductResourceJurisdiction`'s `level` field.
152#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
153#[serde(rename_all = "snake_case")]
154pub enum TaxProductResourceJurisdictionLevel {
155    City,
156    Country,
157    County,
158    District,
159    State,
160}
161
162impl TaxProductResourceJurisdictionLevel {
163    pub fn as_str(self) -> &'static str {
164        match self {
165            TaxProductResourceJurisdictionLevel::City => "city",
166            TaxProductResourceJurisdictionLevel::Country => "country",
167            TaxProductResourceJurisdictionLevel::County => "county",
168            TaxProductResourceJurisdictionLevel::District => "district",
169            TaxProductResourceJurisdictionLevel::State => "state",
170        }
171    }
172}
173
174impl AsRef<str> for TaxProductResourceJurisdictionLevel {
175    fn as_ref(&self) -> &str {
176        self.as_str()
177    }
178}
179
180impl std::fmt::Display for TaxProductResourceJurisdictionLevel {
181    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
182        self.as_str().fmt(f)
183    }
184}
185impl std::default::Default for TaxProductResourceJurisdictionLevel {
186    fn default() -> Self {
187        Self::City
188    }
189}
190
191/// An enum representing the possible values of an `TaxProductResourceLineItemTaxBreakdown`'s `sourcing` field.
192#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
193#[serde(rename_all = "snake_case")]
194pub enum TaxProductResourceLineItemTaxBreakdownSourcing {
195    Destination,
196    Origin,
197}
198
199impl TaxProductResourceLineItemTaxBreakdownSourcing {
200    pub fn as_str(self) -> &'static str {
201        match self {
202            TaxProductResourceLineItemTaxBreakdownSourcing::Destination => "destination",
203            TaxProductResourceLineItemTaxBreakdownSourcing::Origin => "origin",
204        }
205    }
206}
207
208impl AsRef<str> for TaxProductResourceLineItemTaxBreakdownSourcing {
209    fn as_ref(&self) -> &str {
210        self.as_str()
211    }
212}
213
214impl std::fmt::Display for TaxProductResourceLineItemTaxBreakdownSourcing {
215    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
216        self.as_str().fmt(f)
217    }
218}
219impl std::default::Default for TaxProductResourceLineItemTaxBreakdownSourcing {
220    fn default() -> Self {
221        Self::Destination
222    }
223}
224
225/// An enum representing the possible values of an `TaxProductResourceLineItemTaxBreakdown`'s `taxability_reason` field.
226#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
227#[serde(rename_all = "snake_case")]
228pub enum TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
229    CustomerExempt,
230    NotCollecting,
231    NotSubjectToTax,
232    NotSupported,
233    PortionProductExempt,
234    PortionReducedRated,
235    PortionStandardRated,
236    ProductExempt,
237    ProductExemptHoliday,
238    ProportionallyRated,
239    ReducedRated,
240    ReverseCharge,
241    StandardRated,
242    TaxableBasisReduced,
243    ZeroRated,
244}
245
246impl TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
247    pub fn as_str(self) -> &'static str {
248        match self {
249            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::CustomerExempt => {
250                "customer_exempt"
251            }
252            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::NotCollecting => {
253                "not_collecting"
254            }
255            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::NotSubjectToTax => {
256                "not_subject_to_tax"
257            }
258            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::NotSupported => "not_supported",
259            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::PortionProductExempt => {
260                "portion_product_exempt"
261            }
262            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::PortionReducedRated => {
263                "portion_reduced_rated"
264            }
265            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::PortionStandardRated => {
266                "portion_standard_rated"
267            }
268            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ProductExempt => {
269                "product_exempt"
270            }
271            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ProductExemptHoliday => {
272                "product_exempt_holiday"
273            }
274            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ProportionallyRated => {
275                "proportionally_rated"
276            }
277            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ReducedRated => "reduced_rated",
278            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ReverseCharge => {
279                "reverse_charge"
280            }
281            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::StandardRated => {
282                "standard_rated"
283            }
284            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::TaxableBasisReduced => {
285                "taxable_basis_reduced"
286            }
287            TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ZeroRated => "zero_rated",
288        }
289    }
290}
291
292impl AsRef<str> for TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
293    fn as_ref(&self) -> &str {
294        self.as_str()
295    }
296}
297
298impl std::fmt::Display for TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
299    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
300        self.as_str().fmt(f)
301    }
302}
303impl std::default::Default for TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
304    fn default() -> Self {
305        Self::CustomerExempt
306    }
307}
308
309/// An enum representing the possible values of an `TaxProductResourceLineItemTaxRateDetails`'s `tax_type` field.
310#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
311#[serde(rename_all = "snake_case")]
312pub enum TaxProductResourceLineItemTaxRateDetailsTaxType {
313    AmusementTax,
314    CommunicationsTax,
315    Gst,
316    Hst,
317    Igst,
318    Jct,
319    LeaseTax,
320    Pst,
321    Qst,
322    Rst,
323    SalesTax,
324    Vat,
325}
326
327impl TaxProductResourceLineItemTaxRateDetailsTaxType {
328    pub fn as_str(self) -> &'static str {
329        match self {
330            TaxProductResourceLineItemTaxRateDetailsTaxType::AmusementTax => "amusement_tax",
331            TaxProductResourceLineItemTaxRateDetailsTaxType::CommunicationsTax => {
332                "communications_tax"
333            }
334            TaxProductResourceLineItemTaxRateDetailsTaxType::Gst => "gst",
335            TaxProductResourceLineItemTaxRateDetailsTaxType::Hst => "hst",
336            TaxProductResourceLineItemTaxRateDetailsTaxType::Igst => "igst",
337            TaxProductResourceLineItemTaxRateDetailsTaxType::Jct => "jct",
338            TaxProductResourceLineItemTaxRateDetailsTaxType::LeaseTax => "lease_tax",
339            TaxProductResourceLineItemTaxRateDetailsTaxType::Pst => "pst",
340            TaxProductResourceLineItemTaxRateDetailsTaxType::Qst => "qst",
341            TaxProductResourceLineItemTaxRateDetailsTaxType::Rst => "rst",
342            TaxProductResourceLineItemTaxRateDetailsTaxType::SalesTax => "sales_tax",
343            TaxProductResourceLineItemTaxRateDetailsTaxType::Vat => "vat",
344        }
345    }
346}
347
348impl AsRef<str> for TaxProductResourceLineItemTaxRateDetailsTaxType {
349    fn as_ref(&self) -> &str {
350        self.as_str()
351    }
352}
353
354impl std::fmt::Display for TaxProductResourceLineItemTaxRateDetailsTaxType {
355    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
356        self.as_str().fmt(f)
357    }
358}
359impl std::default::Default for TaxProductResourceLineItemTaxRateDetailsTaxType {
360    fn default() -> Self {
361        Self::AmusementTax
362    }
363}