use crate::FloatLike;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AmortizationPeriod<T> {
pub period: u32,
pub principal_payment: T,
pub interest_payment: T,
pub remaining_balance: T,
}
impl<T: FloatLike> AmortizationPeriod<T> {
pub fn new(period: u32, principal_payment: T, interest_payment: T, remaining_balance: T) -> Self {
Self {
period,
principal_payment,
interest_payment,
remaining_balance,
}
}
pub fn default() -> Self {
Self {
period: 0,
principal_payment: T::zero(),
interest_payment: T::zero(),
remaining_balance: T::zero(),
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct DepreciationPeriod<T> {
pub period: u32,
pub depreciation_expense: T,
pub remaining_book_value: T,
}
impl<T: FloatLike> DepreciationPeriod<T> {
pub fn new(period: u32, depreciation_expense: T, remaining_book_value: T) -> Self {
Self {
period,
depreciation_expense,
remaining_book_value,
}
}
pub fn default() -> Self {
Self {
period: 0,
depreciation_expense: T::zero(),
remaining_book_value: T::zero(),
}
}
}