fix: Retain depreciation schedule rows that are linked with JEs while clearing the schedule
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index f3825ea..351556c 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -335,6 +335,11 @@
for schedule in self.get('schedules'):
+ # to update start when there are JEs linked with all the schedule rows corresponding to an FB
+ if len(start) == (int(schedule.finance_book_id) - 2):
+ start.append(num_of_depreciations_completed)
+ num_of_depreciations_completed = 0
+
# to ensure that start will only be updated once for each FB
if len(start) == (int(schedule.finance_book_id) - 1):
if schedule.journal_entry:
@@ -344,11 +349,6 @@
start.append(num_of_depreciations_completed)
num_of_depreciations_completed = 0
- # to update start when there are JEs linked with all the schedule rows corresponding to an FB
- elif len(start) == (int(schedule.finance_book_id) - 2):
- start.append(num_of_depreciations_completed)
- num_of_depreciations_completed = 0
-
# to update start when all the schedule rows corresponding to the last FB are linked with JEs
if len(start) == (len(self.finance_books) - 1):
start.append(num_of_depreciations_completed)