mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 10:36:31 +00:00
fix(assets): build Finance Books even when Calculate Depreciation is checked before Net Purchase Amount is entered
Previously, checking "Calculate Depreciation" (or picking the Item) before typing in "Net Purchase Amount" left the Finance Books table empty, because the depreciation schedule was only built at the moment those fields already had values. Entering the amount afterward only updated existing Finance Books rows, so an empty table stayed empty. Now, entering the amount also builds Finance Books from scratch if it was left empty, regardless of the order fields were filled in.
This commit is contained in:
@@ -735,10 +735,14 @@ frappe.ui.form.on("Asset", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
net_purchase_amount: function (frm) {
|
net_purchase_amount: function (frm) {
|
||||||
if (frm.doc.finance_books) {
|
if (frm.doc.finance_books && frm.doc.finance_books.length) {
|
||||||
frm.doc.finance_books.forEach((d) => {
|
frm.doc.finance_books.forEach((d) => {
|
||||||
frm.events.set_depreciation_rate(frm, d);
|
frm.events.set_depreciation_rate(frm, d);
|
||||||
});
|
});
|
||||||
|
} else if (frm.doc.item_code && frm.doc.calculate_depreciation && frm.doc.net_purchase_amount) {
|
||||||
|
// "Calculate Depreciation" (or the Item) was set before an amount existed, so the
|
||||||
|
// finance books table was left empty -- build it now that there's an amount to base it on.
|
||||||
|
frm.trigger("set_finance_book");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user