pub fn sln_into(
slice: &mut [DepreciationPeriod],
cost: Decimal,
salvage: Decimal,
)
Expand description
Straight Line Depreciation (SLN) Into
Calculates the depreciation schedule for an asset using the straight-line method, mutating a
“slice” of DepreciationPeriod
.
§Arguments
slice
- A mutable slice ofDepreciationPeriod
instances to be filled with the depreciation schedule.
Warning: The length of the slice should be as long as the life as the asset or there will be unexpected behavior.
cost
- The initial cost of the assetsalvage
- The estimated salvage value of the asset at the end of its useful life
§Examples
- $10,000 asset, $1,000 salvage value, 5 year life
use rust_finprim::amort_dep_tax::{DepreciationPeriod, sln_into};
use rust_decimal_macros::*;
let life = 5;
let cost = dec!(10_000);
let salvage = dec!(1_000);
let mut schedule = vec![DepreciationPeriod::default(); life as usize];
sln_into(&mut schedule, cost, salvage);