Button to make Depreciation Entry manually

This commit is contained in:
Nabin Hait 2016-07-06 15:06:05 +05:30
parent e417000bbb
commit c19691632e
3 changed files with 59 additions and 4 deletions

View File

@ -105,7 +105,10 @@ frappe.ui.form.on('Asset', {
}, },
axis: { axis: {
x: { x: {
type: 'category' type: 'timeseries',
tick: {
format: "%d-%m-%Y"
}
}, },
y: { y: {
min: 0, min: 0,
@ -136,9 +139,28 @@ frappe.ui.form.on('Asset', {
is_existing_asset: function(frm) { is_existing_asset: function(frm) {
frm.toggle_enable("supplier", frm.doc.is_existing_asset); frm.toggle_enable("supplier", frm.doc.is_existing_asset);
frm.toggle_reqd("next_depreciation_date", !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) { erpnext.asset.make_purchase_invoice = function(frm) {
frappe.call({ frappe.call({
args: { args: {

View File

@ -21,7 +21,10 @@ def get_depreciable_assets(date):
and a.status in ('Submitted', 'Partially Depreciated') and a.status in ('Submitted', 'Partially Depreciated')
and ifnull(ds.journal_entry, '')=''""", date) and ifnull(ds.journal_entry, '')=''""", date)
@frappe.whitelist()
def make_depreciation_entry(asset_name, date=None): def make_depreciation_entry(asset_name, date=None):
frappe.has_permission('Journal Entry', throw=True)
if not date: if not date:
date = today() date = today()
@ -63,6 +66,8 @@ def make_depreciation_entry(asset_name, date=None):
asset.db_set("value_after_depreciation", asset.value_after_depreciation) asset.db_set("value_after_depreciation", asset.value_after_depreciation)
asset.set_status() asset.set_status()
return asset
def get_depreciation_accounts(asset): def get_depreciation_accounts(asset):
fixed_asset_account = accumulated_depreciation_account = depreciation_expense_account = None fixed_asset_account = accumulated_depreciation_account = depreciation_expense_account = None

View File

@ -3,6 +3,7 @@
"allow_import": 0, "allow_import": 0,
"allow_rename": 1, "allow_rename": 1,
"autoname": "", "autoname": "",
"beta": 0,
"creation": "2016-03-02 15:11:01.278862", "creation": "2016-03-02 15:11:01.278862",
"custom": 0, "custom": 0,
"docstatus": 0, "docstatus": 0,
@ -135,18 +136,45 @@
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 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_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"idx": 0, "idx": 0,
"image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0, "in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-04-20 16:43:21.407123", "modified": "2016-07-06 12:38:32.456903",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Depreciation Schedule", "name": "Depreciation Schedule",