fix: Retain depreciation schedule rows that are linked with JEs while clearing the schedule

(cherry picked from commit 33a0b1db2c)
This commit is contained in:
GangaManoj
2021-11-24 02:45:17 +05:30
committed by mergify-bot
parent 57f41bc30a
commit ae875ab021

View File

@@ -351,6 +351,11 @@ class Asset(AccountsController):
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:
@@ -360,11 +365,6 @@ class Asset(AccountsController):
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)