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