From f45414e5ac776c4c713db569ffb42a7db5e418d0 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 15 Jul 2026 15:33:18 +0000 Subject: [PATCH] perf(vat): make user-edit recompute instant; trim the post-fill wait MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop the 300ms debounce on manual edits (the formula_editor storm it guarded against is already handled by fill mode), so dependent cells update immediately. Shorten the post-report-fill settle from 3s to 400ms — the one delay that must stay, since recomputing during the hundreds-of-cells fill would freeze the form. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../declaration_of_value_added_tax.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/taxes_az/taxes_az/doctype/declaration_of_value_added_tax/declaration_of_value_added_tax.js b/taxes_az/taxes_az/doctype/declaration_of_value_added_tax/declaration_of_value_added_tax.js index cacd7d3..b15bdec 100644 --- a/taxes_az/taxes_az/doctype/declaration_of_value_added_tax/declaration_of_value_added_tax.js +++ b/taxes_az/taxes_az/doctype/declaration_of_value_added_tax/declaration_of_value_added_tax.js @@ -290,21 +290,20 @@ function vc_recompute(frm) { // 3s after the fill settles it runs the recompute ONCE, so roll-ups / passthrough // (e.g. 301.1 = Σ children, turnover ← appendices) fill in from the report data. // User edits (outside fill mode) are debounced. --- -var vc_fill_mode = false, vc_fill_timer = null, vc_calc_timer = null, vc_frm = null; +var vc_fill_mode = false, vc_fill_timer = null, vc_frm = null; function vc_mark_fill(frm) { if (frm) vc_frm = frm; vc_fill_mode = true; if (vc_fill_timer) clearTimeout(vc_fill_timer); vc_fill_timer = setTimeout(function () { vc_fill_mode = false; - if (vc_frm) vc_recompute(vc_frm); // one recompute after the report-fill settles - }, 3000); + if (vc_frm) vc_recompute(vc_frm); // one recompute after the report-fill burst settles + }, 400); } function vc_onchange(frm) { vc_frm = frm; - if (vc_fill_mode) { vc_mark_fill(frm); return; } // during fill: extend window, no per-write recompute - if (vc_calc_timer) clearTimeout(vc_calc_timer); - vc_calc_timer = setTimeout(function () { vc_recompute(frm); }, 300); // debounce user edits + if (vc_fill_mode) { vc_mark_fill(frm); return; } // during report-fill: don't recompute per write (would freeze) + vc_recompute(frm); // user edit: recompute instantly } // period change (dövr picker writes ay/il) starts the fill window