From 5d1ffa7fcae2bd391cea8ab0656f9b37e821cd71 Mon Sep 17 00:00:00 2001 From: Henil Date: Wed, 9 Sep 2026 16:34:20 +0530 Subject: [PATCH] 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. --- erpnext/assets/doctype/asset/asset.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js index e269f289307..8c7f0b1f788 100644 --- a/erpnext/assets/doctype/asset/asset.js +++ b/erpnext/assets/doctype/asset/asset.js @@ -735,10 +735,14 @@ frappe.ui.form.on("Asset", { }, 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.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"); } },