mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-24 13:42:10 +01:00
fix(Asset): On Depreciation reversal, remove Journal Entry reference
This commit is contained in:
@@ -1475,13 +1475,12 @@ class AccountsController(TransactionBase):
|
|||||||
asset.flags.ignore_validate_update_after_submit = True
|
asset.flags.ignore_validate_update_after_submit = True
|
||||||
|
|
||||||
# recreate original depreciation schedule of the asset
|
# recreate original depreciation schedule of the asset
|
||||||
|
self.delete_depreciation_entry_made_after_disposal(asset)
|
||||||
asset.prepare_depreciation_data()
|
asset.prepare_depreciation_data()
|
||||||
|
|
||||||
self.modify_depreciation_schedule_for_asset_repairs(asset)
|
self.modify_depreciation_schedule_for_asset_repairs(asset)
|
||||||
asset.save()
|
asset.save()
|
||||||
|
|
||||||
self.delete_depreciation_entry_made_after_disposal(asset)
|
|
||||||
|
|
||||||
def modify_depreciation_schedule_for_asset_repairs(self, asset):
|
def modify_depreciation_schedule_for_asset_repairs(self, asset):
|
||||||
asset_repairs = frappe.get_all(
|
asset_repairs = frappe.get_all(
|
||||||
'Asset Repair',
|
'Asset Repair',
|
||||||
@@ -1511,7 +1510,7 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
if schedule.schedule_date == posting_date_of_original_invoice:
|
if schedule.schedule_date == posting_date_of_original_invoice:
|
||||||
if not self.disposal_was_made_on_original_schedule_date(asset, schedule, row,
|
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 = make_reverse_journal_entry(schedule.journal_entry)
|
||||||
reverse_journal_entry.posting_date = nowdate()
|
reverse_journal_entry.posting_date = nowdate()
|
||||||
|
|
||||||
@@ -1520,6 +1519,8 @@ class AccountsController(TransactionBase):
|
|||||||
d.reference_name = asset.name
|
d.reference_name = asset.name
|
||||||
|
|
||||||
reverse_journal_entry.submit()
|
reverse_journal_entry.submit()
|
||||||
|
schedule.db_set('journal_entry', None)
|
||||||
|
|
||||||
|
|
||||||
def get_posting_date_of_disposal_entry(self):
|
def get_posting_date_of_disposal_entry(self):
|
||||||
if self.doctype == "Sales Invoice" and self.return_against:
|
if self.doctype == "Sales Invoice" and self.return_against:
|
||||||
|
|||||||
Reference in New Issue
Block a user