From 26e72c253edc89f35d8ef0f321c850d6fab77b3a Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 15 Jul 2026 15:25:06 +0000 Subject: [PATCH] =?UTF-8?q?fix(vat):=20run=20the=20recompute=20once=20afte?= =?UTF-8?q?r=20the=20report-fill=20(d=C3=B6vr)=20settles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Selecting dövr triggers populate_vat_tables + formula_editor, which fill leaf cells from reports but do not roll parents up (e.g. 301.1 = Σ 301.1.1..4). The per-write recompute is suppressed during that storm; previously nothing ran afterwards, so 301.1 (and other roll-ups / appendix→turnover passthrough) stayed stale. Now "fill mode" runs the recompute ONCE, 3s after the fill settles. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../declaration_of_value_added_tax.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 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 d2147bd..cacd7d3 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 @@ -284,18 +284,25 @@ function vc_recompute(frm) { frm.refresh_field("sertifikathesabatdövründəmalındəyərininsəhifəsicəmi"); } -// --- Suppress recompute during the report-fill storm (populate_vat_tables / formula_editor -// write hundreds of cells via set_value; recomputing on each would freeze the UI and -// clobber report values). "Fill mode" starts on period change and re-arms on every -// programmatic write, ending 3s after the fill settles. User edits are debounced. --- -var vc_fill_mode = false, vc_fill_timer = null, vc_calc_timer = null; -function vc_mark_fill() { +// --- Suppress the per-write recompute during the report-fill storm (populate_vat_tables / +// formula_editor write hundreds of cells via set_value; recomputing on each would freeze +// the UI). "Fill mode" starts on period change and re-arms on every programmatic write. +// 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; +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; }, 3000); + vc_fill_timer = setTimeout(function () { + vc_fill_mode = false; + if (vc_frm) vc_recompute(vc_frm); // one recompute after the report-fill settles + }, 3000); } function vc_onchange(frm) { - if (vc_fill_mode) { vc_mark_fill(); return; } // ignore fill writes + 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 }