pub struct BillingEngine { /* private fields */ }Expand description
The composition root for multi-product invoice generation.
Implementations§
Source§impl BillingEngine
impl BillingEngine
Sourcepub fn add<P: BillingProvider + 'static>(self, provider: P) -> Self
pub fn add<P: BillingProvider + 'static>(self, provider: P) -> Self
Register a BillingProvider. Returns self for method chaining.
Providers run in registration order. Register tax providers (e.g.
MwStProvider) last — they will automatically run in a second pass.
Sourcepub fn validate(
&self,
ctx: &BillingContext,
quantities: &Quantities,
) -> Vec<BillingWarning>
pub fn validate( &self, ctx: &BillingContext, quantities: &Quantities, ) -> Vec<BillingWarning>
Run all registered providers and collect regulatory compliance warnings.
Does NOT generate positions or produce an invoice. Call this before bill()
to check regulatory preconditions (e.g. §41a iMSys guard, missing tariff
fields) without committing to billing.
An Error-severity warning indicates a definite regulatory violation.
The operator should resolve the issue before calling bill().
Sourcepub fn bill_batch(
&self,
batch: Vec<(BillingContext, Quantities)>,
) -> Vec<Result<Invoice, EngineError>>
pub fn bill_batch( &self, batch: Vec<(BillingContext, Quantities)>, ) -> Vec<Result<Invoice, EngineError>>
Bill multiple (context, quantities) pairs using this engine configuration.
Reuses the same provider set for every item in the batch. Fails fast per item (each error is independent). For large portfolios, collect all results and handle errors individually.
§Example
let results = engine.bill_batch(batch);
let errors: Vec<_> = results.iter().filter_map(|r| r.as_ref().err()).collect();Sourcepub fn bill(
&self,
ctx: BillingContext,
quantities: &Quantities,
) -> Result<Invoice, EngineError>
pub fn bill( &self, ctx: BillingContext, quantities: &Quantities, ) -> Result<Invoice, EngineError>
Run all providers and assemble an Invoice.
Three-pass execution:
- Commodity + levy providers (all
is_tax_pass() == false) - Tax providers (all
is_tax_pass() == true) - Abschlag deductions from
ctx.abschlage(on every settling document — everyInvoiceTypeexceptAdvancePayment)