mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-03 21:48:27 +00:00
chore: asset scrap and restore fixes [v14] (#35851)
chore: better err msg on cancelling JE for asset scrap and allow restoring non-depr assets
This commit is contained in:
@@ -326,12 +326,10 @@ class JournalEntry(AccountsController):
|
|||||||
d.db_update()
|
d.db_update()
|
||||||
|
|
||||||
def unlink_asset_reference(self):
|
def unlink_asset_reference(self):
|
||||||
if self.voucher_type != "Depreciation Entry":
|
|
||||||
return
|
|
||||||
|
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if (
|
if (
|
||||||
d.reference_type == "Asset"
|
self.voucher_type == "Depreciation Entry"
|
||||||
|
and d.reference_type == "Asset"
|
||||||
and d.reference_name
|
and d.reference_name
|
||||||
and d.account_type == "Depreciation"
|
and d.account_type == "Depreciation"
|
||||||
and d.debit
|
and d.debit
|
||||||
@@ -358,6 +356,15 @@ class JournalEntry(AccountsController):
|
|||||||
else:
|
else:
|
||||||
asset.db_set("value_after_depreciation", asset.value_after_depreciation + d.debit)
|
asset.db_set("value_after_depreciation", asset.value_after_depreciation + d.debit)
|
||||||
asset.set_status()
|
asset.set_status()
|
||||||
|
elif self.voucher_type == "Journal Entry" and d.reference_type == "Asset" and d.reference_name:
|
||||||
|
journal_entry_for_scrap = frappe.db.get_value(
|
||||||
|
"Asset", d.reference_name, "journal_entry_for_scrap"
|
||||||
|
)
|
||||||
|
|
||||||
|
if journal_entry_for_scrap == self.name:
|
||||||
|
frappe.throw(
|
||||||
|
_("Journal Entry for Asset scrapping cannot be cancelled. Please restore the Asset.")
|
||||||
|
)
|
||||||
|
|
||||||
def unlink_inter_company_jv(self):
|
def unlink_inter_company_jv(self):
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -343,6 +343,9 @@ def modify_depreciation_schedule_for_asset_repairs(asset):
|
|||||||
|
|
||||||
|
|
||||||
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
||||||
|
if not asset.calculate_depreciation:
|
||||||
|
return
|
||||||
|
|
||||||
row = -1
|
row = -1
|
||||||
finance_book = asset.get("schedules")[0].get("finance_book")
|
finance_book = asset.get("schedules")[0].get("finance_book")
|
||||||
for schedule in asset.get("schedules"):
|
for schedule in asset.get("schedules"):
|
||||||
|
|||||||
Reference in New Issue
Block a user