diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js
index 97a41de526..a97ea735da 100644
--- a/erpnext/assets/doctype/asset/asset.js
+++ b/erpnext/assets/doctype/asset/asset.js
@@ -141,7 +141,7 @@ frappe.ui.form.on('Asset', {
frm.trigger("set_depr_posting_failure_alert");
}
- frm.trigger("setup_chart");
+ frm.trigger("setup_chart_and_depr_schedule_view");
}
frm.trigger("toggle_reference_doc");
@@ -206,7 +206,38 @@ frappe.ui.form.on('Asset', {
})
},
- setup_chart: async function(frm) {
+ render_depreciation_schedule_view: function(frm, depr_schedule) {
+ var wrapper = $(frm.fields_dict["depreciation_schedule_view"].wrapper).empty();
+
+ let table = $(`
+
+
+ ${__("No.")} |
+ ${__("Schedule Date")} |
+ ${__("Depreciation Amount")} |
+ ${__("Accumulated Depreciation Amount")} |
+ ${__("Journal Entry")} |
+
+
+
+
`);
+
+ depr_schedule.forEach((sch) => {
+ const row = $(`
+ ${sch['idx']} |
+ ${frappe.format(sch['schedule_date'], { fieldtype: 'Date' })} |
+ ${frappe.format(sch['depreciation_amount'], { fieldtype: 'Currency' })} |
+ ${frappe.format(sch['accumulated_depreciation_amount'], { fieldtype: 'Currency' })} |
+ ${sch['journal_entry'] || ''} |
+
`);
+ table.find("tbody").append(row);
+ });
+
+ wrapper.append(table);
+
+ },
+
+ setup_chart_and_depr_schedule_view: async function(frm) {
if(frm.doc.finance_books.length > 1) {
return
}
@@ -228,7 +259,7 @@ frappe.ui.form.on('Asset', {
"erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule.get_depr_schedule",
{
asset_name: frm.doc.name,
- status: frm.doc.docstatus ? "Active" : "Draft",
+ status: "Active",
finance_book: frm.doc.finance_books[0].finance_book || null
}
)).message;
@@ -246,6 +277,9 @@ frappe.ui.form.on('Asset', {
}
}
});
+
+ frm.toggle_display(["depreciation_schedule_view"], 1);
+ frm.events.render_depreciation_schedule_view(frm, depr_schedule);
} else {
if(frm.doc.opening_accumulated_depreciation) {
x_intervals.push(frappe.format(frm.doc.creation.split(" ")[0], { fieldtype: 'Date' }));
diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json
index a1e8f331cd..698fc787e8 100644
--- a/erpnext/assets/doctype/asset/asset.json
+++ b/erpnext/assets/doctype/asset/asset.json
@@ -52,6 +52,8 @@
"column_break_24",
"frequency_of_depreciation",
"next_depreciation_date",
+ "depreciation_schedule_sb",
+ "depreciation_schedule_view",
"insurance_details",
"policy_number",
"insurer",
@@ -487,6 +489,17 @@
"options": "\nSuccessful\nFailed",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "fieldname": "depreciation_schedule_sb",
+ "fieldtype": "Section Break",
+ "label": "Depreciation Schedule"
+ },
+ {
+ "fieldname": "depreciation_schedule_view",
+ "fieldtype": "HTML",
+ "hidden": 1,
+ "label": "Depreciation Schedule View"
}
],
"idx": 72,
@@ -520,7 +533,7 @@
"table_fieldname": "accounts"
}
],
- "modified": "2023-03-30 15:07:41.542374",
+ "modified": "2023-07-26 13:33:36.821534",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset",
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 7dc438e08f..5d35808413 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -21,6 +21,7 @@ from frappe.utils import (
import erpnext
from erpnext.accounts.general_ledger import make_reverse_gl_entries
from erpnext.assets.doctype.asset.depreciation import (
+ get_comma_separated_links,
get_depreciation_accounts,
get_disposal_account_and_cost_center,
)
@@ -59,8 +60,17 @@ class Asset(AccountsController):
if not self.booked_fixed_asset and self.validate_make_gl_entry():
self.make_gl_entries()
if not self.split_from:
- make_draft_asset_depr_schedules_if_not_present(self)
+ asset_depr_schedules_names = make_draft_asset_depr_schedules_if_not_present(self)
convert_draft_asset_depr_schedules_into_active(self)
+ if asset_depr_schedules_names:
+ asset_depr_schedules_links = get_comma_separated_links(
+ asset_depr_schedules_names, "Asset Depreciation Schedule"
+ )
+ frappe.msgprint(
+ _(
+ "Asset Depreciation Schedules created:
{0}
Please check, edit if needed, and submit the Asset."
+ ).format(asset_depr_schedules_links)
+ )
def on_cancel(self):
self.validate_cancellation()
@@ -74,7 +84,15 @@ class Asset(AccountsController):
def after_insert(self):
if not self.split_from:
- make_draft_asset_depr_schedules(self)
+ asset_depr_schedules_names = make_draft_asset_depr_schedules(self)
+ asset_depr_schedules_links = get_comma_separated_links(
+ asset_depr_schedules_names, "Asset Depreciation Schedule"
+ )
+ frappe.msgprint(
+ _(
+ "Asset Depreciation Schedules created:
{0}
Please check, edit if needed, and submit the Asset."
+ ).format(asset_depr_schedules_links)
+ )
def validate_asset_and_reference(self):
if self.purchase_invoice or self.purchase_receipt:
diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
index deae8c7891..e616665ad1 100644
--- a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
+++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py
@@ -571,6 +571,8 @@ def get_wdv_or_dd_depr_amount(
def make_draft_asset_depr_schedules_if_not_present(asset_doc):
+ asset_depr_schedules_names = []
+
for row in asset_doc.get("finance_books"):
draft_asset_depr_schedule_name = get_asset_depr_schedule_name(
asset_doc.name, "Draft", row.finance_book
@@ -581,12 +583,20 @@ def make_draft_asset_depr_schedules_if_not_present(asset_doc):
)
if not draft_asset_depr_schedule_name and not active_asset_depr_schedule_name:
- make_draft_asset_depr_schedule(asset_doc, row)
+ name = make_draft_asset_depr_schedule(asset_doc, row)
+ asset_depr_schedules_names.append(name)
+
+ return asset_depr_schedules_names
def make_draft_asset_depr_schedules(asset_doc):
+ asset_depr_schedules_names = []
+
for row in asset_doc.get("finance_books"):
- make_draft_asset_depr_schedule(asset_doc, row)
+ name = make_draft_asset_depr_schedule(asset_doc, row)
+ asset_depr_schedules_names.append(name)
+
+ return asset_depr_schedules_names
def make_draft_asset_depr_schedule(asset_doc, row):
@@ -596,6 +606,8 @@ def make_draft_asset_depr_schedule(asset_doc, row):
asset_depr_schedule_doc.insert()
+ return asset_depr_schedule_doc.name
+
def update_draft_asset_depr_schedules(asset_doc):
for row in asset_doc.get("finance_books"):
diff --git a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
index abe295c680..884e0c6cb2 100644
--- a/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
+++ b/erpnext/assets/doctype/depreciation_schedule/depreciation_schedule.json
@@ -53,7 +53,7 @@
},
{
"allow_on_submit": 1,
- "depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= get_today())",
+ "depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= frappe.datetime.now_date())",
"fieldname": "make_depreciation_entry",
"fieldtype": "Button",
"label": "Make Depreciation Entry"
@@ -61,7 +61,7 @@
],
"istable": 1,
"links": [],
- "modified": "2023-03-13 23:17:15.849950",
+ "modified": "2023-07-26 12:56:48.718736",
"modified_by": "Administrator",
"module": "Assets",
"name": "Depreciation Schedule",