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