pub struct IncomeExpectation {
pub id: IncomeId,
pub period: BudgetPeriod,
pub expected_amount: Money,
pub notes: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Expected income for a budget period
Fields§
§id: IncomeId§period: BudgetPeriod§expected_amount: Money§notes: String§created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Source§impl IncomeExpectation
impl IncomeExpectation
Sourcepub fn new(period: BudgetPeriod, expected_amount: Money) -> Self
pub fn new(period: BudgetPeriod, expected_amount: Money) -> Self
Create a new income expectation
Sourcepub fn set_expected_amount(&mut self, amount: Money)
pub fn set_expected_amount(&mut self, amount: Money)
Set the expected amount
Sourcepub fn validate(&self) -> Result<(), IncomeValidationError>
pub fn validate(&self) -> Result<(), IncomeValidationError>
Validate the income expectation
Sourcepub fn is_over_budget(&self, total_budgeted: Money) -> bool
pub fn is_over_budget(&self, total_budgeted: Money) -> bool
Check if a budgeted amount exceeds expected income
Sourcepub fn budget_difference(&self, total_budgeted: Money) -> Money
pub fn budget_difference(&self, total_budgeted: Money) -> Money
Get the difference between expected income and budgeted amount Positive = under budget (good), Negative = over budget (warning)
Trait Implementations§
Source§impl Clone for IncomeExpectation
impl Clone for IncomeExpectation
Source§fn clone(&self) -> IncomeExpectation
fn clone(&self) -> IncomeExpectation
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 IncomeExpectation
impl Debug for IncomeExpectation
Source§impl<'de> Deserialize<'de> for IncomeExpectation
impl<'de> Deserialize<'de> for IncomeExpectation
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
Auto Trait Implementations§
impl Freeze for IncomeExpectation
impl RefUnwindSafe for IncomeExpectation
impl Send for IncomeExpectation
impl Sync for IncomeExpectation
impl Unpin for IncomeExpectation
impl UnwindSafe for IncomeExpectation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more