From fc89ae6232a69deafecc8e1b169d2f4017baca65 Mon Sep 17 00:00:00 2001 From: bach Date: Sun, 6 Sep 2026 12:21:53 +0200 Subject: [PATCH] =?UTF-8?q?Resolve=20versement=20reste-=C3=A0-verser/sur-v?= =?UTF-8?q?ers=C3=A9=20from=20the=20server=20proactively?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The badge on a versement freelance row previously only got the correct status once someone clicked it -- before that it could show "inconnu" (or, worse, silently default to "ok") whenever its linked entrée wasn't in the currently loaded sliding window, which is common: the entrée that got paid can be dated years before or after the versement itself. Also fixed a latent bug in the click path itself: toggleEntreeFilter() passed the *entrée's* id to loadEntreeGroup(), which needs an already-loaded row to find a starting nid for the server-side query -- if that entrée wasn't loaded (the exact case this is all about), the lookup silently found nothing and did nothing. Split the fetch+merge logic into fetchGroupFromNid() and let loadEntreeGroup() accept a fallbackNid (the versement's own, always loaded) to start the traversal from when the entrée itself isn't available locally -- LedgerStatsController::groupeEntree() finds the same connected component either way. New ensureLinkedReconciliationResolved(), triggered by a `rows` watcher after every load/loadOlder/loadNewer, calls the same server-backed resolution for every visible linkable row instead of waiting for a click, deduplicated via resolvedLinkGroups so rows sharing an entrée don't each trigger their own fetch. Verified live: the LA MINE versement (own date 2022, linked entrées dated 2023 and 2025) now shows "⚠ Sur-versé" immediately on page load with zero clicks, where before it required manually opening the badge first. Drill-down modal and the "Non liée" -> link-form click path both still work; no console errors on repeated fresh loads. --- .../custom/figli_compta_ledger/js/home.js | 91 +++++++++++++++---- .../templates/figli-compta-home.html.twig | 2 +- 2 files changed, 73 insertions(+), 20 deletions(-) diff --git a/web/modules/custom/figli_compta_ledger/js/home.js b/web/modules/custom/figli_compta_ledger/js/home.js index 1d39f23..e7c724c 100644 --- a/web/modules/custom/figli_compta_ledger/js/home.js +++ b/web/modules/custom/figli_compta_ledger/js/home.js @@ -346,6 +346,12 @@ // group doesn't need to re-fetch. groupExtraRows: [], groupLoading: false, + // Entrée ids whose full linked group has already been resolved + // by ensureLinkedReconciliationResolved() below (or by opening + // the drill-down modal for it) -- avoids re-fetching the same + // group again for every other sortie that happens to link to + // the same entrée. + resolvedLinkGroups: new Set(), // Which row's type badge is currently showing its inline