From 6d242b2960b95bba75a466bdb0a57835d2f8477f Mon Sep 17 00:00:00 2001 From: Michael Roberts Date: Wed, 25 Jun 2025 15:46:10 -0400 Subject: [PATCH 1/9] Expand depreciation --- ...t_line_depreciation.py => depreciation.py} | 99 ++++++++++++++++--- 1 file changed, 88 insertions(+), 11 deletions(-) rename financial/{straight_line_depreciation.py => depreciation.py} (51%) diff --git a/financial/straight_line_depreciation.py b/financial/depreciation.py similarity index 51% rename from financial/straight_line_depreciation.py rename to financial/depreciation.py index e11e1c1364ce..2a2fd4012868 100644 --- a/financial/straight_line_depreciation.py +++ b/financial/depreciation.py @@ -35,7 +35,7 @@ def straight_line_depreciation( residual_value: float = 0.0, ) -> list[float]: """ - Calculate the depreciation expenses over the given period + Calculate the depreciation expenses over the given period using the straight-line method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life @@ -89,15 +89,92 @@ def straight_line_depreciation( return list_of_depreciation_expenses +def declining_balance_depreciation(useful_years: int, + purchase_value: float, + residual_value: float = 0.0,): + """ + Calculate the depreciation expenses over the given period using the declining balance method + :param useful_years: Number of years the asset will be used + :param purchase_value: Purchase expenditure for the asset + :param residual_value: Residual value of the asset at the end of its useful life + :return: A list of annual depreciation expenses over the asset's useful life + """ + + if not isinstance(useful_years, int): + raise TypeError("Useful years must be an integer") + + if useful_years < 1: + raise ValueError("Useful years cannot be less than 1") + + if not isinstance(purchase_value, (float, int)): + raise TypeError("Purchase value must be numeric") + + if not isinstance(residual_value, (float, int)): + raise TypeError("Residual value must be numeric") + + if purchase_value < 0.0: + raise ValueError("Purchase value cannot be less than zero") + + if purchase_value < residual_value: + raise ValueError("Purchase value cannot be less than residual value") + + depreciation_rate = 1 - (residual_value / purchase_value) ** (1 / useful_years) + book_value = purchase_value + + list_of_depreciation_expenses = [] + + for i in range(1, useful_years+1): + new_book_value = purchase_value * ((1 - depreciation_rate) ** i) + list_of_depreciation_expenses.append(book_value - new_book_value) + book_value = new_book_value + + return list_of_depreciation_expenses + +def sum_of_years_digits_depreciation(useful_years: int, + purchase_value: float, + residual_value: float = 0.0,): + """ + Calculate the depreciation expenses over the given period using the sum of years' digits method + :param useful_years: Number of years the asset will be used + :param purchase_value: Purchase expenditure for the asset + :param residual_value: Residual value of the asset at the end of its useful life + :return: A list of annual depreciation expenses over the asset's useful life + """ + + if not isinstance(useful_years, int): + raise TypeError("Useful years must be an integer") + + if useful_years < 1: + raise ValueError("Useful years cannot be less than 1") + + if not isinstance(purchase_value, (float, int)): + raise TypeError("Purchase value must be numeric") + + if not isinstance(residual_value, (float, int)): + raise TypeError("Residual value must be numeric") + + if purchase_value < 0.0: + raise ValueError("Purchase value cannot be less than zero") + + if purchase_value < residual_value: + raise ValueError("Purchase value cannot be less than residual value") + + digits_sum = useful_years * (useful_years + 1) // 2 + + list_of_depreciation_expenses = [] + + for i in range(1, useful_years+1): + depreciation_value = (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + list_of_depreciation_expenses.append(depreciation_value) + + + return list_of_depreciation_expenses + + + + if __name__ == "__main__": - user_input_useful_years = int(input("Please Enter Useful Years:\n > ")) - user_input_purchase_value = float(input("Please Enter Purchase Value:\n > ")) - user_input_residual_value = float(input("Please Enter Residual Value:\n > ")) - print( - straight_line_depreciation( - user_input_useful_years, - user_input_purchase_value, - user_input_residual_value, - ) - ) + import doctest + + doctest.testmod() From b439b9c375d72679ee98367da16d1ca7dca90045 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 19:47:37 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/depreciation.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index 2a2fd4012868..20a000e3c182 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -89,9 +89,12 @@ def straight_line_depreciation( return list_of_depreciation_expenses -def declining_balance_depreciation(useful_years: int, + +def declining_balance_depreciation( + useful_years: int, purchase_value: float, - residual_value: float = 0.0,): + residual_value: float = 0.0, +): """ Calculate the depreciation expenses over the given period using the declining balance method :param useful_years: Number of years the asset will be used @@ -123,16 +126,19 @@ def declining_balance_depreciation(useful_years: int, list_of_depreciation_expenses = [] - for i in range(1, useful_years+1): + for i in range(1, useful_years + 1): new_book_value = purchase_value * ((1 - depreciation_rate) ** i) list_of_depreciation_expenses.append(book_value - new_book_value) book_value = new_book_value - + return list_of_depreciation_expenses -def sum_of_years_digits_depreciation(useful_years: int, + +def sum_of_years_digits_depreciation( + useful_years: int, purchase_value: float, - residual_value: float = 0.0,): + residual_value: float = 0.0, +): """ Calculate the depreciation expenses over the given period using the sum of years' digits method :param useful_years: Number of years the asset will be used @@ -163,17 +169,15 @@ def sum_of_years_digits_depreciation(useful_years: int, list_of_depreciation_expenses = [] - for i in range(1, useful_years+1): - depreciation_value = (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + for i in range(1, useful_years + 1): + depreciation_value = ( + (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + ) list_of_depreciation_expenses.append(depreciation_value) - return list_of_depreciation_expenses - - - if __name__ == "__main__": import doctest From 873776866c4f4bafd07b89eab65950e6c26731d3 Mon Sep 17 00:00:00 2001 From: Michael Roberts Date: Wed, 25 Jun 2025 16:02:35 -0400 Subject: [PATCH 3/9] Add examples --- financial/depreciation.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index 2a2fd4012868..147006645a0e 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -98,6 +98,17 @@ def declining_balance_depreciation(useful_years: int, :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life :return: A list of annual depreciation expenses over the asset's useful life + + >>> declining_balance_depreciation(10,1100.0,100.0) + [234.52721358355052, 184.52447366421927, 145.1826458038188, 114.22875363922134, 89.87443427365002, 70.71261550765269, 55.636222162002895, 43.774214745666626, 34.44126509920373, 27.098161521014077] + >>> declining_balance_depreciation(6,1250.0,50.0) + [518.9955654467834, 303.51044788404226, 177.49398666917426, 103.79911308935672, 60.70208957680846, 35.49879733383485] + >>> declining_balance_depreciation(4,1001.0) + [1001.0, 0.0, 0.0, 0.0] + >>> declining_balance_depreciation(11,380.0,50.0) + [63.98359103909348, 53.21017019104619, 44.25075501045555, 36.799907084771036, 30.60361707111676, 25.45064517902371, 21.165319724245478, 17.601548246751307, 14.637837023922344, 12.173149187513005, 10.123460242061142] + >>> declining_balance_depreciation(1,4985,100) + [4885.0] """ if not isinstance(useful_years, int): @@ -139,6 +150,17 @@ def sum_of_years_digits_depreciation(useful_years: int, :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life :return: A list of annual depreciation expenses over the asset's useful life + + >>> declining_balance_depreciation(10,1100.0,100.0) + [234.52721358355052, 184.52447366421927, 145.1826458038188, 114.22875363922134, 89.87443427365002, 70.71261550765269, 55.636222162002895, 43.774214745666626, 34.44126509920373, 27.098161521014077] + >>> declining_balance_depreciation(6,1250.0,50.0) + [518.9955654467834, 303.51044788404226, 177.49398666917426, 103.79911308935672, 60.70208957680846, 35.49879733383485] + >>> declining_balance_depreciation(4,1001.0) + [1001.0, 0.0, 0.0, 0.0] + >>> declining_balance_depreciation(11,380.0,50.0) + [63.98359103909348, 53.21017019104619, 44.25075501045555, 36.799907084771036, 30.60361707111676, 25.45064517902371, 21.165319724245478, 17.601548246751307, 14.637837023922344, 12.173149187513005, 10.123460242061142] + >>> declining_balance_depreciation(1,4985,100) + [4885.0] """ if not isinstance(useful_years, int): @@ -171,10 +193,6 @@ def sum_of_years_digits_depreciation(useful_years: int, return list_of_depreciation_expenses - - - if __name__ == "__main__": import doctest - - doctest.testmod() + doctest.testmod() \ No newline at end of file From ef9c3c9d887c6f2621ab4e25a6dcabd4aa60bcec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 20:05:53 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/depreciation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index 1471909ecff2..8837333c8bcd 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -202,4 +202,5 @@ def sum_of_years_digits_depreciation( if __name__ == "__main__": import doctest - doctest.testmod() \ No newline at end of file + + doctest.testmod() From a8764d95418caed89cd1c5200adf82cf34d3f0ac Mon Sep 17 00:00:00 2001 From: Michael Roberts Date: Wed, 25 Jun 2025 21:33:09 -0400 Subject: [PATCH 5/9] Fix db depreciation --- financial/depreciation.py | 69 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index 1471909ecff2..83addb3e306f 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -89,27 +89,24 @@ def straight_line_depreciation( return list_of_depreciation_expenses - -def declining_balance_depreciation( - useful_years: int, +def declining_balance_depreciation(useful_years: int, purchase_value: float, - residual_value: float = 0.0, -): + residual_value: float = 0.0,): """ Calculate the depreciation expenses over the given period using the declining balance method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life - :return: A list of annual depreciation expenses over the asset's useful life + :return: A list of annual depreciation expenses over the asset's useful life, rounded to the nearest cent >>> declining_balance_depreciation(10,1100.0,100.0) - [234.52721358355052, 184.52447366421927, 145.1826458038188, 114.22875363922134, 89.87443427365002, 70.71261550765269, 55.636222162002895, 43.774214745666626, 34.44126509920373, 27.098161521014077] + [234.53, 184.52, 145.18, 114.23, 89.87, 70.71, 55.64, 43.77, 34.44, 27.1] >>> declining_balance_depreciation(6,1250.0,50.0) - [518.9955654467834, 303.51044788404226, 177.49398666917426, 103.79911308935672, 60.70208957680846, 35.49879733383485] + [519.0, 303.51, 177.49, 103.8, 60.7, 35.5] >>> declining_balance_depreciation(4,1001.0) [1001.0, 0.0, 0.0, 0.0] >>> declining_balance_depreciation(11,380.0,50.0) - [63.98359103909348, 53.21017019104619, 44.25075501045555, 36.799907084771036, 30.60361707111676, 25.45064517902371, 21.165319724245478, 17.601548246751307, 14.637837023922344, 12.173149187513005, 10.123460242061142] + [63.98, 53.21, 44.25, 36.8, 30.6, 25.45, 21.17, 17.6, 14.64, 12.17, 10.12] >>> declining_balance_depreciation(1,4985,100) [4885.0] """ @@ -132,40 +129,37 @@ def declining_balance_depreciation( if purchase_value < residual_value: raise ValueError("Purchase value cannot be less than residual value") - depreciation_rate = 1 - (residual_value / purchase_value) ** (1 / useful_years) + depreciation_rate = 1 - ((residual_value / purchase_value) ** (1 / useful_years)) book_value = purchase_value list_of_depreciation_expenses = [] - for i in range(1, useful_years + 1): - new_book_value = purchase_value * ((1 - depreciation_rate) ** i) - list_of_depreciation_expenses.append(book_value - new_book_value) + for i in range(1, useful_years+1): + new_book_value = book_value * (1 - depreciation_rate) + list_of_depreciation_expenses.append(round(book_value - new_book_value, 2)) book_value = new_book_value - + return list_of_depreciation_expenses - -def sum_of_years_digits_depreciation( - useful_years: int, +def sum_of_years_digits_depreciation(useful_years: int, purchase_value: float, - residual_value: float = 0.0, -): + residual_value: float = 0.0,): """ Calculate the depreciation expenses over the given period using the sum of years' digits method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life - :return: A list of annual depreciation expenses over the asset's useful life - - >>> declining_balance_depreciation(10,1100.0,100.0) - [234.52721358355052, 184.52447366421927, 145.1826458038188, 114.22875363922134, 89.87443427365002, 70.71261550765269, 55.636222162002895, 43.774214745666626, 34.44126509920373, 27.098161521014077] - >>> declining_balance_depreciation(6,1250.0,50.0) - [518.9955654467834, 303.51044788404226, 177.49398666917426, 103.79911308935672, 60.70208957680846, 35.49879733383485] - >>> declining_balance_depreciation(4,1001.0) - [1001.0, 0.0, 0.0, 0.0] - >>> declining_balance_depreciation(11,380.0,50.0) - [63.98359103909348, 53.21017019104619, 44.25075501045555, 36.799907084771036, 30.60361707111676, 25.45064517902371, 21.165319724245478, 17.601548246751307, 14.637837023922344, 12.173149187513005, 10.123460242061142] - >>> declining_balance_depreciation(1,4985,100) + :return: A list of annual depreciation expenses over the asset's useful life, rounded to the nearest cent + + >>> sum_of_years_digits_depreciation(10,1100.0,100.0) + [181.82, 163.64, 145.45, 127.27, 109.09, 90.91, 72.73, 54.55, 36.36, 18.18] + >>> sum_of_years_digits_depreciation(6,1250.0,50.0) + [342.86, 285.71, 228.57, 171.43, 114.29, 57.14] + >>> sum_of_years_digits_depreciation(4,1001.0) + [400.4, 300.3, 200.2, 100.1] + >>> sum_of_years_digits_depreciation(11,380.0,50.0) + [55.0, 50.0, 45.0, 40.0, 35.0, 30.0, 25.0, 20.0, 15.0, 10.0, 5.0] + >>> sum_of_years_digits_depreciation(1,4985,100) [4885.0] """ @@ -191,15 +185,20 @@ def sum_of_years_digits_depreciation( list_of_depreciation_expenses = [] - for i in range(1, useful_years + 1): - depreciation_value = ( - (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) - ) - list_of_depreciation_expenses.append(depreciation_value) + for i in range(1, useful_years+1): + depreciation_value = (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + list_of_depreciation_expenses.append(round(depreciation_value, 2)) + return list_of_depreciation_expenses + + + + + + if __name__ == "__main__": import doctest doctest.testmod() \ No newline at end of file From 5e03f63139e76181346c06d3a511b35cdb8adc4c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 01:34:06 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/depreciation.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index e2285fd18728..4cc6023f41e7 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -89,9 +89,12 @@ def straight_line_depreciation( return list_of_depreciation_expenses -def declining_balance_depreciation(useful_years: int, + +def declining_balance_depreciation( + useful_years: int, purchase_value: float, - residual_value: float = 0.0,): + residual_value: float = 0.0, +): """ Calculate the depreciation expenses over the given period using the declining balance method :param useful_years: Number of years the asset will be used @@ -134,16 +137,19 @@ def declining_balance_depreciation(useful_years: int, list_of_depreciation_expenses = [] - for i in range(1, useful_years+1): + for i in range(1, useful_years + 1): new_book_value = book_value * (1 - depreciation_rate) list_of_depreciation_expenses.append(round(book_value - new_book_value, 2)) book_value = new_book_value - + return list_of_depreciation_expenses -def sum_of_years_digits_depreciation(useful_years: int, + +def sum_of_years_digits_depreciation( + useful_years: int, purchase_value: float, - residual_value: float = 0.0,): + residual_value: float = 0.0, +): """ Calculate the depreciation expenses over the given period using the sum of years' digits method :param useful_years: Number of years the asset will be used @@ -185,20 +191,15 @@ def sum_of_years_digits_depreciation(useful_years: int, list_of_depreciation_expenses = [] - for i in range(1, useful_years+1): - depreciation_value = (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + for i in range(1, useful_years + 1): + depreciation_value = ( + (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + ) list_of_depreciation_expenses.append(round(depreciation_value, 2)) - return list_of_depreciation_expenses - - - - - - if __name__ == "__main__": import doctest From 6982b7668e51adb03038a2e4e1a66be65b31d3e1 Mon Sep 17 00:00:00 2001 From: Michael Roberts Date: Wed, 25 Jun 2025 21:39:27 -0400 Subject: [PATCH 7/9] reformat --- financial/depreciation.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index e2285fd18728..4ce6d7988c22 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -35,7 +35,8 @@ def straight_line_depreciation( residual_value: float = 0.0, ) -> list[float]: """ - Calculate the depreciation expenses over the given period using the straight-line method + Calculate the depreciation expenses over the given period, + using the straight-line method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life @@ -91,13 +92,15 @@ def straight_line_depreciation( def declining_balance_depreciation(useful_years: int, purchase_value: float, - residual_value: float = 0.0,): + residual_value: float = 0.0,) -> list[float]: """ - Calculate the depreciation expenses over the given period using the declining balance method + Calculate the depreciation expenses over the given period, + using the declining balance method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life - :return: A list of annual depreciation expenses over the asset's useful life, rounded to the nearest cent + :return: A list of annual depreciation expenses over the asset's useful life, + rounded to the nearest cent >>> declining_balance_depreciation(10,1100.0,100.0) [234.53, 184.52, 145.18, 114.23, 89.87, 70.71, 55.64, 43.77, 34.44, 27.1] @@ -134,7 +137,7 @@ def declining_balance_depreciation(useful_years: int, list_of_depreciation_expenses = [] - for i in range(1, useful_years+1): + for _ in range(1, useful_years+1): new_book_value = book_value * (1 - depreciation_rate) list_of_depreciation_expenses.append(round(book_value - new_book_value, 2)) book_value = new_book_value @@ -143,13 +146,15 @@ def declining_balance_depreciation(useful_years: int, def sum_of_years_digits_depreciation(useful_years: int, purchase_value: float, - residual_value: float = 0.0,): + residual_value: float = 0.0,) -> list[float]: """ - Calculate the depreciation expenses over the given period using the sum of years' digits method + Calculate the depreciation expenses over the given period, + using the sum of years' digits method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life - :return: A list of annual depreciation expenses over the asset's useful life, rounded to the nearest cent + :return: A list of annual depreciation expenses over the asset's useful life, + rounded to the nearest cent >>> sum_of_years_digits_depreciation(10,1100.0,100.0) [181.82, 163.64, 145.45, 127.27, 109.09, 90.91, 72.73, 54.55, 36.36, 18.18] From 02ec03b330c906cb7a3d03380135113302a363f2 Mon Sep 17 00:00:00 2001 From: Michael Roberts Date: Wed, 25 Jun 2025 21:41:09 -0400 Subject: [PATCH 8/9] Reformat, pt. 2 --- financial/depreciation.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index 4ce6d7988c22..c85e80340221 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -90,7 +90,9 @@ def straight_line_depreciation( return list_of_depreciation_expenses -def declining_balance_depreciation(useful_years: int, + +def declining_balance_depreciation( + useful_years: int, purchase_value: float, residual_value: float = 0.0,) -> list[float]: """ @@ -141,10 +143,12 @@ def declining_balance_depreciation(useful_years: int, new_book_value = book_value * (1 - depreciation_rate) list_of_depreciation_expenses.append(round(book_value - new_book_value, 2)) book_value = new_book_value - + return list_of_depreciation_expenses -def sum_of_years_digits_depreciation(useful_years: int, + +def sum_of_years_digits_depreciation( + useful_years: int, purchase_value: float, residual_value: float = 0.0,) -> list[float]: """ @@ -190,20 +194,15 @@ def sum_of_years_digits_depreciation(useful_years: int, list_of_depreciation_expenses = [] - for i in range(1, useful_years+1): - depreciation_value = (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + for i in range(1, useful_years + 1): + depreciation_value = ( + (useful_years - (i - 1)) / digits_sum * (purchase_value - residual_value) + ) list_of_depreciation_expenses.append(round(depreciation_value, 2)) - return list_of_depreciation_expenses - - - - - - if __name__ == "__main__": import doctest From 59488a284d4e56d74d28404424f3d14571f8651c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 01:43:04 +0000 Subject: [PATCH 9/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- financial/depreciation.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/financial/depreciation.py b/financial/depreciation.py index c85e80340221..ff8b7ad0d537 100644 --- a/financial/depreciation.py +++ b/financial/depreciation.py @@ -94,14 +94,15 @@ def straight_line_depreciation( def declining_balance_depreciation( useful_years: int, purchase_value: float, - residual_value: float = 0.0,) -> list[float]: + residual_value: float = 0.0, +) -> list[float]: """ Calculate the depreciation expenses over the given period, using the declining balance method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life - :return: A list of annual depreciation expenses over the asset's useful life, + :return: A list of annual depreciation expenses over the asset's useful life, rounded to the nearest cent >>> declining_balance_depreciation(10,1100.0,100.0) @@ -139,7 +140,7 @@ def declining_balance_depreciation( list_of_depreciation_expenses = [] - for _ in range(1, useful_years+1): + for _ in range(1, useful_years + 1): new_book_value = book_value * (1 - depreciation_rate) list_of_depreciation_expenses.append(round(book_value - new_book_value, 2)) book_value = new_book_value @@ -150,14 +151,15 @@ def declining_balance_depreciation( def sum_of_years_digits_depreciation( useful_years: int, purchase_value: float, - residual_value: float = 0.0,) -> list[float]: + residual_value: float = 0.0, +) -> list[float]: """ Calculate the depreciation expenses over the given period, using the sum of years' digits method :param useful_years: Number of years the asset will be used :param purchase_value: Purchase expenditure for the asset :param residual_value: Residual value of the asset at the end of its useful life - :return: A list of annual depreciation expenses over the asset's useful life, + :return: A list of annual depreciation expenses over the asset's useful life, rounded to the nearest cent >>> sum_of_years_digits_depreciation(10,1100.0,100.0) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy