pub struct TaxLine {
pub id: String,
pub document_type: TaxableDocumentType,
pub document_id: String,
pub line_number: u32,
pub tax_code_id: String,
pub jurisdiction_id: String,
pub taxable_amount: Decimal,
pub tax_amount: Decimal,
pub is_deductible: bool,
pub is_reverse_charge: bool,
pub is_self_assessed: bool,
}Expand description
A single tax line attached to a source document.
Fields§
§id: StringUnique tax line identifier
document_type: TaxableDocumentTypeType of the source document
document_id: StringSource document identifier
line_number: u32Line number within the document
tax_code_id: StringTax code applied
jurisdiction_id: StringJurisdiction the tax is assessed in
taxable_amount: DecimalBase amount subject to tax
tax_amount: DecimalComputed tax amount
is_deductible: boolWhether the input tax is deductible (reclaimable)
is_reverse_charge: boolWhether the reverse-charge mechanism applies
is_self_assessed: boolWhether the tax was self-assessed by the buyer
Implementations§
Source§impl TaxLine
impl TaxLine
Sourcepub fn new(
id: impl Into<String>,
document_type: TaxableDocumentType,
document_id: impl Into<String>,
line_number: u32,
tax_code_id: impl Into<String>,
jurisdiction_id: impl Into<String>,
taxable_amount: Decimal,
tax_amount: Decimal,
) -> Self
pub fn new( id: impl Into<String>, document_type: TaxableDocumentType, document_id: impl Into<String>, line_number: u32, tax_code_id: impl Into<String>, jurisdiction_id: impl Into<String>, taxable_amount: Decimal, tax_amount: Decimal, ) -> Self
Creates a new tax line.
Sourcepub fn with_deductible(self, deductible: bool) -> Self
pub fn with_deductible(self, deductible: bool) -> Self
Sets the deductible flag.
Sourcepub fn with_reverse_charge(self, reverse_charge: bool) -> Self
pub fn with_reverse_charge(self, reverse_charge: bool) -> Self
Sets the reverse-charge flag.
Sourcepub fn with_self_assessed(self, self_assessed: bool) -> Self
pub fn with_self_assessed(self, self_assessed: bool) -> Self
Sets the self-assessed flag.
Sourcepub fn effective_rate(&self) -> Decimal
pub fn effective_rate(&self) -> Decimal
Computes the effective tax rate for this line.
Returns tax_amount / taxable_amount, or Decimal::ZERO when the
taxable amount is zero (avoids division by zero).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TaxLine
impl<'de> Deserialize<'de> for TaxLine
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TaxLine
impl RefUnwindSafe for TaxLine
impl Send for TaxLine
impl Sync for TaxLine
impl Unpin for TaxLine
impl UnsafeUnpin for TaxLine
impl UnwindSafe for TaxLine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more