use crate::ids::{TaxTransactionId};
use crate::params::{List, Metadata, Object, Timestamp};
use crate::resources::{Currency, TaxProductResourceCustomerDetails, TaxTransactionLineItem};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TaxTransaction {
pub id: TaxTransactionId,
pub created: Timestamp,
pub currency: Currency,
pub customer: Option<String>,
pub customer_details: TaxProductResourceCustomerDetails,
pub line_items: Option<List<TaxTransactionLineItem>>,
pub livemode: bool,
pub metadata: Option<Metadata>,
pub reference: String,
pub reversal: Option<TaxProductResourceTaxTransactionResourceReversal>,
pub shipping_cost: Option<TaxProductResourceTaxTransactionShippingCost>,
pub tax_date: Timestamp,
#[serde(rename = "type")]
pub type_: TaxTransactionType,
}
impl Object for TaxTransaction {
type Id = TaxTransactionId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"tax.transaction"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TaxProductResourceTaxTransactionResourceReversal {
pub original_transaction: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TaxProductResourceTaxTransactionShippingCost {
pub amount: i64,
pub amount_tax: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub shipping_rate: Option<String>,
pub tax_behavior: TaxProductResourceTaxTransactionShippingCostTaxBehavior,
#[serde(skip_serializing_if = "Option::is_none")]
pub tax_breakdown: Option<Vec<TaxProductResourceLineItemTaxBreakdown>>,
pub tax_code: String,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TaxProductResourceLineItemTaxBreakdown {
pub amount: i64,
pub jurisdiction: TaxProductResourceJurisdiction,
pub sourcing: TaxProductResourceLineItemTaxBreakdownSourcing,
pub tax_rate_details: Option<TaxProductResourceLineItemTaxRateDetails>,
pub taxability_reason: TaxProductResourceLineItemTaxBreakdownTaxabilityReason,
pub taxable_amount: i64,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TaxProductResourceJurisdiction {
pub country: String,
pub display_name: String,
pub level: TaxProductResourceJurisdictionLevel,
pub state: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct TaxProductResourceLineItemTaxRateDetails {
pub display_name: String,
pub percentage_decimal: String,
pub tax_type: TaxProductResourceLineItemTaxRateDetailsTaxType,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaxProductResourceJurisdictionLevel {
City,
Country,
County,
District,
State,
}
impl TaxProductResourceJurisdictionLevel {
pub fn as_str(self) -> &'static str {
match self {
TaxProductResourceJurisdictionLevel::City => "city",
TaxProductResourceJurisdictionLevel::Country => "country",
TaxProductResourceJurisdictionLevel::County => "county",
TaxProductResourceJurisdictionLevel::District => "district",
TaxProductResourceJurisdictionLevel::State => "state",
}
}
}
impl AsRef<str> for TaxProductResourceJurisdictionLevel {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TaxProductResourceJurisdictionLevel {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TaxProductResourceJurisdictionLevel {
fn default() -> Self {
Self::City
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaxProductResourceLineItemTaxBreakdownSourcing {
Destination,
Origin,
}
impl TaxProductResourceLineItemTaxBreakdownSourcing {
pub fn as_str(self) -> &'static str {
match self {
TaxProductResourceLineItemTaxBreakdownSourcing::Destination => "destination",
TaxProductResourceLineItemTaxBreakdownSourcing::Origin => "origin",
}
}
}
impl AsRef<str> for TaxProductResourceLineItemTaxBreakdownSourcing {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TaxProductResourceLineItemTaxBreakdownSourcing {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TaxProductResourceLineItemTaxBreakdownSourcing {
fn default() -> Self {
Self::Destination
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
CustomerExempt,
NotCollecting,
NotSubjectToTax,
NotSupported,
PortionProductExempt,
PortionReducedRated,
PortionStandardRated,
ProductExempt,
ProductExemptHoliday,
ProportionallyRated,
ReducedRated,
ReverseCharge,
StandardRated,
TaxableBasisReduced,
ZeroRated,
}
impl TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
pub fn as_str(self) -> &'static str {
match self {
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::CustomerExempt => "customer_exempt",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::NotCollecting => "not_collecting",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::NotSubjectToTax => "not_subject_to_tax",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::NotSupported => "not_supported",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::PortionProductExempt => "portion_product_exempt",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::PortionReducedRated => "portion_reduced_rated",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::PortionStandardRated => "portion_standard_rated",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ProductExempt => "product_exempt",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ProductExemptHoliday => "product_exempt_holiday",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ProportionallyRated => "proportionally_rated",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ReducedRated => "reduced_rated",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ReverseCharge => "reverse_charge",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::StandardRated => "standard_rated",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::TaxableBasisReduced => "taxable_basis_reduced",
TaxProductResourceLineItemTaxBreakdownTaxabilityReason::ZeroRated => "zero_rated",
}
}
}
impl AsRef<str> for TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TaxProductResourceLineItemTaxBreakdownTaxabilityReason {
fn default() -> Self {
Self::CustomerExempt
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaxProductResourceLineItemTaxRateDetailsTaxType {
AmusementTax,
CommunicationsTax,
Gst,
Hst,
Igst,
Jct,
LeaseTax,
Pst,
Qst,
Rst,
SalesTax,
Vat,
}
impl TaxProductResourceLineItemTaxRateDetailsTaxType {
pub fn as_str(self) -> &'static str {
match self {
TaxProductResourceLineItemTaxRateDetailsTaxType::AmusementTax => "amusement_tax",
TaxProductResourceLineItemTaxRateDetailsTaxType::CommunicationsTax => "communications_tax",
TaxProductResourceLineItemTaxRateDetailsTaxType::Gst => "gst",
TaxProductResourceLineItemTaxRateDetailsTaxType::Hst => "hst",
TaxProductResourceLineItemTaxRateDetailsTaxType::Igst => "igst",
TaxProductResourceLineItemTaxRateDetailsTaxType::Jct => "jct",
TaxProductResourceLineItemTaxRateDetailsTaxType::LeaseTax => "lease_tax",
TaxProductResourceLineItemTaxRateDetailsTaxType::Pst => "pst",
TaxProductResourceLineItemTaxRateDetailsTaxType::Qst => "qst",
TaxProductResourceLineItemTaxRateDetailsTaxType::Rst => "rst",
TaxProductResourceLineItemTaxRateDetailsTaxType::SalesTax => "sales_tax",
TaxProductResourceLineItemTaxRateDetailsTaxType::Vat => "vat",
}
}
}
impl AsRef<str> for TaxProductResourceLineItemTaxRateDetailsTaxType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TaxProductResourceLineItemTaxRateDetailsTaxType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TaxProductResourceLineItemTaxRateDetailsTaxType {
fn default() -> Self {
Self::AmusementTax
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaxProductResourceTaxTransactionShippingCostTaxBehavior {
Exclusive,
Inclusive,
}
impl TaxProductResourceTaxTransactionShippingCostTaxBehavior {
pub fn as_str(self) -> &'static str {
match self {
TaxProductResourceTaxTransactionShippingCostTaxBehavior::Exclusive => "exclusive",
TaxProductResourceTaxTransactionShippingCostTaxBehavior::Inclusive => "inclusive",
}
}
}
impl AsRef<str> for TaxProductResourceTaxTransactionShippingCostTaxBehavior {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TaxProductResourceTaxTransactionShippingCostTaxBehavior {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TaxProductResourceTaxTransactionShippingCostTaxBehavior {
fn default() -> Self {
Self::Exclusive
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum TaxTransactionType {
Reversal,
Transaction,
}
impl TaxTransactionType {
pub fn as_str(self) -> &'static str {
match self {
TaxTransactionType::Reversal => "reversal",
TaxTransactionType::Transaction => "transaction",
}
}
}
impl AsRef<str> for TaxTransactionType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for TaxTransactionType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for TaxTransactionType {
fn default() -> Self {
Self::Reversal
}
}