From d84aeef0bb9bc3799775506ce9570d6efbaff55f Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:31:38 +0530 Subject: [PATCH 1/2] fix: handle zero salvage value case --- erpnext/assets/doctype/asset/asset.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 9b124826fcec..615dc1224031 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -806,6 +806,9 @@ def get_depreciation_rate(self, args, on_validate=False): return args.get("rate_of_depreciation") if self.flags.increase_in_asset_value_due_to_repair: + if not flt(args.get("expected_value_after_useful_life")): + return args.get("rate_of_depreciation") + value = flt(args.get("expected_value_after_useful_life")) / flt( args.get("value_after_depreciation") ) From 325b20491a441b6d9dfe400ae12c8fd30ab003ca Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:36:30 +0530 Subject: [PATCH 2/2] fix: make rate of depreciation mandatory --- erpnext/assets/doctype/asset/asset.py | 6 +++--- .../doctype/asset_finance_book/asset_finance_book.json | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 615dc1224031..8715f2b23547 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -805,10 +805,10 @@ def get_depreciation_rate(self, args, on_validate=False): ): return args.get("rate_of_depreciation") - if self.flags.increase_in_asset_value_due_to_repair: - if not flt(args.get("expected_value_after_useful_life")): - return args.get("rate_of_depreciation") + if args.get("rate_of_depreciation") and not flt(args.get("expected_value_after_useful_life")): + return args.get("rate_of_depreciation") + if self.flags.increase_in_asset_value_due_to_repair: value = flt(args.get("expected_value_after_useful_life")) / flt( args.get("value_after_depreciation") ) diff --git a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json index 8b00bc29c3cc..60e8778e0e65 100644 --- a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json +++ b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json @@ -88,7 +88,8 @@ "depends_on": "eval:doc.depreciation_method == 'Written Down Value'", "fieldname": "rate_of_depreciation", "fieldtype": "Percent", - "label": "Rate of Depreciation (%)" + "label": "Rate of Depreciation (%)", + "mandatory_depends_on": "eval:doc.depreciation_method == 'Written Down Value'" }, { "fieldname": "salvage_value_percentage", @@ -128,7 +129,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-11-29 14:36:54.399034", + "modified": "2024-12-13 12:11:03.743209", "modified_by": "Administrator", "module": "Assets", "name": "Asset Finance Book",