mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 02:44:52 +00:00
Show all scheduled depreciation in dotted line
This commit is contained in:
@@ -55,36 +55,49 @@ frappe.ui.form.on('Asset', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
show_graph: function(frm) {
|
show_graph: function(frm) {
|
||||||
if(flt(frm.doc.value_after_depreciation) == flt(frm.doc.gross_purchase_amount))
|
|
||||||
return
|
|
||||||
|
|
||||||
var x_intervals = ["x", frm.doc.purchase_date];
|
var x_intervals = ["x", frm.doc.purchase_date];
|
||||||
var asset_values = ["Asset Value", frm.doc.gross_purchase_amount];
|
var asset_values = ["Asset Value", frm.doc.gross_purchase_amount];
|
||||||
|
var last_depreciation_date = frm.doc.purchase_date;
|
||||||
|
|
||||||
if(frm.doc.opening_accumulated_depreciation) {
|
if(frm.doc.opening_accumulated_depreciation) {
|
||||||
x_intervals.push(moment(frm.doc.creation).format('YYYY-MM-DD'));
|
last_depreciation_date = frappe.datetime.add_months(frm.doc.next_depreciation_date,
|
||||||
|
-1*frm.doc.frequency_of_depreciation);
|
||||||
|
|
||||||
|
x_intervals.push(last_depreciation_date);
|
||||||
asset_values.push(flt(frm.doc.gross_purchase_amount) -
|
asset_values.push(flt(frm.doc.gross_purchase_amount) -
|
||||||
flt(frm.doc.opening_accumulated_depreciation))
|
flt(frm.doc.opening_accumulated_depreciation));
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(frm.doc.schedules || [], function(i, v) {
|
$.each(frm.doc.schedules || [], function(i, v) {
|
||||||
x_intervals.push(v.schedule_date);
|
x_intervals.push(v.schedule_date);
|
||||||
|
asset_value = flt(frm.doc.gross_purchase_amount) - flt(v.accumulated_depreciation_amount);
|
||||||
if(v.journal_entry) {
|
if(v.journal_entry) {
|
||||||
asset_values.push(flt(frm.doc.gross_purchase_amount) - flt(v.accumulated_depreciation_amount))
|
last_depreciation_date = v.schedule_date;
|
||||||
|
asset_values.push(asset_value)
|
||||||
} else {
|
} else {
|
||||||
asset_values.push(null);
|
if (in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
||||||
|
asset_values.push(null)
|
||||||
|
} else {
|
||||||
|
asset_values.push(asset_value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if(in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
if(in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
||||||
x_intervals.push(frm.doc.disposal_date);
|
x_intervals.push(frm.doc.disposal_date);
|
||||||
asset_values.push(0)
|
asset_values.push(0);
|
||||||
|
last_depreciation_date = frm.doc.disposal_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.dashboard.reset();
|
frm.dashboard.reset();
|
||||||
frm.dashboard.add_graph([x_intervals, asset_values]);
|
frm.dashboard.add_graph({
|
||||||
|
x: 'x',
|
||||||
|
columns: [x_intervals, asset_values],
|
||||||
|
regions: {
|
||||||
|
'Asset Value': [{'start': last_depreciation_date, 'style':'dashed'}]
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
is_existing_asset: function(frm) {
|
is_existing_asset: function(frm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user