Functional Weave
Code in Python

finance.depreciation-straight-line@1.0.0

README.md

1,222 bytes · view raw

# finance.depreciation-straight-line

The depreciable amount (cost less residual value) is split with money.allocate
rather than divided by the number of years, so the charges add up to it exactly
and the final closing value is the residual value to the penny. Dividing and
rounding each year instead leaves 1000.00 over three years as 333.33 three
times, a penny short, and an asset that never finishes writing down.

The odd minor units land in the earliest years, because that is money.allocate's
largest-remainder rule and this capability does not invent a second, conflicting
one. For 1000.00 over three years the charges are 333.34, 333.33, 333.33. An
accounting policy that wants the difference in the final year should adjust the
last charge itself, where the choice is visible.

The schedule is returned whole - opening value, charge and closing value for
every year - because the closing value is the number that has to agree with the
balance sheet, and recomputing it from the charges in caller code is where it
stops agreeing.

A full year is charged in each of the `years` years: this is the simple
convention, not a mid-month or mid-year one. Pro-rating the first and last
period is finance.proration's job.