1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
// ======================================
// This file was automatically generated.
// ======================================
use serde::{Deserialize, Serialize};
use crate::ids::CreditNoteLineItemId;
use crate::params::{Expandable, Object};
use crate::resources::{Discount, TaxRate};
/// The resource representing a Stripe "CreditNoteLineItem".
///
/// For more details see <https://stripe.com/docs/api/credit_notes/line_item>
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreditNoteLineItem {
/// Unique identifier for the object.
pub id: CreditNoteLineItemId,
/// The integer amount in %s representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts.
pub amount: i64,
/// The integer amount in %s representing the amount being credited for this line item, excluding all tax and discounts.
pub amount_excluding_tax: Option<i64>,
/// Description of the item being credited.
pub description: Option<String>,
/// The integer amount in %s representing the discount being credited for this line item.
pub discount_amount: i64,
/// The amount of discount calculated per discount for this line item.
pub discount_amounts: Vec<DiscountsResourceDiscountAmount>,
/// ID of the invoice line item being credited.
#[serde(skip_serializing_if = "Option::is_none")]
pub invoice_line_item: Option<String>,
/// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
pub livemode: bool,
/// The number of units of product being credited.
pub quantity: Option<u64>,
/// The amount of tax calculated per tax rate for this line item.
pub tax_amounts: Vec<CreditNoteTaxAmount>,
/// The tax rates which apply to the line item.
pub tax_rates: Vec<TaxRate>,
/// The type of the credit note line item, one of `invoice_line_item` or `custom_line_item`.
///
/// When the type is `invoice_line_item` there is an additional `invoice_line_item` property on the resource the value of which is the id of the credited line item on the invoice.
#[serde(rename = "type")]
pub type_: CreditNoteLineItemType,
/// The cost of each unit of product being credited.
pub unit_amount: Option<i64>,
/// Same as `unit_amount`, but contains a decimal value with at most 12 decimal places.
pub unit_amount_decimal: Option<String>,
/// The amount in %s representing the unit amount being credited for this line item, excluding all tax and discounts.
pub unit_amount_excluding_tax: Option<String>,
}
impl Object for CreditNoteLineItem {
type Id = CreditNoteLineItemId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"credit_note_line_item"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreditNoteTaxAmount {
/// The amount, in %s, of the tax.
pub amount: i64,
/// Whether this tax amount is inclusive or exclusive.
pub inclusive: bool,
/// The tax rate that was applied to get this tax amount.
pub tax_rate: Expandable<TaxRate>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct DiscountsResourceDiscountAmount {
/// The amount, in %s, of the discount.
pub amount: i64,
/// The discount that was applied to get this discount amount.
pub discount: Expandable<Discount>,
}
/// An enum representing the possible values of an `CreditNoteLineItem`'s `type` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum CreditNoteLineItemType {
CustomLineItem,
InvoiceLineItem,
}
impl CreditNoteLineItemType {
pub fn as_str(self) -> &'static str {
match self {
CreditNoteLineItemType::CustomLineItem => "custom_line_item",
CreditNoteLineItemType::InvoiceLineItem => "invoice_line_item",
}
}
}
impl AsRef<str> for CreditNoteLineItemType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for CreditNoteLineItemType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for CreditNoteLineItemType {
fn default() -> Self {
Self::CustomLineItem
}
}