use crate::{test::ApproxEq, Money};
use super::Price;
impl ApproxEq for Price {
type Tolerance = <Money as ApproxEq>::Tolerance;
fn default_tolerance() -> Self::Tolerance {
Money::default_tolerance()
}
fn approx_eq_tolerance(&self, other: &Self, tolerance: Self::Tolerance) -> bool {
let incl_eq = match (self.incl_vat, other.incl_vat) {
(Some(a), Some(b)) => a.approx_eq_tolerance(&b, tolerance),
(None, None) => true,
_ => return false,
};
incl_eq
&& self
.excl_vat
.approx_eq_tolerance(&other.excl_vat, tolerance)
}
}