pub struct TaxCode {
pub id: String,
pub code: String,
pub description: String,
pub tax_type: TaxType,
pub rate: Decimal,
pub jurisdiction_id: String,
pub effective_date: NaiveDate,
pub expiry_date: Option<NaiveDate>,
pub is_reverse_charge: bool,
pub is_exempt: bool,
}Expand description
A tax code defining a rate for a specific tax type and jurisdiction.
Fields§
§id: StringUnique tax code identifier
code: StringShort mnemonic (e.g., “VAT-STD-20”, “WHT-SVC-15”)
description: StringHuman-readable description
tax_type: TaxTypeCategory of tax
rate: DecimalTax rate as a decimal fraction (e.g., 0.20 for 20%)
jurisdiction_id: StringJurisdiction this code applies to
effective_date: NaiveDateDate from which the code is effective (inclusive)
expiry_date: Option<NaiveDate>Date after which the code is no longer effective (exclusive)
is_reverse_charge: boolWhether the reverse-charge mechanism applies
is_exempt: boolWhether transactions under this code are tax-exempt
Implementations§
Source§impl TaxCode
impl TaxCode
Sourcepub fn new(
id: impl Into<String>,
code: impl Into<String>,
description: impl Into<String>,
tax_type: TaxType,
rate: Decimal,
jurisdiction_id: impl Into<String>,
effective_date: NaiveDate,
) -> Self
pub fn new( id: impl Into<String>, code: impl Into<String>, description: impl Into<String>, tax_type: TaxType, rate: Decimal, jurisdiction_id: impl Into<String>, effective_date: NaiveDate, ) -> Self
Creates a new tax code.
Sourcepub fn with_expiry_date(self, expiry: NaiveDate) -> Self
pub fn with_expiry_date(self, expiry: NaiveDate) -> Self
Sets the expiry date.
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_exempt(self, exempt: bool) -> Self
pub fn with_exempt(self, exempt: bool) -> Self
Sets the exempt flag.
Sourcepub fn tax_amount(&self, taxable_amount: Decimal) -> Decimal
pub fn tax_amount(&self, taxable_amount: Decimal) -> Decimal
Computes the tax amount for a given taxable base.
Returns taxable_amount * rate, rounded to 2 decimal places.
Exempt codes always return zero.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TaxCode
impl<'de> Deserialize<'de> for TaxCode
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
Source§impl ToNodeProperties for TaxCode
impl ToNodeProperties for TaxCode
Source§fn node_type_name(&self) -> &'static str
fn node_type_name(&self) -> &'static str
Entity type name (snake_case), e.g.
"uncertain_tax_position".Source§fn node_type_code(&self) -> u16
fn node_type_code(&self) -> u16
Numeric entity type code for registry, e.g.
416.Source§fn to_node_properties(&self) -> HashMap<String, GraphPropertyValue>
fn to_node_properties(&self) -> HashMap<String, GraphPropertyValue>
Convert all fields to a property map with camelCase keys.
Auto Trait Implementations§
impl Freeze for TaxCode
impl RefUnwindSafe for TaxCode
impl Send for TaxCode
impl Sync for TaxCode
impl Unpin for TaxCode
impl UnsafeUnpin for TaxCode
impl UnwindSafe for TaxCode
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