Skip to main content

Customer

Struct Customer 

Source
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: String

Customer ID (e.g., “C-001234”)

§name: String

Customer name

§customer_type: CustomerType

Type of customer

§country: String

Country code (ISO 3166-1 alpha-2)

§credit_rating: CreditRating

Credit rating

§credit_limit: Decimal

Credit limit

§credit_exposure: Decimal

Current credit exposure (outstanding AR)

§payment_terms: PaymentTerms

Payment terms (structured)

§payment_terms_days: u8

Payment terms in days (legacy)

§payment_behavior: CustomerPaymentBehavior

Payment behavior pattern

§is_active: bool

Is 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: bool

Is this an intercompany customer?

§intercompany_code: Option<String>

Related company code (if intercompany)

§currency: String

Currency 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: bool

Is 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: u8

Dunning level (0-4)

Implementations§

Source§

impl Customer

Source

pub fn new(customer_id: &str, name: &str, customer_type: CustomerType) -> Self

Create a new customer.

Source

pub fn new_intercompany( customer_id: &str, name: &str, related_company_code: &str, ) -> Self

Create an intercompany customer.

Source

pub fn with_country(self, country: &str) -> Self

Set country.

Source

pub fn with_credit_rating(self, rating: CreditRating) -> Self

Set credit rating.

Source

pub fn with_credit_limit(self, limit: Decimal) -> Self

Set credit limit.

Source

pub fn with_payment_terms_structured(self, terms: PaymentTerms) -> Self

Set structured payment terms.

Source

pub fn with_payment_terms(self, days: u8) -> Self

Set payment terms (legacy, by days).

Source

pub fn with_payment_behavior(self, behavior: CustomerPaymentBehavior) -> Self

Set payment behavior.

Source

pub fn with_intercompany(self, related_company_code: &str) -> Self

Set as intercompany customer.

Source

pub fn with_currency(self, currency: &str) -> Self

Set currency.

Source

pub fn with_sales_org(self, org: &str) -> Self

Set sales organization.

Source

pub fn block_credit(&mut self, reason: &str)

Block credit.

Source

pub fn unblock_credit(&mut self)

Unblock credit.

Source

pub fn can_place_order(&self, order_amount: Decimal) -> bool

Check if order can be placed (credit check).

Source

pub fn available_credit(&self) -> Decimal

Available credit.

Source

pub fn add_credit_exposure(&mut self, amount: Decimal)

Update credit exposure.

Source

pub fn reduce_credit_exposure(&mut self, amount: Decimal)

Reduce credit exposure (payment received).

Source

pub fn generate_order_amount(&self, rng: &mut impl Rng) -> Decimal

Generate a random order amount within typical range.

Source

pub fn calculate_due_date(&self, invoice_date: NaiveDate) -> NaiveDate

Calculate due date for an invoice.

Source

pub fn simulate_payment_date( &self, due_date: NaiveDate, rng: &mut impl Rng, ) -> NaiveDate

Simulate payment date based on payment behavior.

Trait Implementations§

Source§

impl Clone for Customer

Source§

fn clone(&self) -> Customer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Customer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Customer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Customer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,