stripe/model/
invoiceitem.rs

1use serde::{Serialize, Deserialize};
2use super::{InvoiceLineItemPeriod, TaxRate};
3/**Invoice Items represent the component lines of an [invoice](https://stripe.com/docs/api/invoices). An invoice item is added to an
4invoice by creating or updating it with an `invoice` field, at which point it will be included as
5[an invoice line item](https://stripe.com/docs/api/invoices/line_item) within
6[invoice.lines](https://stripe.com/docs/api/invoices/object#invoice_object-lines).
7
8Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined
9with a [subscription](https://stripe.com/docs/api/subscriptions). Sometimes you want to add a charge or credit to a customer, but actually charge
10or credit the customer’s card only at the end of a regular billing cycle. This is useful for combining several charges
11(to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.
12
13Related guides: [Integrate with the Invoicing API](https://stripe.com/docs/invoicing/integration), [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items).*/
14#[derive(Debug, Clone, Serialize, Deserialize, Default)]
15pub struct Invoiceitem {
16    ///Amount (in the `currency` specified) of the invoice item. This should always be equal to `unit_amount * quantity`.
17    pub amount: i64,
18    ///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).
19    pub currency: String,
20    ///The ID of the customer who will be billed when this invoice item is billed.
21    pub customer: serde_json::Value,
22    ///Time at which the object was created. Measured in seconds since the Unix epoch.
23    pub date: i64,
24    ///An arbitrary string attached to the object. Often useful for displaying to users.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub description: Option<String>,
27    ///If true, discounts will apply to this invoice item. Always false for prorations.
28    pub discountable: bool,
29    ///The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub discounts: Option<Vec<serde_json::Value>>,
32    ///Unique identifier for the object.
33    pub id: String,
34    ///The ID of the invoice this invoice item belongs to.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub invoice: Option<serde_json::Value>,
37    ///Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
38    pub livemode: bool,
39    ///Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub metadata: Option<serde_json::Value>,
42    ///String representing the object's type. Objects of the same type share the same value.
43    pub object: String,
44    ///
45    pub period: InvoiceLineItemPeriod,
46    ///The price of the invoice item.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub price: Option<serde_json::Value>,
49    ///Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
50    pub proration: bool,
51    ///Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
52    pub quantity: i64,
53    ///The subscription that this invoice item has been created for, if any.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub subscription: Option<serde_json::Value>,
56    ///The subscription item that this invoice item has been created for, if any.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub subscription_item: Option<String>,
59    ///The tax rates which apply to the invoice item. When set, the `default_tax_rates` on the invoice do not apply to this invoice item.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub tax_rates: Option<Vec<TaxRate>>,
62    ///ID of the test clock this invoice item belongs to.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub test_clock: Option<serde_json::Value>,
65    ///Unit amount (in the `currency` specified) of the invoice item.
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub unit_amount: Option<i64>,
68    ///Same as `unit_amount`, but contains a decimal value with at most 12 decimal places.
69    #[serde(skip_serializing_if = "Option::is_none")]
70    #[serde(with = "rust_decimal::serde::str_option")]
71    pub unit_amount_decimal: Option<rust_decimal::Decimal>,
72}
73impl std::fmt::Display for Invoiceitem {
74    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
75        write!(f, "{}", serde_json::to_string(self).unwrap())
76    }
77}