pub struct JournalEntryGenerator { /* private fields */ }Expand description
Generator for realistic journal entries.
Implementations§
Source§impl JournalEntryGenerator
impl JournalEntryGenerator
Sourcepub fn new_with_params(
config: TransactionConfig,
coa: Arc<ChartOfAccounts>,
companies: Vec<String>,
start_date: NaiveDate,
end_date: NaiveDate,
seed: u64,
) -> Self
pub fn new_with_params( config: TransactionConfig, coa: Arc<ChartOfAccounts>, companies: Vec<String>, start_date: NaiveDate, end_date: NaiveDate, seed: u64, ) -> Self
Create a new journal entry generator.
Sourcepub fn new_with_full_config(
config: TransactionConfig,
coa: Arc<ChartOfAccounts>,
companies: Vec<String>,
start_date: NaiveDate,
end_date: NaiveDate,
seed: u64,
template_config: TemplateConfig,
user_pool: Option<UserPool>,
) -> Self
pub fn new_with_full_config( config: TransactionConfig, coa: Arc<ChartOfAccounts>, companies: Vec<String>, start_date: NaiveDate, end_date: NaiveDate, seed: u64, template_config: TemplateConfig, user_pool: Option<UserPool>, ) -> Self
Create a new journal entry generator with full configuration.
Sourcepub fn from_generator_config(
full_config: &GeneratorConfig,
coa: Arc<ChartOfAccounts>,
start_date: NaiveDate,
end_date: NaiveDate,
seed: u64,
) -> Self
pub fn from_generator_config( full_config: &GeneratorConfig, coa: Arc<ChartOfAccounts>, start_date: NaiveDate, end_date: NaiveDate, seed: u64, ) -> Self
Create from a full GeneratorConfig.
This constructor uses the volume_weight from company configs for weighted company selection, and fraud config from GeneratorConfig.
Sourcepub fn with_temporal_patterns(
self,
config: TemporalPatternsConfig,
seed: u64,
) -> Self
pub fn with_temporal_patterns( self, config: TemporalPatternsConfig, seed: u64, ) -> Self
Configure temporal patterns including business day calculations and processing lags.
This enables realistic temporal behavior including:
- Business day awareness (no postings on weekends/holidays)
- Processing lag modeling (event-to-posting delays)
- Period-end dynamics (volume spikes at month/quarter/year end)
Sourcepub fn with_country_pack_temporal(
self,
config: TemporalPatternsConfig,
seed: u64,
pack: &CountryPack,
) -> Self
pub fn with_country_pack_temporal( self, config: TemporalPatternsConfig, seed: u64, pack: &CountryPack, ) -> Self
Configure temporal patterns using a CountryPack for the holiday calendar.
This is an alternative to [with_temporal_patterns] that derives the
holiday calendar from a country-pack definition rather than the built-in
region-based calendars. All other temporal behaviour (business-day
adjustment, processing lags, period-end dynamics) is configured
identically.
Sourcepub fn set_company_selector(&mut self, selector: WeightedCompanySelector)
pub fn set_company_selector(&mut self, selector: WeightedCompanySelector)
Set a custom company selector.
Sourcepub fn company_selector(&self) -> &WeightedCompanySelector
pub fn company_selector(&self) -> &WeightedCompanySelector
Get the current company selector.
Sourcepub fn set_fraud_config(&mut self, config: FraudConfig)
pub fn set_fraud_config(&mut self, config: FraudConfig)
Set fraud configuration.
Sourcepub fn with_vendors(self, vendors: &[Vendor]) -> Self
pub fn with_vendors(self, vendors: &[Vendor]) -> Self
Set vendors from generated master data.
This replaces the default vendor pool with actual generated vendors, ensuring JEs reference real master data entities.
Sourcepub fn with_customers(self, customers: &[Customer]) -> Self
pub fn with_customers(self, customers: &[Customer]) -> Self
Set customers from generated master data.
This replaces the default customer pool with actual generated customers, ensuring JEs reference real master data entities.
Sourcepub fn with_materials(self, materials: &[Material]) -> Self
pub fn with_materials(self, materials: &[Material]) -> Self
Set materials from generated master data.
This provides material references for JEs that involve inventory movements.
Sourcepub fn with_master_data(
self,
vendors: &[Vendor],
customers: &[Customer],
materials: &[Material],
) -> Self
pub fn with_master_data( self, vendors: &[Vendor], customers: &[Customer], materials: &[Material], ) -> Self
Set all master data at once for convenience.
This is the recommended way to configure the JE generator with generated master data to ensure data coherence.
Sourcepub fn with_country_pack_names(self, pack: &CountryPack) -> Self
pub fn with_country_pack_names(self, pack: &CountryPack) -> Self
Replace the user pool with one generated from a CountryPack.
This is an alternative to the default name-culture distribution that
derives name pools and weights from the country-pack’s names section.
The existing user pool (if any) is discarded and regenerated using
[MultiCultureNameGenerator::from_country_pack].
Sourcepub fn is_using_real_master_data(&self) -> bool
pub fn is_using_real_master_data(&self) -> bool
Check if the generator is using real master data.
Sourcepub fn generate(&mut self) -> JournalEntry
pub fn generate(&mut self) -> JournalEntry
Generate a single journal entry.
Sourcepub fn with_persona_errors(self, enabled: bool) -> Self
pub fn with_persona_errors(self, enabled: bool) -> Self
Enable or disable persona-based error injection.
When enabled, entries created by human personas have a chance to contain realistic human errors based on their experience level.
Sourcepub fn with_fraud_config(self, config: FraudConfig) -> Self
pub fn with_fraud_config(self, config: FraudConfig) -> Self
Set fraud configuration for fraud injection.
When fraud is enabled in the config, transactions have a chance to be marked as fraudulent based on the configured fraud rate.
Sourcepub fn persona_errors_enabled(&self) -> bool
pub fn persona_errors_enabled(&self) -> bool
Check if persona errors are enabled.
Sourcepub fn with_batching(self, enabled: bool) -> Self
pub fn with_batching(self, enabled: bool) -> Self
Enable or disable batch processing behavior.
When enabled (default), the generator will occasionally produce batches of similar entries, simulating how humans batch similar work together.
Sourcepub fn batching_enabled(&self) -> bool
pub fn batching_enabled(&self) -> bool
Check if batch processing is enabled.
Sourcepub fn with_approval(self, enabled: bool) -> Self
pub fn with_approval(self, enabled: bool) -> Self
Enable or disable approval workflow.
Sourcepub fn with_approval_threshold(self, threshold: Decimal) -> Self
pub fn with_approval_threshold(self, threshold: Decimal) -> Self
Set the approval threshold amount.
Sourcepub fn with_drift_controller(self, controller: DriftController) -> Self
pub fn with_drift_controller(self, controller: DriftController) -> Self
Set the temporal drift controller for simulating distribution changes over time.
When drift is enabled, amounts and other distributions will shift based on the period (month) to simulate realistic temporal evolution like inflation or increasing fraud rates.
Sourcepub fn with_drift_config(self, config: DriftConfig, seed: u64) -> Self
pub fn with_drift_config(self, config: DriftConfig, seed: u64) -> Self
Set drift configuration directly.
Creates a drift controller from the config. Total periods is calculated from the date range.
Trait Implementations§
Source§impl Generator for JournalEntryGenerator
impl Generator for JournalEntryGenerator
Source§type Item = JournalEntry
type Item = JournalEntry
Source§type Config = (TransactionConfig, Arc<ChartOfAccounts>, Vec<String>, NaiveDate, NaiveDate)
type Config = (TransactionConfig, Arc<ChartOfAccounts>, Vec<String>, NaiveDate, NaiveDate)
Source§fn new(config: Self::Config, seed: u64) -> Self
fn new(config: Self::Config, seed: u64) -> Self
Source§fn generate_one(&mut self) -> Self::Item
fn generate_one(&mut self) -> Self::Item
Source§fn generate_batch(&mut self, count: usize) -> Vec<Self::Item>
fn generate_batch(&mut self, count: usize) -> Vec<Self::Item>
Source§fn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self>where
Self: Sized,
fn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self>where
Self: Sized,
Source§impl ParallelGenerator for JournalEntryGenerator
impl ParallelGenerator for JournalEntryGenerator
Source§fn split(self, parts: usize) -> Vec<Self>
fn split(self, parts: usize) -> Vec<Self>
Split this generator into parts independent sub-generators.
Each sub-generator gets a deterministic seed derived from the parent seed and its partition index, plus a partitioned UUID factory to avoid contention. The results are deterministic for a given partition count.