fix: Reset value_after_depreciation on reversing journal entry during Asset return (#28980)

(cherry picked from commit 1ed30ee7c7)

Co-authored-by: Ganga Manoj <ganga.manoj98@gmail.com>
This commit is contained in:
mergify[bot]
2021-12-21 15:13:11 +05:30
committed by GitHub
parent 56d72764b7
commit 84404bf6e3

View File

@@ -1062,6 +1062,8 @@ class SalesInvoice(SellingController):
frappe.flags.is_reverse_depr_entry = False
asset.flags.ignore_validate_update_after_submit = True
schedule.journal_entry = None
depreciation_amount = self.get_depreciation_amount_in_je(reverse_journal_entry)
asset.finance_books[0].value_after_depreciation += depreciation_amount
asset.save()
def get_posting_date_of_sales_invoice(self):
@@ -1084,6 +1086,12 @@ class SalesInvoice(SellingController):
return False
def get_depreciation_amount_in_je(self, journal_entry):
if journal_entry.accounts[0].debit_in_account_currency:
return journal_entry.accounts[0].debit_in_account_currency
else:
return journal_entry.accounts[0].credit_in_account_currency
@property
def enable_discount_accounting(self):
if not hasattr(self, "_enable_discount_accounting"):