#[non_exhaustive]pub struct PricingPolicy {
pub component_decimals: u32,
pub currency_decimals: u32,
pub rounding: RoundingStrategy,
pub quantity_decimals: u32,
pub quantisation: Quantisation,
}tariffs only.Expand description
How and when to round money.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.component_decimals: u32Decimal places each dimension’s cost is rounded to before the totals are summed.
Default 4, which is the precision the specification names for OCPI numbers:
“Unless mentioned otherwise, numbers use 4 decimals.”
currency_decimals: u32Decimal places the final total is rounded to.
Default 2: the minor unit of the great majority of currencies. Set to 0 for JPY, 3 for KWD and the other three-decimal currencies.
rounding: RoundingStrategyHow a value exactly halfway between two representable amounts is resolved.
Default RoundingStrategy::MidpointAwayFromZero — “round half up” — which is what
invoicing legislation in most of Europe assumes.
quantity_decimals: u32Decimal places the quantities in a CostBreakdown are reported to.
Default 6, which resolves a second of time (1/3600 h ≈ 0.000278) and a tenth of a watt hour, and is comfortably inside what a JSON number carries exactly.
This exists because a measured quantity is not always a short decimal. Summing
PARKING_TIME volumes, or converting seconds to hours, produces values like
0.13333333333333333333333333333 — exact as a Decimal, but
with more significant digits than a JSON number preserves, so a breakdown carrying one
would fail Number::json_round_trips and be
reported as Imprecise by the crate’s own
validator. An auditable artefact that does not survive being written down is not
auditable.
Money is not rounded to this: costs are computed from the exact quantity and then
rounded by component_decimals. This setting decides what the
breakdown says was measured, never what was charged.
quantisation: QuantisationWhether to apply step_size block billing.
Default Quantisation::StepSize. OCPI 3.0 removes step_size in favour of
full-precision metering, so this is a pluggable stage rather than a hard-wired one:
NOTE: The
step_sizefield is no longer present in OCPI 3.0. In OCPI 3.0, Parties are advised to measure quantities as precise as required by calibration law and use the full precision of such measurements in cost computation.
Implementations§
Source§impl PricingPolicy
impl PricingPolicy
Sourcepub fn zero_decimal_currency() -> Self
pub fn zero_decimal_currency() -> Self
A policy for a currency with no minor unit, such as JPY.
Sourcepub fn without_step_size(self) -> Self
pub fn without_step_size(self) -> Self
A policy that ignores step_size, as OCPI 3.0 will.
Sourcepub fn round_component(&self, value: Number) -> Number
pub fn round_component(&self, value: Number) -> Number
Rounds an intermediate per-dimension cost.
Sourcepub fn round_currency(&self, value: Number) -> Number
pub fn round_currency(&self, value: Number) -> Number
Rounds a final, presentable amount.
Sourcepub fn round_quantity(&self, value: Number) -> Number
pub fn round_quantity(&self, value: Number) -> Number
Rounds a quantity for reporting. See quantity_decimals.
Trait Implementations§
Source§impl Clone for PricingPolicy
impl Clone for PricingPolicy
Source§fn clone(&self) -> PricingPolicy
fn clone(&self) -> PricingPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PricingPolicy
Source§impl Debug for PricingPolicy
impl Debug for PricingPolicy
Source§impl Default for PricingPolicy
impl Default for PricingPolicy
impl Eq for PricingPolicy
Source§impl PartialEq for PricingPolicy
impl PartialEq for PricingPolicy
impl StructuralPartialEq for PricingPolicy
Auto Trait Implementations§
impl Freeze for PricingPolicy
impl RefUnwindSafe for PricingPolicy
impl Send for PricingPolicy
impl Sync for PricingPolicy
impl Unpin for PricingPolicy
impl UnsafeUnpin for PricingPolicy
impl UnwindSafe for PricingPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.