mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-14 18:51:21 +00:00
fix: reset consumed asset's depreciation on capitalization cancel
This commit is contained in:
@@ -635,13 +635,13 @@ class Asset(AccountsController):
|
|||||||
].expected_value_after_useful_life
|
].expected_value_after_useful_life
|
||||||
value_after_depreciation = self.finance_books[idx].value_after_depreciation
|
value_after_depreciation = self.finance_books[idx].value_after_depreciation
|
||||||
|
|
||||||
if (
|
if (
|
||||||
flt(value_after_depreciation) <= expected_value_after_useful_life
|
flt(value_after_depreciation) <= expected_value_after_useful_life
|
||||||
or self.is_fully_depreciated
|
or self.is_fully_depreciated
|
||||||
):
|
):
|
||||||
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):
|
||||||
status = "Partially Depreciated"
|
status = "Partially Depreciated"
|
||||||
elif self.docstatus == 2:
|
elif self.docstatus == 2:
|
||||||
status = "Cancelled"
|
status = "Cancelled"
|
||||||
return status
|
return status
|
||||||
|
|||||||
@@ -604,16 +604,17 @@ class AssetCapitalization(StockController):
|
|||||||
|
|
||||||
total_target_asset_value = flt(self.total_value, self.precision("total_value"))
|
total_target_asset_value = flt(self.total_value, self.precision("total_value"))
|
||||||
asset_doc = frappe.get_doc("Asset", self.target_asset)
|
asset_doc = frappe.get_doc("Asset", self.target_asset)
|
||||||
if self.docstatus == 2:
|
|
||||||
asset_doc.gross_purchase_amount -= total_target_asset_value
|
|
||||||
asset_doc.purchase_amount -= total_target_asset_value
|
|
||||||
else:
|
|
||||||
asset_doc.gross_purchase_amount += total_target_asset_value
|
|
||||||
asset_doc.purchase_amount += total_target_asset_value
|
|
||||||
|
|
||||||
asset_doc.set_status("Work In Progress")
|
if self.docstatus == 2:
|
||||||
asset_doc.flags.ignore_validate = True
|
gross_purchase_amount = asset_doc.gross_purchase_amount - total_target_asset_value
|
||||||
asset_doc.save()
|
purchase_amount = asset_doc.purchase_amount - total_target_asset_value
|
||||||
|
asset_doc.db_set("total_asset_cost", asset_doc.total_asset_cost - total_target_asset_value)
|
||||||
|
else:
|
||||||
|
gross_purchase_amount = asset_doc.gross_purchase_amount + total_target_asset_value
|
||||||
|
purchase_amount = asset_doc.purchase_amount + total_target_asset_value
|
||||||
|
|
||||||
|
asset_doc.db_set("gross_purchase_amount", gross_purchase_amount)
|
||||||
|
asset_doc.db_set("purchase_amount", purchase_amount)
|
||||||
|
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
_("Asset {0} has been updated. Please set the depreciation details if any and submit it.").format(
|
_("Asset {0} has been updated. Please set the depreciation details if any and submit it.").format(
|
||||||
@@ -624,7 +625,6 @@ class AssetCapitalization(StockController):
|
|||||||
def restore_consumed_asset_items(self):
|
def restore_consumed_asset_items(self):
|
||||||
for item in self.asset_items:
|
for item in self.asset_items:
|
||||||
asset = frappe.get_doc("Asset", item.asset)
|
asset = frappe.get_doc("Asset", item.asset)
|
||||||
asset.db_set("disposal_date", None)
|
|
||||||
self.set_consumed_asset_status(asset)
|
self.set_consumed_asset_status(asset)
|
||||||
|
|
||||||
if asset.calculate_depreciation:
|
if asset.calculate_depreciation:
|
||||||
@@ -635,6 +635,7 @@ class AssetCapitalization(StockController):
|
|||||||
get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.name)
|
get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.name)
|
||||||
)
|
)
|
||||||
reset_depreciation_schedule(asset, notes)
|
reset_depreciation_schedule(asset, notes)
|
||||||
|
asset.db_set("disposal_date", None)
|
||||||
|
|
||||||
def set_consumed_asset_status(self, asset):
|
def set_consumed_asset_status(self, asset):
|
||||||
if self.docstatus == 1:
|
if self.docstatus == 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user