stripe/resources/generated/
credit_note_line_item.rs1use crate::ids::CreditNoteLineItemId;
6use crate::params::{Expandable, Object};
7use crate::resources::{Discount, TaxRate};
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct CreditNoteLineItem {
15 pub id: CreditNoteLineItemId,
17
18 pub amount: i64,
20
21 pub amount_excluding_tax: Option<i64>,
23
24 pub description: Option<String>,
26
27 pub discount_amount: i64,
29
30 pub discount_amounts: Vec<DiscountsResourceDiscountAmount>,
32
33 #[serde(skip_serializing_if = "Option::is_none")]
35 pub invoice_line_item: Option<String>,
36
37 pub livemode: bool,
39
40 pub quantity: Option<u64>,
42
43 pub tax_amounts: Vec<CreditNoteTaxAmount>,
45
46 pub tax_rates: Vec<TaxRate>,
48
49 #[serde(rename = "type")]
53 pub type_: CreditNoteLineItemType,
54
55 pub unit_amount: Option<i64>,
57
58 pub unit_amount_decimal: Option<String>,
60
61 pub unit_amount_excluding_tax: Option<String>,
63}
64
65impl Object for CreditNoteLineItem {
66 type Id = CreditNoteLineItemId;
67 fn id(&self) -> Self::Id {
68 self.id.clone()
69 }
70 fn object(&self) -> &'static str {
71 "credit_note_line_item"
72 }
73}
74
75#[derive(Clone, Debug, Default, Deserialize, Serialize)]
76pub struct CreditNoteTaxAmount {
77 pub amount: i64,
79
80 pub inclusive: bool,
82
83 pub tax_rate: Expandable<TaxRate>,
85
86 pub taxability_reason: Option<CreditNoteTaxAmountTaxabilityReason>,
90
91 pub taxable_amount: Option<i64>,
93}
94
95#[derive(Clone, Debug, Default, Deserialize, Serialize)]
96pub struct DiscountsResourceDiscountAmount {
97 pub amount: i64,
99
100 pub discount: Expandable<Discount>,
102}
103
104#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
106#[serde(rename_all = "snake_case")]
107pub enum CreditNoteLineItemType {
108 CustomLineItem,
109 InvoiceLineItem,
110}
111
112impl CreditNoteLineItemType {
113 pub fn as_str(self) -> &'static str {
114 match self {
115 CreditNoteLineItemType::CustomLineItem => "custom_line_item",
116 CreditNoteLineItemType::InvoiceLineItem => "invoice_line_item",
117 }
118 }
119}
120
121impl AsRef<str> for CreditNoteLineItemType {
122 fn as_ref(&self) -> &str {
123 self.as_str()
124 }
125}
126
127impl std::fmt::Display for CreditNoteLineItemType {
128 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
129 self.as_str().fmt(f)
130 }
131}
132impl std::default::Default for CreditNoteLineItemType {
133 fn default() -> Self {
134 Self::CustomLineItem
135 }
136}
137
138#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
140#[serde(rename_all = "snake_case")]
141pub enum CreditNoteTaxAmountTaxabilityReason {
142 CustomerExempt,
143 NotCollecting,
144 NotSubjectToTax,
145 NotSupported,
146 PortionProductExempt,
147 PortionReducedRated,
148 PortionStandardRated,
149 ProductExempt,
150 ProductExemptHoliday,
151 ProportionallyRated,
152 ReducedRated,
153 ReverseCharge,
154 StandardRated,
155 TaxableBasisReduced,
156 ZeroRated,
157}
158
159impl CreditNoteTaxAmountTaxabilityReason {
160 pub fn as_str(self) -> &'static str {
161 match self {
162 CreditNoteTaxAmountTaxabilityReason::CustomerExempt => "customer_exempt",
163 CreditNoteTaxAmountTaxabilityReason::NotCollecting => "not_collecting",
164 CreditNoteTaxAmountTaxabilityReason::NotSubjectToTax => "not_subject_to_tax",
165 CreditNoteTaxAmountTaxabilityReason::NotSupported => "not_supported",
166 CreditNoteTaxAmountTaxabilityReason::PortionProductExempt => "portion_product_exempt",
167 CreditNoteTaxAmountTaxabilityReason::PortionReducedRated => "portion_reduced_rated",
168 CreditNoteTaxAmountTaxabilityReason::PortionStandardRated => "portion_standard_rated",
169 CreditNoteTaxAmountTaxabilityReason::ProductExempt => "product_exempt",
170 CreditNoteTaxAmountTaxabilityReason::ProductExemptHoliday => "product_exempt_holiday",
171 CreditNoteTaxAmountTaxabilityReason::ProportionallyRated => "proportionally_rated",
172 CreditNoteTaxAmountTaxabilityReason::ReducedRated => "reduced_rated",
173 CreditNoteTaxAmountTaxabilityReason::ReverseCharge => "reverse_charge",
174 CreditNoteTaxAmountTaxabilityReason::StandardRated => "standard_rated",
175 CreditNoteTaxAmountTaxabilityReason::TaxableBasisReduced => "taxable_basis_reduced",
176 CreditNoteTaxAmountTaxabilityReason::ZeroRated => "zero_rated",
177 }
178 }
179}
180
181impl AsRef<str> for CreditNoteTaxAmountTaxabilityReason {
182 fn as_ref(&self) -> &str {
183 self.as_str()
184 }
185}
186
187impl std::fmt::Display for CreditNoteTaxAmountTaxabilityReason {
188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
189 self.as_str().fmt(f)
190 }
191}
192impl std::default::Default for CreditNoteTaxAmountTaxabilityReason {
193 fn default() -> Self {
194 Self::CustomerExempt
195 }
196}