Function db

Source
pub fn db<T: FloatLike>(
    cost: T,
    salvage: T,
    life: u32,
    factor: Option<T>,
    round: Option<(u32, RoundingMode, T)>,
) -> Vec<DepreciationPeriod<T>>
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).

§Feature

This function requires the std feature to be enabled as it uses the std::Vec. sln_into can be used in a no_std environment as any allocation is done by the caller.

§Arguments

  • cost - The initial cost of the assert
  • salvage - The estimated salvage value of the asset at the end of its useful life
  • life - The number of periods over which the asset will be depreciated
  • factor (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, RoundingMode), default is no rounding of calculations. The final depreciation expense is adjusted to ensure the remaining book value is equal to the salvage value.

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;

let cost = 10_000.0;
let salvage = 1_000.0;
let life = 5;
let schedule = db(cost, salvage, life, None, None);