pub struct Customer {Show 25 fields
pub customer_id: String,
pub name: String,
pub customer_type: CustomerType,
pub country: String,
pub credit_rating: CreditRating,
pub credit_limit: Decimal,
pub credit_exposure: Decimal,
pub payment_terms: PaymentTerms,
pub payment_terms_days: u8,
pub payment_behavior: CustomerPaymentBehavior,
pub is_active: bool,
pub account_number: Option<String>,
pub typical_order_range: (Decimal, Decimal),
pub is_intercompany: bool,
pub intercompany_code: Option<String>,
pub currency: String,
pub reconciliation_account: Option<String>,
pub sales_org: Option<String>,
pub distribution_channel: Option<String>,
pub tax_id: Option<String>,
pub credit_blocked: bool,
pub credit_block_reason: Option<String>,
pub dunning_procedure: Option<String>,
pub last_dunning_date: Option<NaiveDate>,
pub dunning_level: u8,
}Expand description
Customer master data.
Fields§
§customer_id: StringCustomer ID (e.g., “C-001234”)
name: StringCustomer name
customer_type: CustomerTypeType of customer
country: StringCountry code (ISO 3166-1 alpha-2)
credit_rating: CreditRatingCredit rating
credit_limit: DecimalCredit limit
credit_exposure: DecimalCurrent credit exposure (outstanding AR)
payment_terms: PaymentTermsPayment terms (structured)
payment_terms_days: u8Payment terms in days (legacy)
payment_behavior: CustomerPaymentBehaviorPayment behavior pattern
is_active: boolIs this customer active
account_number: Option<String>Customer account number in sub-ledger
typical_order_range: (Decimal, Decimal)Typical order amount range (min, max)
is_intercompany: boolIs this an intercompany customer?
intercompany_code: Option<String>Related company code (if intercompany)
currency: StringCurrency for transactions
reconciliation_account: Option<String>Reconciliation account in GL
sales_org: Option<String>Sales organization
distribution_channel: Option<String>Distribution channel
tax_id: Option<String>Tax ID / VAT number
credit_blocked: boolIs credit blocked?
credit_block_reason: Option<String>Credit block reason
dunning_procedure: Option<String>Dunning procedure
last_dunning_date: Option<NaiveDate>Last dunning date
dunning_level: u8Dunning level (0-4)
Implementations§
Source§impl Customer
impl Customer
Sourcepub fn new(customer_id: &str, name: &str, customer_type: CustomerType) -> Self
pub fn new(customer_id: &str, name: &str, customer_type: CustomerType) -> Self
Create a new customer.
Sourcepub fn new_intercompany(
customer_id: &str,
name: &str,
related_company_code: &str,
) -> Self
pub fn new_intercompany( customer_id: &str, name: &str, related_company_code: &str, ) -> Self
Create an intercompany customer.
Sourcepub fn with_country(self, country: &str) -> Self
pub fn with_country(self, country: &str) -> Self
Set country.
Sourcepub fn with_credit_rating(self, rating: CreditRating) -> Self
pub fn with_credit_rating(self, rating: CreditRating) -> Self
Set credit rating.
Sourcepub fn with_credit_limit(self, limit: Decimal) -> Self
pub fn with_credit_limit(self, limit: Decimal) -> Self
Set credit limit.
Sourcepub fn with_payment_terms_structured(self, terms: PaymentTerms) -> Self
pub fn with_payment_terms_structured(self, terms: PaymentTerms) -> Self
Set structured payment terms.
Sourcepub fn with_payment_terms(self, days: u8) -> Self
pub fn with_payment_terms(self, days: u8) -> Self
Set payment terms (legacy, by days).
Sourcepub fn with_payment_behavior(self, behavior: CustomerPaymentBehavior) -> Self
pub fn with_payment_behavior(self, behavior: CustomerPaymentBehavior) -> Self
Set payment behavior.
Sourcepub fn with_intercompany(self, related_company_code: &str) -> Self
pub fn with_intercompany(self, related_company_code: &str) -> Self
Set as intercompany customer.
Sourcepub fn with_currency(self, currency: &str) -> Self
pub fn with_currency(self, currency: &str) -> Self
Set currency.
Sourcepub fn with_sales_org(self, org: &str) -> Self
pub fn with_sales_org(self, org: &str) -> Self
Set sales organization.
Sourcepub fn block_credit(&mut self, reason: &str)
pub fn block_credit(&mut self, reason: &str)
Block credit.
Sourcepub fn unblock_credit(&mut self)
pub fn unblock_credit(&mut self)
Unblock credit.
Sourcepub fn can_place_order(&self, order_amount: Decimal) -> bool
pub fn can_place_order(&self, order_amount: Decimal) -> bool
Check if order can be placed (credit check).
Sourcepub fn available_credit(&self) -> Decimal
pub fn available_credit(&self) -> Decimal
Available credit.
Sourcepub fn add_credit_exposure(&mut self, amount: Decimal)
pub fn add_credit_exposure(&mut self, amount: Decimal)
Update credit exposure.
Sourcepub fn reduce_credit_exposure(&mut self, amount: Decimal)
pub fn reduce_credit_exposure(&mut self, amount: Decimal)
Reduce credit exposure (payment received).
Sourcepub fn generate_order_amount(&self, rng: &mut impl Rng) -> Decimal
pub fn generate_order_amount(&self, rng: &mut impl Rng) -> Decimal
Generate a random order amount within typical range.
Sourcepub fn calculate_due_date(&self, invoice_date: NaiveDate) -> NaiveDate
pub fn calculate_due_date(&self, invoice_date: NaiveDate) -> NaiveDate
Calculate due date for an invoice.
Sourcepub fn simulate_payment_date(
&self,
due_date: NaiveDate,
rng: &mut impl Rng,
) -> NaiveDate
pub fn simulate_payment_date( &self, due_date: NaiveDate, rng: &mut impl Rng, ) -> NaiveDate
Simulate payment date based on payment behavior.