Skip to main content

CalculationTrace

Struct CalculationTrace 

Source
pub struct CalculationTrace {
    pub explanation: String,
    pub input_quantity: Decimal,
    pub input_unit_price_eur: Decimal,
    pub gross_eur: Decimal,
    pub legal_refs: Vec<LegalReference>,
    pub tariff_source: Option<TariffSource>,
    pub regulatory_reduction_factor: Option<Decimal>,
    pub rounding_note: Option<&'static str>,
}
Expand description

Full audit record for how one InvoicePosition was computed.

Answers the question: “Why is this amount on the invoice?”

Every CalculationTrace carries the input values, the applied legal rules, intermediate results, and the tariff source. This enables:

  • Regulator audits (BNetzA §20 EnWG)
  • Operator review
  • LF dispute resolution
  • AI-assisted invoice explainability (MCP tools)

Fields§

§explanation: String

Human-readable explanation of this position.

Example: "Arbeit 1500 kWh × 3.5 ct/kWh = 52.50 EUR"

§input_quantity: Decimal

Input quantity used (before rounding).

§input_unit_price_eur: Decimal

Input unit price in EUR (before rounding, already converted from ct).

§gross_eur: Decimal

Intermediate result before rounding (qty × price).

§legal_refs: Vec<LegalReference>

Applied legal references (at least one required).

§tariff_source: Option<TariffSource>

Source of the tariff rate.

§regulatory_reduction_factor: Option<Decimal>

Any §14a reductions applied, expressed as a fraction (0.0–1.0).

None when no regulatory reduction applies. Example: Some(Decimal::new(85, 2)) = 85% of full rate (15% reduction).

§rounding_note: Option<&'static str>

Notes on rounding applied.

Example: "rounded to 5 dp per StromNEV §17".

Trait Implementations§

Source§

impl Clone for CalculationTrace

Source§

fn clone(&self) -> CalculationTrace

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 CalculationTrace

Source§

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

Formats the value using the given formatter. 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 = 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.