pub struct BudgetAllocation {
pub category_id: CategoryId,
pub period: BudgetPeriod,
pub budgeted: Money,
pub carryover: Money,
pub notes: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
A budget allocation for a specific category in a specific period
Fields§
§category_id: CategoryIdThe category this allocation is for
period: BudgetPeriodThe budget period
budgeted: MoneyAmount budgeted/assigned to this category this period
carryover: MoneyAmount carried over from the previous period (positive or negative)
notes: StringNotes for this period’s allocation
created_at: DateTime<Utc>When this allocation was created
updated_at: DateTime<Utc>When this allocation was last modified
Implementations§
Source§impl BudgetAllocation
impl BudgetAllocation
Sourcepub fn new(category_id: CategoryId, period: BudgetPeriod) -> Self
pub fn new(category_id: CategoryId, period: BudgetPeriod) -> Self
Create a new budget allocation
Sourcepub fn with_budget(
category_id: CategoryId,
period: BudgetPeriod,
budgeted: Money,
) -> Self
pub fn with_budget( category_id: CategoryId, period: BudgetPeriod, budgeted: Money, ) -> Self
Create an allocation with an initial budget amount
Sourcepub fn set_budgeted(&mut self, amount: Money)
pub fn set_budgeted(&mut self, amount: Money)
Set the budgeted amount
Sourcepub fn add_budgeted(&mut self, amount: Money)
pub fn add_budgeted(&mut self, amount: Money)
Add to the budgeted amount
Sourcepub fn set_carryover(&mut self, amount: Money)
pub fn set_carryover(&mut self, amount: Money)
Set the carryover amount
Sourcepub fn total_budgeted(&self) -> Money
pub fn total_budgeted(&self) -> Money
Get the total available in this category (budgeted + carryover) Note: Activity (spending) must be subtracted by the caller who has transaction data
Sourcepub fn validate(&self) -> Result<(), BudgetValidationError>
pub fn validate(&self) -> Result<(), BudgetValidationError>
Validate the allocation
Trait Implementations§
Source§impl Clone for BudgetAllocation
impl Clone for BudgetAllocation
Source§fn clone(&self) -> BudgetAllocation
fn clone(&self) -> BudgetAllocation
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 BudgetAllocation
impl Debug for BudgetAllocation
Source§impl<'de> Deserialize<'de> for BudgetAllocation
impl<'de> Deserialize<'de> for BudgetAllocation
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 BudgetAllocation
impl Display for BudgetAllocation
Auto Trait Implementations§
impl Freeze for BudgetAllocation
impl RefUnwindSafe for BudgetAllocation
impl Send for BudgetAllocation
impl Sync for BudgetAllocation
impl Unpin for BudgetAllocation
impl UnwindSafe for BudgetAllocation
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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more