pub struct GridSettlement {Show 14 fields
pub pid: u32,
pub settlement_type: SettlementType,
pub status: SettlementStatus,
pub rechnungsnummer: String,
pub correction_of: Option<String>,
pub invoice_date: Date,
pub due_date: Date,
pub period_from: Date,
pub period_to: Date,
pub nb_mp_id: String,
pub counterparty_mp_id: String,
pub positions: Vec<InvoicePosition>,
pub total_eur: Decimal,
pub warnings: Vec<SettlementWarning>,
}Expand description
Result of a grid settlement calculation — pure domain type, no BO4E coupling.
This is the canonical output of all calculation functions in grid-billing.
The service layer (netzbilanzd, invoicd) converts it to rubo4e::current::Rechnung
via a local into_rechnung() adapter.
§Explainability
Every settlement carries a full CalculationTrace per position, applied
LegalReferences, and the TariffSource for each rate. The warnings
field surfaces any non-blocking validation issues.
§Immutable correction chain
When correcting a prior settlement, set status = SettlementStatus::Correction
and populate correction_of with the original settlement’s rechnungsnummer.
The original settlement is never mutated.
§PID override
pid defaults to SettlementType::default_pid(). Override after construction:
31005for Gas NNE (NneStrom → NneGas)31006for selbstausstellt NNE31011for GeLi Gas AWH Sperrprozesse
Fields§
§pid: u32BDEW Prüfidentifikator — caller may override after construction.
settlement_type: SettlementTypeSettlement type.
status: SettlementStatusLifecycle status.
rechnungsnummer: StringUnique invoice reference number.
correction_of: Option<String>If this is a correction, the rechnungsnummer of the original settlement.
invoice_date: DateInvoice issue date.
due_date: DatePayment due date (Zahlungsziel, §271 BGB).
period_from: DateStart of billing period (inclusive).
period_to: DateEnd of billing period (inclusive).
nb_mp_id: StringSender MP-ID — Netzbetreiber (or MSB for PID 31009).
counterparty_mp_id: StringRecipient MP-ID — Lieferant (NNE/MMM), MSB (PID 31009), or MGV (GaBi Gas).
Maps to rechnungsempfaenger in the BO4E Rechnung built by the service layer.
Previously omitted, causing service-layer code to pass recipient IDs separately.
positions: Vec<InvoicePosition>Ordered billing positions (each with full calculation trace).
total_eur: DecimalNet total in EUR, rounded to 2 decimal places.
warnings: Vec<SettlementWarning>Non-blocking validation warnings.
Empty when the settlement is clean. The service layer should review
Warning and Error severity items before dispatch.
Implementations§
Source§impl GridSettlement
impl GridSettlement
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 GridSettlement
impl Clone for GridSettlement
Source§fn clone(&self) -> GridSettlement
fn clone(&self) -> GridSettlement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more