From 9d0fe7aa56e48cd53a41cb1d88bcb74ae741c8ec Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:47:48 +0530 Subject: [PATCH] fix: consider opening asset values while calculating asset depreciation rate --- erpnext/assets/doctype/asset/asset.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 258d7a6b0611..fc16e5acc0e4 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -791,14 +791,19 @@ def get_depreciation_rate(self, args, on_validate=False): args.get("value_after_depreciation") ) else: - value = flt(args.get("expected_value_after_useful_life")) / flt(self.gross_purchase_amount) + value = flt(args.get("expected_value_after_useful_life")) / ( + flt(self.gross_purchase_amount) - flt(self.opening_accumulated_depreciation) + ) depreciation_rate = math.pow( value, 1.0 / ( ( - flt(args.get("total_number_of_depreciations"), 2) + ( + flt(args.get("total_number_of_depreciations"), 2) + - flt(self.opening_number_of_booked_depreciations) + ) * flt(args.get("frequency_of_depreciation")) ) / 12