Button to make Depreciation Entry manually
diff --git a/erpnext/accounts/doctype/asset/asset.js b/erpnext/accounts/doctype/asset/asset.js
index 2cd800a..38be263 100644
--- a/erpnext/accounts/doctype/asset/asset.js
+++ b/erpnext/accounts/doctype/asset/asset.js
@@ -27,7 +27,7 @@
refresh: function(frm) {
frappe.ui.form.trigger("Asset", "is_existing_asset");
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
-
+
if (frm.doc.docstatus==1) {
if (frm.doc.status=='Submitted' && !frm.doc.is_existing_asset && !frm.doc.purchase_invoice) {
frm.add_custom_button("Make Purchase Invoice", function() {
@@ -105,7 +105,10 @@
},
axis: {
x: {
- type: 'category'
+ type: 'timeseries',
+ tick: {
+ format: "%d-%m-%Y"
+ }
},
y: {
min: 0,
@@ -136,9 +139,28 @@
is_existing_asset: function(frm) {
frm.toggle_enable("supplier", frm.doc.is_existing_asset);
frm.toggle_reqd("next_depreciation_date", !frm.doc.is_existing_asset);
- }
+ },
});
+frappe.ui.form.on('Depreciation Schedule', {
+ make_depreciation_entry: function(frm, cdt, cdn) {
+ var row = locals[cdt][cdn];
+ if (!row.journal_entry) {
+ frappe.call({
+ method: "erpnext.accounts.doctype.asset.depreciation.make_depreciation_entry",
+ args: {
+ "asset_name": frm.doc.name,
+ "date": row.schedule_date
+ },
+ callback: function(r) {
+ frappe.model.sync(r.message);
+ frm.refresh();
+ }
+ })
+ }
+ }
+})
+
erpnext.asset.make_purchase_invoice = function(frm) {
frappe.call({
args: {
diff --git a/erpnext/accounts/doctype/asset/depreciation.py b/erpnext/accounts/doctype/asset/depreciation.py
index 06e1d1a..6cf09d3 100644
--- a/erpnext/accounts/doctype/asset/depreciation.py
+++ b/erpnext/accounts/doctype/asset/depreciation.py
@@ -21,7 +21,10 @@
and a.status in ('Submitted', 'Partially Depreciated')
and ifnull(ds.journal_entry, '')=''""", date)
+@frappe.whitelist()
def make_depreciation_entry(asset_name, date=None):
+ frappe.has_permission('Journal Entry', throw=True)
+
if not date:
date = today()
@@ -62,6 +65,8 @@
asset.db_set("value_after_depreciation", asset.value_after_depreciation)
asset.set_status()
+
+ return asset
def get_depreciation_accounts(asset):
fixed_asset_account = accumulated_depreciation_account = depreciation_expense_account = None
diff --git a/erpnext/accounts/doctype/depreciation_schedule/depreciation_schedule.json b/erpnext/accounts/doctype/depreciation_schedule/depreciation_schedule.json
index dc854b2..68ce53f 100644
--- a/erpnext/accounts/doctype/depreciation_schedule/depreciation_schedule.json
+++ b/erpnext/accounts/doctype/depreciation_schedule/depreciation_schedule.json
@@ -3,6 +3,7 @@
"allow_import": 0,
"allow_rename": 1,
"autoname": "",
+ "beta": 0,
"creation": "2016-03-02 15:11:01.278862",
"custom": 0,
"docstatus": 0,
@@ -135,18 +136,45 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
+ },
+ {
+ "allow_on_submit": 1,
+ "bold": 0,
+ "collapsible": 0,
+ "depends_on": "eval:(!doc.journal_entry && doc.schedule_date <= get_today())",
+ "fieldname": "make_depreciation_entry",
+ "fieldtype": "Button",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Make Depreciation Entry",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
+ "image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-04-20 16:43:21.407123",
+ "modified": "2016-07-06 12:38:32.456903",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Depreciation Schedule",