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: SettlementTypeWhat was settled.
status: SettlementStatusWhere 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: SettlementPeriodThe delivery period.
regime: RegulatoryRegimeThe rules the calculation applied.
sparte: SparteCommodity.
malo_id: StringThe metering location settled.
sender_mp_id: StringSender 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: StringRecipient MP-ID — the party being billed (LF, NB, MSB, MGV or ESA).
positions: Vec<SettlementPosition>The positions, in calculation order.
total_eur: DecimalNet total in EUR, rounded to 2 decimal places.
steuer: SteuerausweisThe 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
impl SettlementResult
Sourcepub const fn lineage_is_consistent(&self) -> bool
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.
Sourcepub fn corrects_a_defect(&self) -> bool
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
impl SettlementResult
Sourcepub fn positions_count(&self) -> usize
pub fn positions_count(&self) -> usize
Number of billing positions.
Sourcepub fn is_clean(&self) -> bool
pub fn is_clean(&self) -> bool
true when the settlement has no warnings at Warning or Error severity.
Sourcepub fn all_legal_refs(&self) -> Vec<String>
pub fn all_legal_refs(&self) -> Vec<String>
All legal references cited across all positions (deduplicated by citation string).
Sourcepub fn recomputed_total(&self) -> Decimal
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
impl Clone for SettlementResult
Source§fn clone(&self) -> SettlementResult
fn clone(&self) -> SettlementResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more