stripe/model/tax_calculation.rs
1use serde::{Serialize, Deserialize};
2use super::{
3 TaxProductResourceCustomerDetails, TaxProductResourceTaxBreakdown,
4 TaxProductResourceTaxCalculationLineItemList,
5};
6/**A Tax Calculation allows you to calculate the tax to collect from your customer.
7
8Related guide: [Calculate tax in your custom payment flow](https://stripe.com/docs/tax/custom)*/
9#[derive(Debug, Clone, Serialize, Deserialize, Default)]
10pub struct TaxCalculation {
11 ///Total after taxes.
12 pub amount_total: i64,
13 ///Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
14 pub currency: String,
15 ///The ID of an existing [Customer](https://stripe.com/docs/api/customers/object) used for the resource.
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub customer: Option<String>,
18 ///
19 pub customer_details: TaxProductResourceCustomerDetails,
20 ///Timestamp of date at which the tax calculation will expire.
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub expires_at: Option<i64>,
23 ///Unique identifier for the calculation.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub id: Option<String>,
26 ///The list of items the customer is purchasing.
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub line_items: Option<TaxProductResourceTaxCalculationLineItemList>,
29 ///Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
30 pub livemode: bool,
31 ///String representing the object's type. Objects of the same type share the same value.
32 pub object: String,
33 ///The shipping cost details for the calculation.
34 #[serde(skip_serializing_if = "Option::is_none")]
35 pub shipping_cost: Option<serde_json::Value>,
36 ///The amount of tax to be collected on top of the line item prices.
37 pub tax_amount_exclusive: i64,
38 ///The amount of tax already included in the line item prices.
39 pub tax_amount_inclusive: i64,
40 ///Breakdown of individual tax amounts that add up to the total.
41 pub tax_breakdown: Vec<TaxProductResourceTaxBreakdown>,
42 ///Timestamp of date at which the tax rules and rates in effect applies for the calculation.
43 pub tax_date: i64,
44}
45impl std::fmt::Display for TaxCalculation {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
47 write!(f, "{}", serde_json::to_string(self).unwrap())
48 }
49}