@@ -519,19 +519,23 @@ frappe.ui.form.on('Depreciation Schedule', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
depreciation_amount: function(frm, cdt, cdn) {
|
depreciation_amount: function(frm, cdt, cdn) {
|
||||||
erpnext.asset.set_accumulated_depreciation(frm);
|
erpnext.asset.set_accumulated_depreciation(frm, locals[cdt][cdn].finance_book_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
||||||
erpnext.asset.set_accumulated_depreciation = function(frm) {
|
erpnext.asset.set_accumulated_depreciation = function(frm, finance_book_id) {
|
||||||
if(frm.doc.depreciation_method != "Manual") return;
|
var depreciation_method = frm.doc.finance_books[Number(finance_book_id) - 1].depreciation_method;
|
||||||
|
|
||||||
|
if(depreciation_method != "Manual") return;
|
||||||
|
|
||||||
var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
|
var accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
|
||||||
|
|
||||||
$.each(frm.doc.schedules || [], function(i, row) {
|
$.each(frm.doc.schedules || [], function(i, row) {
|
||||||
accumulated_depreciation += flt(row.depreciation_amount);
|
if (row.finance_book_id === finance_book_id) {
|
||||||
frappe.model.set_value(row.doctype, row.name,
|
accumulated_depreciation += flt(row.depreciation_amount);
|
||||||
"accumulated_depreciation_amount", accumulated_depreciation);
|
frappe.model.set_value(row.doctype, row.name, "accumulated_depreciation_amount", accumulated_depreciation);
|
||||||
|
};
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -84,8 +84,11 @@ class Asset(AccountsController):
|
|||||||
if self.calculate_depreciation:
|
if self.calculate_depreciation:
|
||||||
self.value_after_depreciation = 0
|
self.value_after_depreciation = 0
|
||||||
self.set_depreciation_rate()
|
self.set_depreciation_rate()
|
||||||
self.make_depreciation_schedule(date_of_disposal)
|
if not (
|
||||||
self.set_accumulated_depreciation(date_of_disposal, date_of_return)
|
self.get("schedules") and "Manual" in [d.depreciation_method for d in self.finance_books]
|
||||||
|
):
|
||||||
|
self.make_depreciation_schedule(date_of_disposal)
|
||||||
|
self.set_accumulated_depreciation(date_of_disposal, date_of_return)
|
||||||
else:
|
else:
|
||||||
self.finance_books = []
|
self.finance_books = []
|
||||||
self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(
|
self.value_after_depreciation = flt(self.gross_purchase_amount) - flt(
|
||||||
@@ -225,9 +228,7 @@ class Asset(AccountsController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def make_depreciation_schedule(self, date_of_disposal):
|
def make_depreciation_schedule(self, date_of_disposal):
|
||||||
if "Manual" not in [d.depreciation_method for d in self.finance_books] and not self.get(
|
if not self.get("schedules"):
|
||||||
"schedules"
|
|
||||||
):
|
|
||||||
self.schedules = []
|
self.schedules = []
|
||||||
|
|
||||||
if not self.available_for_use_date:
|
if not self.available_for_use_date:
|
||||||
@@ -546,7 +547,9 @@ class Asset(AccountsController):
|
|||||||
self, date_of_disposal=None, date_of_return=None, ignore_booked_entry=False
|
self, date_of_disposal=None, date_of_return=None, ignore_booked_entry=False
|
||||||
):
|
):
|
||||||
straight_line_idx = [
|
straight_line_idx = [
|
||||||
d.idx for d in self.get("schedules") if d.depreciation_method == "Straight Line"
|
d.idx
|
||||||
|
for d in self.get("schedules")
|
||||||
|
if d.depreciation_method == "Straight Line" or d.depreciation_method == "Manual"
|
||||||
]
|
]
|
||||||
finance_books = []
|
finance_books = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user