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

This commit is contained in:
GangaManoj 2021-11-24 02:45:17 +05:30
parent f455de2924
commit 33a0b1db2c

View File

@ -335,6 +335,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:
@ -344,11 +349,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)