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).