Fix finance book getter error when book doesn't exist (#14987)

This commit is contained in:
Alchez
2018-07-23 14:16:35 +05:30
committed by Nabin Hait
parent 851ac754f7
commit 56bd5d8aaa

View File

@@ -315,14 +315,14 @@ class Asset(AccountsController):
elif self.docstatus == 1: elif self.docstatus == 1:
status = "Submitted" status = "Submitted"
idx = self.get_default_finance_book_idx() or 0
expected_value_after_useful_life = self.finance_books[idx].expected_value_after_useful_life
value_after_depreciation = self.finance_books[idx].value_after_depreciation
if self.journal_entry_for_scrap: if self.journal_entry_for_scrap:
status = "Scrapped" status = "Scrapped"
elif self.finance_books: elif self.finance_books:
idx = self.get_default_finance_book_idx() or 0
expected_value_after_useful_life = self.finance_books[idx].expected_value_after_useful_life
value_after_depreciation = self.finance_books[idx].value_after_depreciation
if flt(value_after_depreciation) <= expected_value_after_useful_life: if flt(value_after_depreciation) <= expected_value_after_useful_life:
status = "Fully Depreciated" status = "Fully Depreciated"
elif flt(value_after_depreciation) < flt(self.gross_purchase_amount): elif flt(value_after_depreciation) < flt(self.gross_purchase_amount):