stripe/resources/generated/
invoiceitem.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use serde::{Deserialize, Serialize};
6
7use crate::client::{Client, Response};
8use crate::ids::{CustomerId, InvoiceId, InvoiceItemId, PriceId, SubscriptionId};
9use crate::params::{
10    Deleted, Expand, Expandable, List, Metadata, Object, Paginable, RangeQuery, Timestamp,
11};
12use crate::resources::{
13    Currency, Customer, Discount, Invoice, Period, Plan, Price, Subscription, TaxRate,
14    TestHelpersTestClock,
15};
16
17/// The resource representing a Stripe "InvoiceItem".
18///
19/// For more details see <https://stripe.com/docs/api/invoiceitems/object>
20#[derive(Clone, Debug, Default, Deserialize, Serialize)]
21pub struct InvoiceItem {
22    /// Unique identifier for the object.
23    pub id: InvoiceItemId,
24
25    /// Amount (in the `currency` specified) of the invoice item.
26    ///
27    /// This should always be equal to `unit_amount * quantity`.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub amount: Option<i64>,
30
31    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
32    ///
33    /// Must be a [supported currency](https://stripe.com/docs/currencies).
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub currency: Option<Currency>,
36
37    /// The ID of the customer who will be billed when this invoice item is billed.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub customer: Option<Expandable<Customer>>,
40
41    /// Time at which the object was created.
42    ///
43    /// Measured in seconds since the Unix epoch.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub date: Option<Timestamp>,
46
47    // Always true for a deleted object
48    #[serde(default)]
49    pub deleted: bool,
50
51    /// An arbitrary string attached to the object.
52    ///
53    /// Often useful for displaying to users.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub description: Option<String>,
56
57    /// If true, discounts will apply to this invoice item.
58    ///
59    /// Always false for prorations.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub discountable: Option<bool>,
62
63    /// The discounts which apply to the invoice item.
64    ///
65    /// Item discounts are applied before invoice discounts.
66    /// Use `expand[]=discounts` to expand each discount.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub discounts: Option<Vec<Expandable<Discount>>>,
69
70    /// The ID of the invoice this invoice item belongs to.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub invoice: Option<Expandable<Invoice>>,
73
74    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub livemode: Option<bool>,
77
78    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
79    ///
80    /// This can be useful for storing additional information about the object in a structured format.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub metadata: Option<Metadata>,
83
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub period: Option<Period>,
86
87    /// If the invoice item is a proration, the plan of the subscription that the proration was computed for.
88    #[serde(skip_serializing_if = "Option::is_none")]
89    pub plan: Option<Plan>,
90
91    /// The price of the invoice item.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub price: Option<Price>,
94
95    /// Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub proration: Option<bool>,
98
99    /// Quantity of units for the invoice item.
100    ///
101    /// If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub quantity: Option<u64>,
104
105    /// The subscription that this invoice item has been created for, if any.
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub subscription: Option<Expandable<Subscription>>,
108
109    /// The subscription item that this invoice item has been created for, if any.
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub subscription_item: Option<String>,
112
113    /// The tax rates which apply to the invoice item.
114    ///
115    /// When set, the `default_tax_rates` on the invoice do not apply to this invoice item.
116    #[serde(skip_serializing_if = "Option::is_none")]
117    pub tax_rates: Option<Vec<TaxRate>>,
118
119    /// ID of the test clock this invoice item belongs to.
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub test_clock: Option<Expandable<TestHelpersTestClock>>,
122
123    /// Unit amount (in the `currency` specified) of the invoice item.
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub unit_amount: Option<i64>,
126
127    /// Same as `unit_amount`, but contains a decimal value with at most 12 decimal places.
128    #[serde(skip_serializing_if = "Option::is_none")]
129    pub unit_amount_decimal: Option<String>,
130}
131
132impl InvoiceItem {
133    /// Returns a list of your invoice items.
134    ///
135    /// Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
136    pub fn list(client: &Client, params: &ListInvoiceItems<'_>) -> Response<List<InvoiceItem>> {
137        client.get_query("/invoiceitems", &params)
138    }
139
140    /// Creates an item to be added to a draft invoice (up to 250 items per invoice).
141    ///
142    /// If no invoice is specified, the item will be on the next invoice created for the customer specified.
143    pub fn create(client: &Client, params: CreateInvoiceItem<'_>) -> Response<InvoiceItem> {
144        client.post_form("/invoiceitems", &params)
145    }
146
147    /// Retrieves the invoice item with the given ID.
148    pub fn retrieve(client: &Client, id: &InvoiceItemId, expand: &[&str]) -> Response<InvoiceItem> {
149        client.get_query(&format!("/invoiceitems/{}", id), &Expand { expand })
150    }
151
152    /// Updates the amount or description of an invoice item on an upcoming invoice.
153    ///
154    /// Updating an invoice item is only possible before the invoice it’s attached to is closed.
155    pub fn update(
156        client: &Client,
157        id: &InvoiceItemId,
158        params: UpdateInvoiceItem<'_>,
159    ) -> Response<InvoiceItem> {
160        client.post_form(&format!("/invoiceitems/{}", id), &params)
161    }
162
163    /// Deletes an invoice item, removing it from an invoice.
164    ///
165    /// Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.
166    pub fn delete(client: &Client, id: &InvoiceItemId) -> Response<Deleted<InvoiceItemId>> {
167        client.delete(&format!("/invoiceitems/{}", id))
168    }
169}
170
171impl Object for InvoiceItem {
172    type Id = InvoiceItemId;
173    fn id(&self) -> Self::Id {
174        self.id.clone()
175    }
176    fn object(&self) -> &'static str {
177        "invoiceitem"
178    }
179}
180
181/// The parameters for `InvoiceItem::create`.
182#[derive(Clone, Debug, Serialize)]
183pub struct CreateInvoiceItem<'a> {
184    /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice.
185    ///
186    /// Passing in a negative `amount` will reduce the `amount_due` on the invoice.
187    #[serde(skip_serializing_if = "Option::is_none")]
188    pub amount: Option<i64>,
189
190    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
191    ///
192    /// Must be a [supported currency](https://stripe.com/docs/currencies).
193    #[serde(skip_serializing_if = "Option::is_none")]
194    pub currency: Option<Currency>,
195
196    /// The ID of the customer who will be billed when this invoice item is billed.
197    pub customer: CustomerId,
198
199    /// An arbitrary string which you can attach to the invoice item.
200    ///
201    /// The description is displayed in the invoice for easy tracking.
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub description: Option<&'a str>,
204
205    /// Controls whether discounts apply to this invoice item.
206    ///
207    /// Defaults to false for prorations or negative invoice items, and true for all other invoice items.
208    #[serde(skip_serializing_if = "Option::is_none")]
209    pub discountable: Option<bool>,
210
211    /// The coupons to redeem into discounts for the invoice item or invoice line item.
212    #[serde(skip_serializing_if = "Option::is_none")]
213    pub discounts: Option<Vec<CreateInvoiceItemDiscounts>>,
214
215    /// Specifies which fields in the response should be expanded.
216    #[serde(skip_serializing_if = "Expand::is_empty")]
217    pub expand: &'a [&'a str],
218
219    /// The ID of an existing invoice to add this invoice item to.
220    ///
221    /// When left blank, the invoice item will be added to the next upcoming scheduled invoice.
222    /// This is useful when adding invoice items in response to an invoice.created webhook.
223    /// You can only add invoice items to draft invoices and there is a maximum of 250 items per invoice.
224    #[serde(skip_serializing_if = "Option::is_none")]
225    pub invoice: Option<InvoiceId>,
226
227    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
228    ///
229    /// This can be useful for storing additional information about the object in a structured format.
230    /// Individual keys can be unset by posting an empty value to them.
231    /// All keys can be unset by posting an empty value to `metadata`.
232    #[serde(skip_serializing_if = "Option::is_none")]
233    pub metadata: Option<Metadata>,
234
235    /// The period associated with this invoice item.
236    ///
237    /// When set to different values, the period will be rendered on the invoice.
238    /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue.
239    /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details.
240    #[serde(skip_serializing_if = "Option::is_none")]
241    pub period: Option<Period>,
242
243    /// The ID of the price object.
244    #[serde(skip_serializing_if = "Option::is_none")]
245    pub price: Option<PriceId>,
246
247    /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
248    #[serde(skip_serializing_if = "Option::is_none")]
249    pub price_data: Option<InvoiceItemPriceData>,
250
251    /// Non-negative integer.
252    ///
253    /// The quantity of units for the invoice item.
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub quantity: Option<u64>,
256
257    /// The ID of a subscription to add this invoice item to.
258    ///
259    /// When left blank, the invoice item will be be added to the next upcoming scheduled invoice.
260    /// When set, scheduled invoices for subscriptions other than the specified subscription will ignore the invoice item.
261    /// Use this when you want to express that an invoice item has been accrued within the context of a particular subscription.
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub subscription: Option<SubscriptionId>,
264
265    /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings.
266    ///
267    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
268    /// One of `inclusive`, `exclusive`, or `unspecified`.
269    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
270    #[serde(skip_serializing_if = "Option::is_none")]
271    pub tax_behavior: Option<InvoiceItemTaxBehavior>,
272
273    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
274    #[serde(skip_serializing_if = "Option::is_none")]
275    pub tax_code: Option<String>,
276
277    /// The tax rates which apply to the invoice item.
278    ///
279    /// When set, the `default_tax_rates` on the invoice do not apply to this invoice item.
280    #[serde(skip_serializing_if = "Option::is_none")]
281    pub tax_rates: Option<Vec<String>>,
282
283    /// The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice.
284    ///
285    /// This `unit_amount` will be multiplied by the quantity to get the full amount.
286    /// Passing in a negative `unit_amount` will reduce the `amount_due` on the invoice.
287    #[serde(skip_serializing_if = "Option::is_none")]
288    pub unit_amount: Option<i64>,
289
290    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
291    ///
292    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
293    #[serde(skip_serializing_if = "Option::is_none")]
294    pub unit_amount_decimal: Option<&'a str>,
295}
296
297impl<'a> CreateInvoiceItem<'a> {
298    pub fn new(customer: CustomerId) -> Self {
299        CreateInvoiceItem {
300            amount: Default::default(),
301            currency: Default::default(),
302            customer,
303            description: Default::default(),
304            discountable: Default::default(),
305            discounts: Default::default(),
306            expand: Default::default(),
307            invoice: Default::default(),
308            metadata: Default::default(),
309            period: Default::default(),
310            price: Default::default(),
311            price_data: Default::default(),
312            quantity: Default::default(),
313            subscription: Default::default(),
314            tax_behavior: Default::default(),
315            tax_code: Default::default(),
316            tax_rates: Default::default(),
317            unit_amount: Default::default(),
318            unit_amount_decimal: Default::default(),
319        }
320    }
321}
322
323/// The parameters for `InvoiceItem::list`.
324#[derive(Clone, Debug, Serialize, Default)]
325pub struct ListInvoiceItems<'a> {
326    #[serde(skip_serializing_if = "Option::is_none")]
327    pub created: Option<RangeQuery<Timestamp>>,
328
329    /// The identifier of the customer whose invoice items to return.
330    ///
331    /// If none is provided, all invoice items will be returned.
332    #[serde(skip_serializing_if = "Option::is_none")]
333    pub customer: Option<CustomerId>,
334
335    /// A cursor for use in pagination.
336    ///
337    /// `ending_before` is an object ID that defines your place in the list.
338    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
339    #[serde(skip_serializing_if = "Option::is_none")]
340    pub ending_before: Option<InvoiceItemId>,
341
342    /// Specifies which fields in the response should be expanded.
343    #[serde(skip_serializing_if = "Expand::is_empty")]
344    pub expand: &'a [&'a str],
345
346    /// Only return invoice items belonging to this invoice.
347    ///
348    /// If none is provided, all invoice items will be returned.
349    /// If specifying an invoice, no customer identifier is needed.
350    #[serde(skip_serializing_if = "Option::is_none")]
351    pub invoice: Option<InvoiceId>,
352
353    /// A limit on the number of objects to be returned.
354    ///
355    /// Limit can range between 1 and 100, and the default is 10.
356    #[serde(skip_serializing_if = "Option::is_none")]
357    pub limit: Option<u64>,
358
359    /// Set to `true` to only show pending invoice items, which are not yet attached to any invoices.
360    ///
361    /// Set to `false` to only show invoice items already attached to invoices.
362    /// If unspecified, no filter is applied.
363    #[serde(skip_serializing_if = "Option::is_none")]
364    pub pending: Option<bool>,
365
366    /// A cursor for use in pagination.
367    ///
368    /// `starting_after` is an object ID that defines your place in the list.
369    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
370    #[serde(skip_serializing_if = "Option::is_none")]
371    pub starting_after: Option<InvoiceItemId>,
372}
373
374impl<'a> ListInvoiceItems<'a> {
375    pub fn new() -> Self {
376        ListInvoiceItems {
377            created: Default::default(),
378            customer: Default::default(),
379            ending_before: Default::default(),
380            expand: Default::default(),
381            invoice: Default::default(),
382            limit: Default::default(),
383            pending: Default::default(),
384            starting_after: Default::default(),
385        }
386    }
387}
388impl Paginable for ListInvoiceItems<'_> {
389    type O = InvoiceItem;
390    fn set_last(&mut self, item: Self::O) {
391        self.starting_after = Some(item.id());
392    }
393}
394/// The parameters for `InvoiceItem::update`.
395#[derive(Clone, Debug, Serialize, Default)]
396pub struct UpdateInvoiceItem<'a> {
397    /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice.
398    ///
399    /// If you want to apply a credit to the customer's account, pass a negative amount.
400    #[serde(skip_serializing_if = "Option::is_none")]
401    pub amount: Option<i64>,
402
403    /// An arbitrary string which you can attach to the invoice item.
404    ///
405    /// The description is displayed in the invoice for easy tracking.
406    #[serde(skip_serializing_if = "Option::is_none")]
407    pub description: Option<&'a str>,
408
409    /// Controls whether discounts apply to this invoice item.
410    ///
411    /// Defaults to false for prorations or negative invoice items, and true for all other invoice items.
412    /// Cannot be set to true for prorations.
413    #[serde(skip_serializing_if = "Option::is_none")]
414    pub discountable: Option<bool>,
415
416    /// The coupons & existing discounts which apply to the invoice item or invoice line item.
417    ///
418    /// Item discounts are applied before invoice discounts.
419    /// Pass an empty string to remove previously-defined discounts.
420    #[serde(skip_serializing_if = "Option::is_none")]
421    pub discounts: Option<Vec<UpdateInvoiceItemDiscounts>>,
422
423    /// Specifies which fields in the response should be expanded.
424    #[serde(skip_serializing_if = "Expand::is_empty")]
425    pub expand: &'a [&'a str],
426
427    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
428    ///
429    /// This can be useful for storing additional information about the object in a structured format.
430    /// Individual keys can be unset by posting an empty value to them.
431    /// All keys can be unset by posting an empty value to `metadata`.
432    #[serde(skip_serializing_if = "Option::is_none")]
433    pub metadata: Option<Metadata>,
434
435    /// The period associated with this invoice item.
436    ///
437    /// When set to different values, the period will be rendered on the invoice.
438    /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue.
439    /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details.
440    #[serde(skip_serializing_if = "Option::is_none")]
441    pub period: Option<Period>,
442
443    /// The ID of the price object.
444    #[serde(skip_serializing_if = "Option::is_none")]
445    pub price: Option<PriceId>,
446
447    /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
448    #[serde(skip_serializing_if = "Option::is_none")]
449    pub price_data: Option<InvoiceItemPriceData>,
450
451    /// Non-negative integer.
452    ///
453    /// The quantity of units for the invoice item.
454    #[serde(skip_serializing_if = "Option::is_none")]
455    pub quantity: Option<u64>,
456
457    /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings.
458    ///
459    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
460    /// One of `inclusive`, `exclusive`, or `unspecified`.
461    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
462    #[serde(skip_serializing_if = "Option::is_none")]
463    pub tax_behavior: Option<InvoiceItemTaxBehavior>,
464
465    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
466    #[serde(skip_serializing_if = "Option::is_none")]
467    pub tax_code: Option<String>,
468
469    /// The tax rates which apply to the invoice item.
470    ///
471    /// When set, the `default_tax_rates` on the invoice do not apply to this invoice item.
472    /// Pass an empty string to remove previously-defined tax rates.
473    #[serde(skip_serializing_if = "Option::is_none")]
474    pub tax_rates: Option<Vec<String>>,
475
476    /// The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice.
477    ///
478    /// This unit_amount will be multiplied by the quantity to get the full amount.
479    /// If you want to apply a credit to the customer's account, pass a negative unit_amount.
480    #[serde(skip_serializing_if = "Option::is_none")]
481    pub unit_amount: Option<i64>,
482
483    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
484    ///
485    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
486    #[serde(skip_serializing_if = "Option::is_none")]
487    pub unit_amount_decimal: Option<&'a str>,
488}
489
490impl<'a> UpdateInvoiceItem<'a> {
491    pub fn new() -> Self {
492        UpdateInvoiceItem {
493            amount: Default::default(),
494            description: Default::default(),
495            discountable: Default::default(),
496            discounts: Default::default(),
497            expand: Default::default(),
498            metadata: Default::default(),
499            period: Default::default(),
500            price: Default::default(),
501            price_data: Default::default(),
502            quantity: Default::default(),
503            tax_behavior: Default::default(),
504            tax_code: Default::default(),
505            tax_rates: Default::default(),
506            unit_amount: Default::default(),
507            unit_amount_decimal: Default::default(),
508        }
509    }
510}
511
512#[derive(Clone, Debug, Default, Deserialize, Serialize)]
513pub struct CreateInvoiceItemDiscounts {
514    /// ID of the coupon to create a new discount for.
515    #[serde(skip_serializing_if = "Option::is_none")]
516    pub coupon: Option<String>,
517
518    /// ID of an existing discount on the object (or one of its ancestors) to reuse.
519    #[serde(skip_serializing_if = "Option::is_none")]
520    pub discount: Option<String>,
521}
522
523#[derive(Clone, Debug, Default, Deserialize, Serialize)]
524pub struct InvoiceItemPriceData {
525    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
526    ///
527    /// Must be a [supported currency](https://stripe.com/docs/currencies).
528    pub currency: Currency,
529
530    /// The ID of the product that this price will belong to.
531    pub product: String,
532
533    /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings.
534    ///
535    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
536    /// One of `inclusive`, `exclusive`, or `unspecified`.
537    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
538    #[serde(skip_serializing_if = "Option::is_none")]
539    pub tax_behavior: Option<InvoiceItemPriceDataTaxBehavior>,
540
541    /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
542    #[serde(skip_serializing_if = "Option::is_none")]
543    pub unit_amount: Option<i64>,
544
545    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
546    ///
547    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
548    #[serde(skip_serializing_if = "Option::is_none")]
549    pub unit_amount_decimal: Option<String>,
550}
551
552#[derive(Clone, Debug, Default, Deserialize, Serialize)]
553pub struct UpdateInvoiceItemDiscounts {
554    /// ID of the coupon to create a new discount for.
555    #[serde(skip_serializing_if = "Option::is_none")]
556    pub coupon: Option<String>,
557
558    /// ID of an existing discount on the object (or one of its ancestors) to reuse.
559    #[serde(skip_serializing_if = "Option::is_none")]
560    pub discount: Option<String>,
561}
562
563/// An enum representing the possible values of an `InvoiceItemPriceData`'s `tax_behavior` field.
564#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
565#[serde(rename_all = "snake_case")]
566pub enum InvoiceItemPriceDataTaxBehavior {
567    Exclusive,
568    Inclusive,
569    Unspecified,
570}
571
572impl InvoiceItemPriceDataTaxBehavior {
573    pub fn as_str(self) -> &'static str {
574        match self {
575            InvoiceItemPriceDataTaxBehavior::Exclusive => "exclusive",
576            InvoiceItemPriceDataTaxBehavior::Inclusive => "inclusive",
577            InvoiceItemPriceDataTaxBehavior::Unspecified => "unspecified",
578        }
579    }
580}
581
582impl AsRef<str> for InvoiceItemPriceDataTaxBehavior {
583    fn as_ref(&self) -> &str {
584        self.as_str()
585    }
586}
587
588impl std::fmt::Display for InvoiceItemPriceDataTaxBehavior {
589    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
590        self.as_str().fmt(f)
591    }
592}
593impl std::default::Default for InvoiceItemPriceDataTaxBehavior {
594    fn default() -> Self {
595        Self::Exclusive
596    }
597}
598
599/// An enum representing the possible values of an `CreateInvoiceItem`'s `tax_behavior` field.
600#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
601#[serde(rename_all = "snake_case")]
602pub enum InvoiceItemTaxBehavior {
603    Exclusive,
604    Inclusive,
605    Unspecified,
606}
607
608impl InvoiceItemTaxBehavior {
609    pub fn as_str(self) -> &'static str {
610        match self {
611            InvoiceItemTaxBehavior::Exclusive => "exclusive",
612            InvoiceItemTaxBehavior::Inclusive => "inclusive",
613            InvoiceItemTaxBehavior::Unspecified => "unspecified",
614        }
615    }
616}
617
618impl AsRef<str> for InvoiceItemTaxBehavior {
619    fn as_ref(&self) -> &str {
620        self.as_str()
621    }
622}
623
624impl std::fmt::Display for InvoiceItemTaxBehavior {
625    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
626        self.as_str().fmt(f)
627    }
628}
629impl std::default::Default for InvoiceItemTaxBehavior {
630    fn default() -> Self {
631        Self::Exclusive
632    }
633}