pub fn macrs_into(
slice: &mut [DepreciationPeriod],
cost: Decimal,
rates: &[Decimal],
)
Expand description
MACRS Deprectiation Into
Calculates the depreciation schedule for an asset using the Modified Accelerated Cost Recovery
System (MACRS method). MACRS is a depreciation method allowed by the IRS for tax purposes.
Mutates 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, in this case, that is as long as the number of rates provided. If the length of the slice is not equal to the number of rates, this will panic.
cost
- The initial cost of the assetrates
- A slice representing the MACRS depreciation rates for all periods of the asset’s life, starting with the first year (period 1) and ending with the last year (period 2). Rates for each period can be found in IRS Publication 946 or other tax resources. The rates should be in decimal form (e.g., 0.20 for 20%).
§Returns
- A vector of
DepreciationPeriod
instances representing each period in the depreciation schedule. The length of the vector will be equal to the number of rates provided.
§Examples
- $10,000 asset, MACRS rates for 5 year life
use rust_finprim::amort_dep_tax::{DepreciationPeriod, macrs_into};
use rust_decimal_macros::*;
use rust_decimal::Decimal;
let cost = dec!(10_000);
let rates = vec![
dec!(0.20),
dec!(0.32),
dec!(0.1920),
dec!(0.1152),
dec!(0.1152),
dec!(0.0576)
];
let life = rates.len() as u32;
let mut schedule = vec![DepreciationPeriod::default(); life as usize];
macrs_into(&mut schedule, cost, &rates);