Skip to main content

CostBreakdown

Struct CostBreakdown 

Source
pub struct CostBreakdown {
    pub dimensions: Vec<DimensionCost>,
    pub total_excl_vat: Number,
    pub total_incl_vat: Number,
    pub taxes: Vec<TaxLine>,
    pub limit_applied: Option<PriceLimitApplied>,
    pub notes: Vec<PricingNote>,
}
Available on crate feature tariffs only.
Expand description

The complete, auditable result of pricing a session.

for dimension in &breakdown.dimensions {
    println!(
        "{:>12} {:>8} billed (measured {:>8}) = {}",
        dimension.dimension, dimension.billed, dimension.measured, dimension.cost,
    );
    for segment in &dimension.segments {
        println!("             via {}", segment.applied);
    }
}
println!("total {} ({} incl. VAT)", breakdown.total_excl_vat, breakdown.total_incl_vat);

Fields§

§dimensions: Vec<DimensionCost>

What each dimension cost.

§total_excl_vat: Number

The total excluding VAT, after any min_price/max_price clamp.

§total_incl_vat: Number

The total including VAT, after any clamp.

§taxes: Vec<TaxLine>

The VAT owed, grouped by percentage.

§limit_applied: Option<PriceLimitApplied>

Whether a min_price or max_price changed the total.

§notes: Vec<PricingNote>

Anything the reader of this breakdown should know: see PricingNoteCode.

Empty is the ordinary case. A note is never an error — the total beside it is the engine’s best answer — but every one of them is a reason to look, and most of them are defects in the input rather than in the tariff.

Implementations§

Source§

impl CostBreakdown

Source

pub fn dimension( &self, dimension: TariffDimensionType, ) -> Option<&DimensionCost>

The cost of one dimension, if it was priced.

Source

pub fn dimension_total(&self, dimension: TariffDimensionType) -> Number

The total for one dimension, or zero if it was not priced.

Source

pub fn total_vat(&self) -> Number

The total VAT across all dimensions.

Always equal to total_incl_vat - total_excl_vat; see TaxLine.

Source

pub fn notes_with( &self, code: PricingNoteCode, ) -> impl Iterator<Item = &PricingNote>

The notes carrying code.

Source

pub fn needs_review(&self) -> bool

Whether anything about this session needs a human’s attention.

True when the breakdown carries any note at all. A reconciliation pipeline can use this to split a month’s CDRs into the ones that priced cleanly and the ones that did not.

Source

pub fn applied_components(&self) -> impl Iterator<Item = &AppliedComponent>

Every Price Component that contributed, in the order they were applied.

Source

pub fn to_price_v2_3_0(&self) -> Price

Available on crate feature v2_3_0 only.

The result as an OCPI 2.3.0 Price.

The VAT lines become TaxAmounts named VAT, one per distinct percentage, which is what a Tariff’s per-component vat fields describe.

Source

pub fn to_price_v2_2_1(&self) -> Price

Available on crate feature v2_2_1 only.

The result as an OCPI 2.2.1 Price.

Trait Implementations§

Source§

impl Clone for CostBreakdown

Source§

fn clone(&self) -> CostBreakdown

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 CostBreakdown

Source§

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

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

impl<'de> Deserialize<'de> for CostBreakdown

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for CostBreakdown

Source§

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

The whole breakdown, including its notes.

The notes are the part somebody has to act on, so they are not something the default rendering may quietly leave out. An engine that records a finding and then prints a total as if nothing happened is worse than one that never looked.

Source§

impl PartialEq for CostBreakdown

Source§

fn eq(&self, other: &CostBreakdown) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CostBreakdown

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
Source§

impl StructuralPartialEq for CostBreakdown

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more