Function rust_finprim::amort_dep_tax::db
source · pub fn db(
cost: Decimal,
salvage: Decimal,
life: u32,
factor: Option<Decimal>,
round: Option<(u32, RoundingStrategy)>
) -> Vec<DepreciationPeriod>
Expand description
Declining Balance Depreciation - DB
Calculates the depreciation schedule for an asset using the declining balance method given a declining balance factor (e.g., double-declining balance).
§Arguments
cost
- The initial cost of the assertsalvage
- The estimated salvage value of the asset at the end of its useful lifelife
- The number of periods over which the asset will be depreciatedfactor
(optional) - The factor by which the straight-line depreciation rate is multiplied (default is 2 for double-declining balance)round
(optional) - A tuple specifying the number of decimal places and a rounding strategy for the amounts(dp, RoundingStrategy)
, default is no rounding of calculations. The final depreciation expense is adjusted to ensure the remaining book value is equal to the salvage value.rust_decimal::RoundingStrategy::MidpointNearestEven
(“Bankers Rounding”) is likely what you are looking for as the rounding strategy.
If rounding is enabled, the final period will be adjusted to “zero” out the remaining book value to the salvage value.
§Returns
- A vector of
DepreciationPeriod
instances representing each period in the depreciation schedule.
§Examples
- $10,000 asset, $1,000 salvage value, 5 year life
use rust_finprim::amort_dep_tax::db;
use rust_decimal_macros::*;
let cost = dec!(10_000);
let salvage = dec!(1_000);
let life = 5;
let schedule = db(cost, salvage, life, None, None);