diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 31af7f3744..ba0c7a8a8b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1475,13 +1475,12 @@ class AccountsController(TransactionBase): asset.flags.ignore_validate_update_after_submit = True # recreate original depreciation schedule of the asset + self.delete_depreciation_entry_made_after_disposal(asset) asset.prepare_depreciation_data() self.modify_depreciation_schedule_for_asset_repairs(asset) asset.save() - self.delete_depreciation_entry_made_after_disposal(asset) - def modify_depreciation_schedule_for_asset_repairs(self, asset): asset_repairs = frappe.get_all( 'Asset Repair', @@ -1511,7 +1510,7 @@ class AccountsController(TransactionBase): if schedule.schedule_date == posting_date_of_original_invoice: if not self.disposal_was_made_on_original_schedule_date(asset, schedule, row, - posting_date_of_original_invoice): + posting_date_of_original_invoice) or getdate(schedule.schedule_date) > getdate(today()): reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry) reverse_journal_entry.posting_date = nowdate() @@ -1520,6 +1519,8 @@ class AccountsController(TransactionBase): d.reference_name = asset.name reverse_journal_entry.submit() + schedule.db_set('journal_entry', None) + def get_posting_date_of_disposal_entry(self): if self.doctype == "Sales Invoice" and self.return_against: