Skip to main content

SettlementResult

Struct SettlementResult 

Source
pub struct SettlementResult {
Show 13 fields pub settlement_type: SettlementType, pub status: SettlementStatus, pub korrektur_grund: Option<KorrekturGrund>, pub period: SettlementPeriod, pub regime: RegulatoryRegime, pub sparte: Sparte, pub malo_id: String, pub sender_mp_id: String, pub recipient_mp_id: String, pub positions: Vec<SettlementPosition>, pub total_eur: Decimal, pub steuer: Steuerausweis, pub warnings: Vec<SettlementWarning>,
}
Expand description

What a settlement calculation produced.

This is the canonical output of every calculation in this crate. It answers what is owed and why, and deliberately not what the invoice looks like: invoice numbers, issue and due dates, Prüfidentifikatoren and position numbering live on InvoiceDocument, which an adapter builds around this.

The separation is what makes a settlement recomputable. The same period can be settled twice — for a correction, a dispute, or an audit — and the two results compared, without inventing a document each time.

§Explainability

Every position carries a CalculationTrace; Self::all_legal_refs collects the paragraphs the settlement rests on. warnings records what the engine could not do, which is as much part of the result as the amounts.

Fields§

§settlement_type: SettlementType

What was settled.

§status: SettlementStatus

Where this settlement sits in the correction lifecycle.

§korrektur_grund: Option<KorrekturGrund>

Why this settlement was recalculated.

None for an Initial settlement and required for every other status — see SettlementResult::lineage_is_consistent.

§period: SettlementPeriod

The delivery period.

§regime: RegulatoryRegime

The rules the calculation applied.

§sparte: Sparte

Commodity.

§malo_id: String

The metering location settled.

§sender_mp_id: String

Sender MP-ID — the party issuing the invoice.

The Netzbetreiber for NNE/MMM, and the Messstellenbetreiber for a MSB-Rechnung (PID 31009). Named for the role it plays, not for one of the roles that can fill it.

§recipient_mp_id: String

Recipient MP-ID — the party being billed (LF, NB, MSB, MGV or ESA).

§positions: Vec<SettlementPosition>

The positions, in calculation order.

§total_eur: Decimal

Net total in EUR, rounded to 2 decimal places.

§steuer: Steuerausweis

The Umsatzsteuer on that net total.

§14 Abs. 4 Nr. 8 UStG requires the rate and the amount on every invoice, or a note saying why neither is stated. A settlement that carries only a net figure cannot be rendered as a lawful Rechnung, and the recipient gets no Vorsteuerabzug from one.

§warnings: Vec<SettlementWarning>

What the engine could not do, or did with a caveat.

Implementations§

Source§

impl SettlementResult

Source

pub const fn lineage_is_consistent(&self) -> bool

Whether the lifecycle status and the recorded reason agree.

An Initial settlement corrects nothing and must carry no reason; every other status is a recalculation and must say why. A Correction with no reason is the state this check exists to catch — it looks like a complete settlement and answers none of the questions an audit asks of one.

Source

pub fn corrects_a_defect(&self) -> bool

Whether this settlement records a defect in an earlier one.

Distinguishes an engineering signal from a lawful recalculation — see KorrekturGrund::indicates_defect.

Source§

impl SettlementResult

Source

pub fn positions_count(&self) -> usize

Number of billing positions.

Source

pub fn is_clean(&self) -> bool

true when the settlement has no warnings at Warning or Error severity.

All legal references cited across all positions (deduplicated by citation string).

Source

pub fn recomputed_total(&self) -> Decimal

Net total as computed from positions (re-summed for verification).

Should equal total_eur. A mismatch indicates a calculation bug.

Trait Implementations§

Source§

impl Clone for SettlementResult

Source§

fn clone(&self) -> SettlementResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SettlementResult

Source§

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

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

impl Serialize for SettlementResult

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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.