pub struct CashAmount {
pub amount: f64,
pub currency: Currency,
}Expand description
Container for an amount of money in some currency
Fields§
§amount: f64§currency: CurrencyImplementations§
Source§impl CashAmount
impl CashAmount
pub async fn add( &mut self, cash_amount: CashAmount, time: DateTime<Utc>, currency_converter: &(dyn CurrencyConverter + Send + Sync), with_rounding: bool, ) -> Result<&mut Self, CurrencyError>
pub async fn add_opt( &mut self, cash_amount: Option<CashAmount>, time: DateTime<Utc>, currency_converter: &(dyn CurrencyConverter + Send + Sync), with_rounding: bool, ) -> Result<&mut Self, CurrencyError>
pub async fn sub( &mut self, cash_amount: CashAmount, time: DateTime<Utc>, currency_converter: &(dyn CurrencyConverter + Send + Sync), with_rounding: bool, ) -> Result<&mut Self, CurrencyError>
pub async fn sub_opt( &mut self, cash_amount: Option<CashAmount>, time: DateTime<Utc>, currency_converter: &(dyn CurrencyConverter + Send + Sync), with_rounding: bool, ) -> Result<&mut Self, CurrencyError>
Sourcepub fn round(&self, digits: i32) -> CashAmount
pub fn round(&self, digits: i32) -> CashAmount
Round a cash amount to that number of decimals
Sourcepub fn round_by_convention(
&self,
rounding_conventions: &BTreeMap<String, i32>,
) -> CashAmount
pub fn round_by_convention( &self, rounding_conventions: &BTreeMap<String, i32>, ) -> CashAmount
Round Cash amount according to rounding conventions Lookup currency in rounding_conventions. If found, use the number of digits found for rounding to that number of decimals, otherwise round to two decimals.
Trait Implementations§
Source§impl Clone for CashAmount
impl Clone for CashAmount
Source§fn clone(&self) -> CashAmount
fn clone(&self) -> CashAmount
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CashAmount
impl Debug for CashAmount
Source§impl<'de> Deserialize<'de> for CashAmount
impl<'de> Deserialize<'de> for CashAmount
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 CashAmount
impl Display for CashAmount
Source§impl Neg for CashAmount
impl Neg for CashAmount
Source§impl PartialEq for CashAmount
impl PartialEq for CashAmount
Source§impl Serialize for CashAmount
impl Serialize for CashAmount
impl Copy for CashAmount
impl StructuralPartialEq for CashAmount
Auto Trait Implementations§
impl Freeze for CashAmount
impl RefUnwindSafe for CashAmount
impl Send for CashAmount
impl Sync for CashAmount
impl Unpin for CashAmount
impl UnwindSafe for CashAmount
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
Mutably borrows from an owned value. Read more