stripe/resources/generated/
credit_note.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::{CreditNoteId, CustomerId, InvoiceId, RefundId};
7use crate::params::{Expand, Expandable, List, Metadata, Object, Paginable, Timestamp};
8use crate::resources::{
9    CreditNoteLineItem, Currency, Customer, CustomerBalanceTransaction, Discount, Invoice,
10    InvoicesShippingCost, Refund, TaxRate,
11};
12use serde::{Deserialize, Serialize};
13
14/// The resource representing a Stripe "CreditNote".
15///
16/// For more details see <https://stripe.com/docs/api/credit_notes/object>
17#[derive(Clone, Debug, Default, Deserialize, Serialize)]
18pub struct CreditNote {
19    /// Unique identifier for the object.
20    pub id: CreditNoteId,
21
22    /// The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
23    pub amount: i64,
24
25    /// This is the sum of all the shipping amounts.
26    pub amount_shipping: i64,
27
28    /// Time at which the object was created.
29    ///
30    /// Measured in seconds since the Unix epoch.
31    pub created: Timestamp,
32
33    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
34    ///
35    /// Must be a [supported currency](https://stripe.com/docs/currencies).
36    pub currency: Currency,
37
38    /// ID of the customer.
39    pub customer: Expandable<Customer>,
40
41    /// Customer balance transaction related to this credit note.
42    pub customer_balance_transaction: Option<Expandable<CustomerBalanceTransaction>>,
43
44    /// The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
45    pub discount_amount: i64,
46
47    /// The aggregate amounts calculated per discount for all line items.
48    pub discount_amounts: Vec<DiscountsResourceDiscountAmount>,
49
50    /// The date when this credit note is in effect.
51    ///
52    /// Same as `created` unless overwritten.
53    /// When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
54    pub effective_at: Option<Timestamp>,
55
56    /// ID of the invoice.
57    pub invoice: Expandable<Invoice>,
58
59    /// Line items that make up the credit note.
60    pub lines: List<CreditNoteLineItem>,
61
62    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
63    pub livemode: bool,
64
65    /// Customer-facing text that appears on the credit note PDF.
66    pub memo: Option<String>,
67
68    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
69    ///
70    /// This can be useful for storing additional information about the object in a structured format.
71    pub metadata: Option<Metadata>,
72
73    /// A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
74    pub number: String,
75
76    /// Amount that was credited outside of Stripe.
77    pub out_of_band_amount: Option<i64>,
78
79    /// The link to download the PDF of the credit note.
80    pub pdf: String,
81
82    /// Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`.
83    pub reason: Option<CreditNoteReason>,
84
85    /// Refund related to this credit note.
86    pub refund: Option<Expandable<Refund>>,
87
88    /// The details of the cost of shipping, including the ShippingRate applied to the invoice.
89    pub shipping_cost: Option<InvoicesShippingCost>,
90
91    /// Status of this credit note, one of `issued` or `void`.
92    ///
93    /// Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
94    pub status: CreditNoteStatus,
95
96    /// The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
97    pub subtotal: i64,
98
99    /// The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
100    pub subtotal_excluding_tax: Option<i64>,
101
102    /// The aggregate amounts calculated per tax rate for all line items.
103    pub tax_amounts: Vec<CreditNoteTaxAmount>,
104
105    /// The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
106    pub total: i64,
107
108    /// The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
109    pub total_excluding_tax: Option<i64>,
110
111    /// Type of this credit note, one of `pre_payment` or `post_payment`.
112    ///
113    /// A `pre_payment` credit note means it was issued when the invoice was open.
114    /// A `post_payment` credit note means it was issued when the invoice was paid.
115    #[serde(rename = "type")]
116    pub type_: CreditNoteType,
117
118    /// The time that the credit note was voided.
119    pub voided_at: Option<Timestamp>,
120}
121
122impl CreditNote {
123    /// Returns a list of credit notes.
124    pub fn list(client: &Client, params: &ListCreditNotes<'_>) -> Response<List<CreditNote>> {
125        client.get_query("/credit_notes", params)
126    }
127
128    /// Issue a credit note to adjust the amount of a finalized invoice.
129    ///
130    /// For a `status=open` invoice, a credit note reduces its `amount_due`.
131    /// For a `status=paid` invoice, a credit note does not affect its `amount_due`.
132    /// Instead, it can result in any combination of the following:  <ul> <li>Refund: create a new refund (using `refund_amount`) or link an existing refund (using `refund`).</li> <li>Customer balance credit: credit the customer’s balance (using `credit_amount`) which will be automatically applied to their next invoice when it’s finalized.</li> <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using `out_of_band_amount`).</li> </ul>  For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.  You may issue multiple credit notes for an invoice.
133    /// Each credit note will increment the invoice’s `pre_payment_credit_notes_amount` or `post_payment_credit_notes_amount` depending on its `status` at the time of credit note creation.
134    pub fn create(client: &Client, params: CreateCreditNote<'_>) -> Response<CreditNote> {
135        #[allow(clippy::needless_borrows_for_generic_args)]
136        client.post_form("/credit_notes", &params)
137    }
138
139    /// Retrieves the credit note object with the given identifier.
140    pub fn retrieve(client: &Client, id: &CreditNoteId, expand: &[&str]) -> Response<CreditNote> {
141        client.get_query(&format!("/credit_notes/{}", id), Expand { expand })
142    }
143
144    /// Updates an existing credit note.
145    pub fn update(
146        client: &Client,
147        id: &CreditNoteId,
148        params: UpdateCreditNote<'_>,
149    ) -> Response<CreditNote> {
150        #[allow(clippy::needless_borrows_for_generic_args)]
151        client.post_form(&format!("/credit_notes/{}", id), &params)
152    }
153}
154
155impl Object for CreditNote {
156    type Id = CreditNoteId;
157    fn id(&self) -> Self::Id {
158        self.id.clone()
159    }
160    fn object(&self) -> &'static str {
161        "credit_note"
162    }
163}
164
165#[derive(Clone, Debug, Default, Deserialize, Serialize)]
166pub struct CreditNoteTaxAmount {
167    /// The amount, in cents (or local equivalent), of the tax.
168    pub amount: i64,
169
170    /// Whether this tax amount is inclusive or exclusive.
171    pub inclusive: bool,
172
173    /// The tax rate that was applied to get this tax amount.
174    pub tax_rate: Expandable<TaxRate>,
175
176    /// The reasoning behind this tax, for example, if the product is tax exempt.
177    ///
178    /// The possible values for this field may be extended as new tax rules are supported.
179    pub taxability_reason: Option<CreditNoteTaxAmountTaxabilityReason>,
180
181    /// The amount on which tax is calculated, in cents (or local equivalent).
182    pub taxable_amount: Option<i64>,
183}
184
185#[derive(Clone, Debug, Default, Deserialize, Serialize)]
186pub struct DiscountsResourceDiscountAmount {
187    /// The amount, in cents (or local equivalent), of the discount.
188    pub amount: i64,
189
190    /// The discount that was applied to get this discount amount.
191    pub discount: Expandable<Discount>,
192}
193
194/// The parameters for `CreditNote::create`.
195#[derive(Clone, Debug, Serialize)]
196pub struct CreateCreditNote<'a> {
197    /// The integer amount in cents (or local equivalent) representing the total amount of the credit note.
198    #[serde(skip_serializing_if = "Option::is_none")]
199    pub amount: Option<i64>,
200
201    /// The integer amount in cents (or local equivalent) representing the amount to credit the customer's balance, which will be automatically applied to their next invoice.
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub credit_amount: Option<i64>,
204
205    /// The date when this credit note is in effect.
206    ///
207    /// Same as `created` unless overwritten.
208    /// When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub effective_at: Option<Timestamp>,
211
212    /// Specifies which fields in the response should be expanded.
213    #[serde(skip_serializing_if = "Expand::is_empty")]
214    pub expand: &'a [&'a str],
215
216    /// ID of the invoice.
217    pub invoice: InvoiceId,
218
219    /// Line items that make up the credit note.
220    #[serde(skip_serializing_if = "Option::is_none")]
221    pub lines: Option<Vec<CreateCreditNoteLines>>,
222
223    /// The credit note's memo appears on the credit note PDF.
224    #[serde(skip_serializing_if = "Option::is_none")]
225    pub memo: Option<&'a str>,
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 integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
236    #[serde(skip_serializing_if = "Option::is_none")]
237    pub out_of_band_amount: Option<i64>,
238
239    /// Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`.
240    #[serde(skip_serializing_if = "Option::is_none")]
241    pub reason: Option<CreditNoteReason>,
242
243    /// ID of an existing refund to link this credit note to.
244    #[serde(skip_serializing_if = "Option::is_none")]
245    pub refund: Option<RefundId>,
246
247    /// The integer amount in cents (or local equivalent) representing the amount to refund.
248    ///
249    /// If set, a refund will be created for the charge associated with the invoice.
250    #[serde(skip_serializing_if = "Option::is_none")]
251    pub refund_amount: Option<i64>,
252
253    /// When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub shipping_cost: Option<CreateCreditNoteShippingCost>,
256}
257
258impl<'a> CreateCreditNote<'a> {
259    pub fn new(invoice: InvoiceId) -> Self {
260        CreateCreditNote {
261            amount: Default::default(),
262            credit_amount: Default::default(),
263            effective_at: Default::default(),
264            expand: Default::default(),
265            invoice,
266            lines: Default::default(),
267            memo: Default::default(),
268            metadata: Default::default(),
269            out_of_band_amount: Default::default(),
270            reason: Default::default(),
271            refund: Default::default(),
272            refund_amount: Default::default(),
273            shipping_cost: Default::default(),
274        }
275    }
276}
277
278/// The parameters for `CreditNote::list`.
279#[derive(Clone, Debug, Serialize, Default)]
280pub struct ListCreditNotes<'a> {
281    /// Only return credit notes for the customer specified by this customer ID.
282    #[serde(skip_serializing_if = "Option::is_none")]
283    pub customer: Option<CustomerId>,
284
285    /// A cursor for use in pagination.
286    ///
287    /// `ending_before` is an object ID that defines your place in the list.
288    /// 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.
289    #[serde(skip_serializing_if = "Option::is_none")]
290    pub ending_before: Option<CreditNoteId>,
291
292    /// Specifies which fields in the response should be expanded.
293    #[serde(skip_serializing_if = "Expand::is_empty")]
294    pub expand: &'a [&'a str],
295
296    /// Only return credit notes for the invoice specified by this invoice ID.
297    #[serde(skip_serializing_if = "Option::is_none")]
298    pub invoice: Option<InvoiceId>,
299
300    /// A limit on the number of objects to be returned.
301    ///
302    /// Limit can range between 1 and 100, and the default is 10.
303    #[serde(skip_serializing_if = "Option::is_none")]
304    pub limit: Option<u64>,
305
306    /// A cursor for use in pagination.
307    ///
308    /// `starting_after` is an object ID that defines your place in the list.
309    /// 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.
310    #[serde(skip_serializing_if = "Option::is_none")]
311    pub starting_after: Option<CreditNoteId>,
312}
313
314impl<'a> ListCreditNotes<'a> {
315    pub fn new() -> Self {
316        ListCreditNotes {
317            customer: Default::default(),
318            ending_before: Default::default(),
319            expand: Default::default(),
320            invoice: Default::default(),
321            limit: Default::default(),
322            starting_after: Default::default(),
323        }
324    }
325}
326impl Paginable for ListCreditNotes<'_> {
327    type O = CreditNote;
328    fn set_last(&mut self, item: Self::O) {
329        self.starting_after = Some(item.id());
330    }
331}
332/// The parameters for `CreditNote::update`.
333#[derive(Clone, Debug, Serialize, Default)]
334pub struct UpdateCreditNote<'a> {
335    /// Specifies which fields in the response should be expanded.
336    #[serde(skip_serializing_if = "Expand::is_empty")]
337    pub expand: &'a [&'a str],
338
339    /// Credit note memo.
340    #[serde(skip_serializing_if = "Option::is_none")]
341    pub memo: Option<&'a str>,
342
343    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
344    ///
345    /// This can be useful for storing additional information about the object in a structured format.
346    /// Individual keys can be unset by posting an empty value to them.
347    /// All keys can be unset by posting an empty value to `metadata`.
348    #[serde(skip_serializing_if = "Option::is_none")]
349    pub metadata: Option<Metadata>,
350}
351
352impl<'a> UpdateCreditNote<'a> {
353    pub fn new() -> Self {
354        UpdateCreditNote {
355            expand: Default::default(),
356            memo: Default::default(),
357            metadata: Default::default(),
358        }
359    }
360}
361
362#[derive(Clone, Debug, Default, Deserialize, Serialize)]
363pub struct CreateCreditNoteLines {
364    /// The line item amount to credit.
365    ///
366    /// Only valid when `type` is `invoice_line_item`.
367    #[serde(skip_serializing_if = "Option::is_none")]
368    pub amount: Option<i64>,
369
370    /// The description of the credit note line item.
371    ///
372    /// Only valid when the `type` is `custom_line_item`.
373    #[serde(skip_serializing_if = "Option::is_none")]
374    pub description: Option<String>,
375
376    /// The invoice line item to credit.
377    ///
378    /// Only valid when the `type` is `invoice_line_item`.
379    #[serde(skip_serializing_if = "Option::is_none")]
380    pub invoice_line_item: Option<String>,
381
382    /// The line item quantity to credit.
383    #[serde(skip_serializing_if = "Option::is_none")]
384    pub quantity: Option<u64>,
385
386    /// A list of up to 10 tax amounts for the credit note line item.
387    ///
388    /// Cannot be mixed with `tax_rates`.
389    #[serde(skip_serializing_if = "Option::is_none")]
390    pub tax_amounts: Option<Vec<CreateCreditNoteLinesTaxAmounts>>,
391
392    /// The tax rates which apply to the credit note line item.
393    ///
394    /// Only valid when the `type` is `custom_line_item` and cannot be mixed with `tax_amounts`.
395    #[serde(skip_serializing_if = "Option::is_none")]
396    pub tax_rates: Option<Vec<String>>,
397
398    /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`.
399    #[serde(rename = "type")]
400    pub type_: CreateCreditNoteLinesType,
401
402    /// The integer unit amount in cents (or local equivalent) of the credit note line item.
403    ///
404    /// This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item.
405    /// Only valid when `type` is `custom_line_item`.
406    #[serde(skip_serializing_if = "Option::is_none")]
407    pub unit_amount: Option<i64>,
408
409    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
410    ///
411    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
412    #[serde(skip_serializing_if = "Option::is_none")]
413    pub unit_amount_decimal: Option<String>,
414}
415
416#[derive(Clone, Debug, Default, Deserialize, Serialize)]
417pub struct CreateCreditNoteShippingCost {
418    /// The ID of the shipping rate to use for this order.
419    #[serde(skip_serializing_if = "Option::is_none")]
420    pub shipping_rate: Option<String>,
421}
422
423#[derive(Clone, Debug, Default, Deserialize, Serialize)]
424pub struct CreateCreditNoteLinesTaxAmounts {
425    /// The amount, in cents (or local equivalent), of the tax.
426    pub amount: i64,
427
428    /// The id of the tax rate for this tax amount.
429    ///
430    /// The tax rate must have been automatically created by Stripe.
431    pub tax_rate: String,
432
433    /// The amount on which tax is calculated, in cents (or local equivalent).
434    pub taxable_amount: i64,
435}
436
437/// An enum representing the possible values of an `CreateCreditNoteLines`'s `type` field.
438#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
439#[serde(rename_all = "snake_case")]
440pub enum CreateCreditNoteLinesType {
441    CustomLineItem,
442    InvoiceLineItem,
443}
444
445impl CreateCreditNoteLinesType {
446    pub fn as_str(self) -> &'static str {
447        match self {
448            CreateCreditNoteLinesType::CustomLineItem => "custom_line_item",
449            CreateCreditNoteLinesType::InvoiceLineItem => "invoice_line_item",
450        }
451    }
452}
453
454impl AsRef<str> for CreateCreditNoteLinesType {
455    fn as_ref(&self) -> &str {
456        self.as_str()
457    }
458}
459
460impl std::fmt::Display for CreateCreditNoteLinesType {
461    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
462        self.as_str().fmt(f)
463    }
464}
465impl std::default::Default for CreateCreditNoteLinesType {
466    fn default() -> Self {
467        Self::CustomLineItem
468    }
469}
470
471/// An enum representing the possible values of an `CreditNote`'s `reason` field.
472#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
473#[serde(rename_all = "snake_case")]
474pub enum CreditNoteReason {
475    Duplicate,
476    Fraudulent,
477    OrderChange,
478    ProductUnsatisfactory,
479}
480
481impl CreditNoteReason {
482    pub fn as_str(self) -> &'static str {
483        match self {
484            CreditNoteReason::Duplicate => "duplicate",
485            CreditNoteReason::Fraudulent => "fraudulent",
486            CreditNoteReason::OrderChange => "order_change",
487            CreditNoteReason::ProductUnsatisfactory => "product_unsatisfactory",
488        }
489    }
490}
491
492impl AsRef<str> for CreditNoteReason {
493    fn as_ref(&self) -> &str {
494        self.as_str()
495    }
496}
497
498impl std::fmt::Display for CreditNoteReason {
499    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
500        self.as_str().fmt(f)
501    }
502}
503impl std::default::Default for CreditNoteReason {
504    fn default() -> Self {
505        Self::Duplicate
506    }
507}
508
509/// An enum representing the possible values of an `CreditNote`'s `status` field.
510#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
511#[serde(rename_all = "snake_case")]
512pub enum CreditNoteStatus {
513    Issued,
514    Void,
515}
516
517impl CreditNoteStatus {
518    pub fn as_str(self) -> &'static str {
519        match self {
520            CreditNoteStatus::Issued => "issued",
521            CreditNoteStatus::Void => "void",
522        }
523    }
524}
525
526impl AsRef<str> for CreditNoteStatus {
527    fn as_ref(&self) -> &str {
528        self.as_str()
529    }
530}
531
532impl std::fmt::Display for CreditNoteStatus {
533    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
534        self.as_str().fmt(f)
535    }
536}
537impl std::default::Default for CreditNoteStatus {
538    fn default() -> Self {
539        Self::Issued
540    }
541}
542
543/// An enum representing the possible values of an `CreditNoteTaxAmount`'s `taxability_reason` field.
544#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
545#[serde(rename_all = "snake_case")]
546pub enum CreditNoteTaxAmountTaxabilityReason {
547    CustomerExempt,
548    NotCollecting,
549    NotSubjectToTax,
550    NotSupported,
551    PortionProductExempt,
552    PortionReducedRated,
553    PortionStandardRated,
554    ProductExempt,
555    ProductExemptHoliday,
556    ProportionallyRated,
557    ReducedRated,
558    ReverseCharge,
559    StandardRated,
560    TaxableBasisReduced,
561    ZeroRated,
562}
563
564impl CreditNoteTaxAmountTaxabilityReason {
565    pub fn as_str(self) -> &'static str {
566        match self {
567            CreditNoteTaxAmountTaxabilityReason::CustomerExempt => "customer_exempt",
568            CreditNoteTaxAmountTaxabilityReason::NotCollecting => "not_collecting",
569            CreditNoteTaxAmountTaxabilityReason::NotSubjectToTax => "not_subject_to_tax",
570            CreditNoteTaxAmountTaxabilityReason::NotSupported => "not_supported",
571            CreditNoteTaxAmountTaxabilityReason::PortionProductExempt => "portion_product_exempt",
572            CreditNoteTaxAmountTaxabilityReason::PortionReducedRated => "portion_reduced_rated",
573            CreditNoteTaxAmountTaxabilityReason::PortionStandardRated => "portion_standard_rated",
574            CreditNoteTaxAmountTaxabilityReason::ProductExempt => "product_exempt",
575            CreditNoteTaxAmountTaxabilityReason::ProductExemptHoliday => "product_exempt_holiday",
576            CreditNoteTaxAmountTaxabilityReason::ProportionallyRated => "proportionally_rated",
577            CreditNoteTaxAmountTaxabilityReason::ReducedRated => "reduced_rated",
578            CreditNoteTaxAmountTaxabilityReason::ReverseCharge => "reverse_charge",
579            CreditNoteTaxAmountTaxabilityReason::StandardRated => "standard_rated",
580            CreditNoteTaxAmountTaxabilityReason::TaxableBasisReduced => "taxable_basis_reduced",
581            CreditNoteTaxAmountTaxabilityReason::ZeroRated => "zero_rated",
582        }
583    }
584}
585
586impl AsRef<str> for CreditNoteTaxAmountTaxabilityReason {
587    fn as_ref(&self) -> &str {
588        self.as_str()
589    }
590}
591
592impl std::fmt::Display for CreditNoteTaxAmountTaxabilityReason {
593    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
594        self.as_str().fmt(f)
595    }
596}
597impl std::default::Default for CreditNoteTaxAmountTaxabilityReason {
598    fn default() -> Self {
599        Self::CustomerExempt
600    }
601}
602
603/// An enum representing the possible values of an `CreditNote`'s `type` field.
604#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
605#[serde(rename_all = "snake_case")]
606pub enum CreditNoteType {
607    PostPayment,
608    PrePayment,
609}
610
611impl CreditNoteType {
612    pub fn as_str(self) -> &'static str {
613        match self {
614            CreditNoteType::PostPayment => "post_payment",
615            CreditNoteType::PrePayment => "pre_payment",
616        }
617    }
618}
619
620impl AsRef<str> for CreditNoteType {
621    fn as_ref(&self) -> &str {
622        self.as_str()
623    }
624}
625
626impl std::fmt::Display for CreditNoteType {
627    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
628        self.as_str().fmt(f)
629    }
630}
631impl std::default::Default for CreditNoteType {
632    fn default() -> Self {
633        Self::PostPayment
634    }
635}