mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
chore: fix asset depr schedule notes
This commit is contained in:
@@ -1189,7 +1189,10 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
if asset.calculate_depreciation:
|
if asset.calculate_depreciation:
|
||||||
depreciate_asset(asset, self.posting_date, "Sell asset")
|
notes = _(
|
||||||
|
"This schedule was created when the Asset {0} was sold through Sales Invoice {1}."
|
||||||
|
).format(asset.name, self.get("name"))
|
||||||
|
depreciate_asset(asset, self.posting_date, notes)
|
||||||
|
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
||||||
asset, item.base_net_amount, item.finance_book, self.get("doctype"), self.get("name")
|
asset, item.base_net_amount, item.finance_book, self.get("doctype"), self.get("name")
|
||||||
|
|||||||
@@ -352,13 +352,13 @@ class Asset(AccountsController):
|
|||||||
0
|
0
|
||||||
].depreciation_amount
|
].depreciation_amount
|
||||||
|
|
||||||
def get_value_after_depreciation(self, idx):
|
|
||||||
return flt(self.get("finance_books")[cint(idx) - 1].value_after_depreciation)
|
|
||||||
|
|
||||||
def validate_expected_value_after_useful_life(self):
|
def validate_expected_value_after_useful_life(self):
|
||||||
for row in self.get("finance_books"):
|
for row in self.get("finance_books"):
|
||||||
depr_schedule = get_depr_schedule_from_asset_depr_schedule_of_asset(self.name, row.finance_book)
|
depr_schedule = get_depr_schedule_from_asset_depr_schedule_of_asset(self.name, row.finance_book)
|
||||||
|
|
||||||
|
if not depr_schedule:
|
||||||
|
continue
|
||||||
|
|
||||||
accumulated_depreciation_after_full_schedule = [
|
accumulated_depreciation_after_full_schedule = [
|
||||||
d.accumulated_depreciation_amount for d in depr_schedule
|
d.accumulated_depreciation_amount for d in depr_schedule
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -219,8 +219,6 @@ def scrap_asset(asset_name):
|
|||||||
|
|
||||||
date = today()
|
date = today()
|
||||||
|
|
||||||
depreciate_asset(asset, date, "Scrap asset")
|
|
||||||
|
|
||||||
depreciation_series = frappe.get_cached_value(
|
depreciation_series = frappe.get_cached_value(
|
||||||
"Company", asset.company, "series_for_depreciation_entry"
|
"Company", asset.company, "series_for_depreciation_entry"
|
||||||
)
|
)
|
||||||
@@ -239,6 +237,11 @@ def scrap_asset(asset_name):
|
|||||||
je.flags.ignore_permissions = True
|
je.flags.ignore_permissions = True
|
||||||
je.submit()
|
je.submit()
|
||||||
|
|
||||||
|
notes = _(
|
||||||
|
"This schedule was created when the Asset {0} was scrapped through Journal Entry {1}."
|
||||||
|
).format(asset.name, je.name)
|
||||||
|
depreciate_asset(asset, date, notes)
|
||||||
|
|
||||||
frappe.db.set_value("Asset", asset_name, "disposal_date", date)
|
frappe.db.set_value("Asset", asset_name, "disposal_date", date)
|
||||||
frappe.db.set_value("Asset", asset_name, "journal_entry_for_scrap", je.name)
|
frappe.db.set_value("Asset", asset_name, "journal_entry_for_scrap", je.name)
|
||||||
asset.set_status("Scrapped")
|
asset.set_status("Scrapped")
|
||||||
@@ -288,7 +291,10 @@ def modify_depreciation_schedule_for_asset_repairs(asset):
|
|||||||
if repair.increase_in_asset_life:
|
if repair.increase_in_asset_life:
|
||||||
asset_repair = frappe.get_doc("Asset Repair", repair.name)
|
asset_repair = frappe.get_doc("Asset Repair", repair.name)
|
||||||
asset_repair.modify_depreciation_schedule()
|
asset_repair.modify_depreciation_schedule()
|
||||||
make_new_active_asset_depr_schedules_and_cancel_current_ones(asset, "Asset Repair TODO")
|
notes = _(
|
||||||
|
"This schedule was created when the Asset {0} went through the Asset Repair {1}."
|
||||||
|
).format(asset.name, repair.name)
|
||||||
|
make_new_active_asset_depr_schedules_and_cancel_current_ones(asset, notes)
|
||||||
|
|
||||||
|
|
||||||
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
||||||
|
|||||||
@@ -430,7 +430,11 @@ class AssetCapitalization(StockController):
|
|||||||
asset = self.get_asset(item)
|
asset = self.get_asset(item)
|
||||||
|
|
||||||
if asset.calculate_depreciation:
|
if asset.calculate_depreciation:
|
||||||
depreciate_asset(asset, self.posting_date, "Asset Capitalization TODO")
|
notes = _(
|
||||||
|
"This schedule was created when the Asset {0} was consumed through Asset Capitalization {1}."
|
||||||
|
).format(asset.name, self.get("name"))
|
||||||
|
depreciate_asset(asset, self.posting_date, notes)
|
||||||
|
asset.reload()
|
||||||
|
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(
|
||||||
asset,
|
asset,
|
||||||
@@ -515,9 +519,10 @@ class AssetCapitalization(StockController):
|
|||||||
asset_doc.purchase_date = self.posting_date
|
asset_doc.purchase_date = self.posting_date
|
||||||
asset_doc.gross_purchase_amount = total_target_asset_value
|
asset_doc.gross_purchase_amount = total_target_asset_value
|
||||||
asset_doc.purchase_receipt_amount = total_target_asset_value
|
asset_doc.purchase_receipt_amount = total_target_asset_value
|
||||||
make_new_active_asset_depr_schedules_and_cancel_current_ones(
|
notes = _("This schedule was created when the Asset Capitalization {0} was submitted.").format(
|
||||||
asset_doc, "Asset Capitalization TODO"
|
self.name
|
||||||
)
|
)
|
||||||
|
make_new_active_asset_depr_schedules_and_cancel_current_ones(asset_doc, notes)
|
||||||
elif self.docstatus == 2:
|
elif self.docstatus == 2:
|
||||||
for item in self.asset_items:
|
for item in self.asset_items:
|
||||||
asset = self.get_asset(item)
|
asset = self.get_asset(item)
|
||||||
@@ -526,7 +531,10 @@ class AssetCapitalization(StockController):
|
|||||||
|
|
||||||
if asset.calculate_depreciation:
|
if asset.calculate_depreciation:
|
||||||
reverse_depreciation_entry_made_after_disposal(asset, self.posting_date)
|
reverse_depreciation_entry_made_after_disposal(asset, self.posting_date)
|
||||||
reset_depreciation_schedule(asset, self.posting_date, "Asset Capitalization TODO")
|
notes = _(
|
||||||
|
"This schedule was created when the Asset Capitalization {0} was cancelled."
|
||||||
|
).format(self.name)
|
||||||
|
reset_depreciation_schedule(asset, self.posting_date, notes)
|
||||||
|
|
||||||
def get_asset(self, item):
|
def get_asset(self, item):
|
||||||
asset = frappe.get_doc("Asset", item.asset)
|
asset = frappe.get_doc("Asset", item.asset)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
"depreciation_schedule",
|
"depreciation_schedule",
|
||||||
"details_section",
|
"details_section",
|
||||||
"notes",
|
"notes",
|
||||||
"column_break_15",
|
|
||||||
"status",
|
"status",
|
||||||
"amended_from"
|
"amended_from"
|
||||||
],
|
],
|
||||||
@@ -126,10 +125,6 @@
|
|||||||
"options": "Draft\nActive\nCancelled",
|
"options": "Draft\nActive\nCancelled",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "column_break_15",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"depends_on": "frequency_of_depreciation",
|
"depends_on": "frequency_of_depreciation",
|
||||||
"fieldname": "frequency_of_depreciation",
|
"fieldname": "frequency_of_depreciation",
|
||||||
@@ -154,19 +149,19 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "opening_accumulated_depreciation",
|
"depends_on": "opening_accumulated_depreciation",
|
||||||
"fieldname": "opening_accumulated_depreciation",
|
"fieldname": "opening_accumulated_depreciation",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Opening Accumulated Depreciation",
|
"label": "Opening Accumulated Depreciation",
|
||||||
"read_only": 1,
|
"options": "Company:company:default_currency",
|
||||||
"options": "Company:company:default_currency"
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"in_create": 1,
|
"in_create": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-11-25 14:31:52.668821",
|
"modified": "2022-12-09 15:14:20.562294",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset Depreciation Schedule",
|
"name": "Asset Depreciation Schedule",
|
||||||
|
|||||||
@@ -55,9 +55,10 @@ class AssetRepair(AccountsController):
|
|||||||
and self.increase_in_asset_life
|
and self.increase_in_asset_life
|
||||||
):
|
):
|
||||||
self.modify_depreciation_schedule()
|
self.modify_depreciation_schedule()
|
||||||
make_new_active_asset_depr_schedules_and_cancel_current_ones(
|
notes = _("This schedule was created when the Asset Repair {0} was submitted.").format(
|
||||||
self.asset_doc, "Asset Repair submit TODO"
|
self.name
|
||||||
)
|
)
|
||||||
|
make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
|
||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
self.asset_doc = frappe.get_doc("Asset", self.asset)
|
self.asset_doc = frappe.get_doc("Asset", self.asset)
|
||||||
@@ -75,9 +76,10 @@ class AssetRepair(AccountsController):
|
|||||||
and self.increase_in_asset_life
|
and self.increase_in_asset_life
|
||||||
):
|
):
|
||||||
self.revert_depreciation_schedule_on_cancellation()
|
self.revert_depreciation_schedule_on_cancellation()
|
||||||
make_new_active_asset_depr_schedules_and_cancel_current_ones(
|
notes = _("This schedule was created when the Asset Repair {0} was cancelled.").format(
|
||||||
self.asset_doc, "Asset Repair cancel TODO"
|
self.name
|
||||||
)
|
)
|
||||||
|
make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
|
||||||
|
|
||||||
def check_repair_status(self):
|
def check_repair_status(self):
|
||||||
if self.repair_status == "Pending":
|
if self.repair_status == "Pending":
|
||||||
|
|||||||
@@ -121,9 +121,8 @@ class AssetValueAdjustment(Document):
|
|||||||
"Asset Depreciation Schedule", current_asset_depr_schedule_name
|
"Asset Depreciation Schedule", current_asset_depr_schedule_name
|
||||||
)
|
)
|
||||||
|
|
||||||
new_asset_depr_schedule_doc = frappe.copy_doc(
|
new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
|
||||||
current_asset_depr_schedule_doc, ignore_no_copy=False
|
|
||||||
)
|
|
||||||
new_asset_depr_schedule_doc.notes = "Asset value adjustment"
|
new_asset_depr_schedule_doc.notes = "Asset value adjustment"
|
||||||
|
|
||||||
current_asset_depr_schedule_doc.cancel()
|
current_asset_depr_schedule_doc.cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user