pub struct TaxCodeGenerator { /* private fields */ }Expand description
Generates tax jurisdictions and tax codes from built-in rate tables.
The generator reads TaxConfig to determine which countries to produce
jurisdictions for, whether to include sub-national jurisdictions (US states,
Canadian provinces, etc.), and whether config-provided rate overrides should
replace the built-in defaults.
§Examples
use datasynth_generators::tax::TaxCodeGenerator;
let mut gen = TaxCodeGenerator::new(42);
let (jurisdictions, codes) = gen.generate();
assert!(!jurisdictions.is_empty());
assert!(!codes.is_empty());Implementations§
Source§impl TaxCodeGenerator
impl TaxCodeGenerator
Sourcepub fn new(seed: u64) -> Self
pub fn new(seed: u64) -> Self
Creates a new generator with default configuration.
Default config generates jurisdictions for US, DE, and GB.
Sourcepub fn with_config(seed: u64, config: TaxConfig) -> Self
pub fn with_config(seed: u64, config: TaxConfig) -> Self
Creates a new generator with custom configuration.
Sourcepub fn generate(&mut self) -> (Vec<TaxJurisdiction>, Vec<TaxCode>)
pub fn generate(&mut self) -> (Vec<TaxJurisdiction>, Vec<TaxCode>)
Generates tax jurisdictions and tax codes.
Returns a tuple of (Vec<TaxJurisdiction>, Vec<TaxCode>).
Sourcepub fn generate_from_country_pack(
&mut self,
pack: &CountryPack,
company_code: &str,
fiscal_year: i32,
) -> (Vec<TaxJurisdiction>, Vec<TaxCode>)
pub fn generate_from_country_pack( &mut self, pack: &CountryPack, company_code: &str, fiscal_year: i32, ) -> (Vec<TaxJurisdiction>, Vec<TaxCode>)
Generates tax jurisdictions and tax codes from a CountryPack.
This is an alternative to generate() that reads
tax rates and sub-national jurisdictions from a country pack instead of
using the hardcoded constants. If the pack carries no meaningful tax data
(e.g. standard_rate == 0.0 and no sub-national entries), the method
returns empty vectors so the caller can fall back to generate().
§Arguments
pack- The country pack whose tax data should drive generation.company_code- Company code used to prefix generated IDs.fiscal_year- Fiscal year; used to derive the effective date (January 1 of that year).
Auto Trait Implementations§
impl Freeze for TaxCodeGenerator
impl RefUnwindSafe for TaxCodeGenerator
impl Send for TaxCodeGenerator
impl Sync for TaxCodeGenerator
impl Unpin for TaxCodeGenerator
impl UnsafeUnpin for TaxCodeGenerator
impl UnwindSafe for TaxCodeGenerator
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.