chore: fix asset depr schedule notes
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 6e87415..85ed784 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -1189,7 +1189,10 @@
else:
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(
asset, item.base_net_amount, item.finance_book, self.get("doctype"), self.get("name")
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index d01b179..0b37b89 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -352,13 +352,13 @@
0
].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):
for row in self.get("finance_books"):
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 = [
d.accumulated_depreciation_amount for d in depr_schedule
]
diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py
index bc5b8a9..22c65fd 100644
--- a/erpnext/assets/doctype/asset/depreciation.py
+++ b/erpnext/assets/doctype/asset/depreciation.py
@@ -219,8 +219,6 @@
date = today()
- depreciate_asset(asset, date, "Scrap asset")
-
depreciation_series = frappe.get_cached_value(
"Company", asset.company, "series_for_depreciation_entry"
)
@@ -239,6 +237,11 @@
je.flags.ignore_permissions = True
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, "journal_entry_for_scrap", je.name)
asset.set_status("Scrapped")
@@ -288,7 +291,10 @@
if repair.increase_in_asset_life:
asset_repair = frappe.get_doc("Asset Repair", repair.name)
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):
diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
index 22459c4..96c01a5 100644
--- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
+++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
@@ -430,7 +430,11 @@
asset = self.get_asset(item)
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(
asset,
@@ -515,9 +519,10 @@
asset_doc.purchase_date = self.posting_date
asset_doc.gross_purchase_amount = total_target_asset_value
asset_doc.purchase_receipt_amount = total_target_asset_value
- make_new_active_asset_depr_schedules_and_cancel_current_ones(
- asset_doc, "Asset Capitalization TODO"
+ notes = _("This schedule was created when the Asset Capitalization {0} was submitted.").format(
+ self.name
)
+ make_new_active_asset_depr_schedules_and_cancel_current_ones(asset_doc, notes)
elif self.docstatus == 2:
for item in self.asset_items:
asset = self.get_asset(item)
@@ -526,7 +531,10 @@
if asset.calculate_depreciation:
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):
asset = frappe.get_doc("Asset", item.asset)
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json
index d39f30f..0fea6a5 100644
--- a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.json
@@ -24,7 +24,6 @@
"depreciation_schedule",
"details_section",
"notes",
- "column_break_15",
"status",
"amended_from"
],
@@ -127,10 +126,6 @@
"read_only": 1
},
{
- "fieldname": "column_break_15",
- "fieldtype": "Column Break"
- },
- {
"depends_on": "frequency_of_depreciation",
"fieldname": "frequency_of_depreciation",
"fieldtype": "Int",
@@ -154,19 +149,19 @@
"read_only": 1
},
{
- "depends_on": "opening_accumulated_depreciation",
- "fieldname": "opening_accumulated_depreciation",
- "fieldtype": "Currency",
- "label": "Opening Accumulated Depreciation",
- "read_only": 1,
- "options": "Company:company:default_currency"
- }
+ "depends_on": "opening_accumulated_depreciation",
+ "fieldname": "opening_accumulated_depreciation",
+ "fieldtype": "Currency",
+ "label": "Opening Accumulated Depreciation",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ }
],
"in_create": 1,
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2022-11-25 14:31:52.668821",
+ "modified": "2022-12-09 15:14:20.562294",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Depreciation Schedule",
diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py
index 33530bd..d3f74b0 100644
--- a/erpnext/assets/doctype/asset_repair/asset_repair.py
+++ b/erpnext/assets/doctype/asset_repair/asset_repair.py
@@ -55,9 +55,10 @@
and self.increase_in_asset_life
):
self.modify_depreciation_schedule()
- make_new_active_asset_depr_schedules_and_cancel_current_ones(
- self.asset_doc, "Asset Repair submit TODO"
+ notes = _("This schedule was created when the Asset Repair {0} was submitted.").format(
+ self.name
)
+ make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
def before_cancel(self):
self.asset_doc = frappe.get_doc("Asset", self.asset)
@@ -75,9 +76,10 @@
and self.increase_in_asset_life
):
self.revert_depreciation_schedule_on_cancellation()
- make_new_active_asset_depr_schedules_and_cancel_current_ones(
- self.asset_doc, "Asset Repair cancel TODO"
+ notes = _("This schedule was created when the Asset Repair {0} was cancelled.").format(
+ self.name
)
+ make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
def check_repair_status(self):
if self.repair_status == "Pending":
diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
index d153809..9caca33 100644
--- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
+++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
@@ -121,9 +121,8 @@
"Asset Depreciation Schedule", current_asset_depr_schedule_name
)
- new_asset_depr_schedule_doc = frappe.copy_doc(
- current_asset_depr_schedule_doc, ignore_no_copy=False
- )
+ new_asset_depr_schedule_doc = frappe.copy_doc(current_asset_depr_schedule_doc)
+
new_asset_depr_schedule_doc.notes = "Asset value adjustment"
current_asset_depr_schedule_doc.cancel()