Skip to main content

JournalEntryGenerator

Struct JournalEntryGenerator 

Source
pub struct JournalEntryGenerator { /* private fields */ }
Expand description

Generator for realistic journal entries.

Implementations§

Source§

impl JournalEntryGenerator

Source

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.

Source

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.

Source

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.

Source

pub fn set_company_selector(&mut self, selector: WeightedCompanySelector)

Set a custom company selector.

Source

pub fn company_selector(&self) -> &WeightedCompanySelector

Get the current company selector.

Source

pub fn set_fraud_config(&mut self, config: FraudConfig)

Set fraud configuration.

Source

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.

Source

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.

Source

pub fn with_materials(self, materials: &[Material]) -> Self

Set materials from generated master data.

This provides material references for JEs that involve inventory movements.

Source

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.

Source

pub fn is_using_real_master_data(&self) -> bool

Check if the generator is using real master data.

Source

pub fn generate(&mut self) -> JournalEntry

Generate a single journal entry.

Source

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.

Source

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.

Source

pub fn persona_errors_enabled(&self) -> bool

Check if persona errors are enabled.

Source

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.

Source

pub fn batching_enabled(&self) -> bool

Check if batch processing is enabled.

Source

pub fn with_approval(self, enabled: bool) -> Self

Enable or disable approval workflow.

Source

pub fn with_approval_threshold(self, threshold: Decimal) -> Self

Set the approval threshold amount.

Source

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.

Source

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

Source§

type Item = JournalEntry

The type of items this generator produces.
Source§

type Config = (TransactionConfig, Arc<ChartOfAccounts>, Vec<String>, NaiveDate, NaiveDate)

The configuration type for this generator.
Source§

fn new(config: Self::Config, seed: u64) -> Self

Initialize the generator with configuration and seed. Read more
Source§

fn generate_one(&mut self) -> Self::Item

Generate a single item.
Source§

fn reset(&mut self)

Reset the generator to initial state (same seed). Read more
Source§

fn count(&self) -> u64

Get the current generation count.
Source§

fn seed(&self) -> u64

Get the seed used by this generator.
Source§

fn generate_batch(&mut self, count: usize) -> Vec<Self::Item>

Generate a batch of items. Read more
Source§

fn generate_iter(&mut self, count: usize) -> GeneratorIterator<'_, Self>
where Self: Sized,

Generate items into an iterator. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V