From 006520b4c06ce3272563d5de5bc0ab6dbbccfba8 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Wed, 5 Aug 2026 10:04:43 -0500 Subject: [PATCH] vaultLoop: prefer live /money balance, fall back to MAX(running_balance) --- includes/utilities.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/utilities.php b/includes/utilities.php index c27820e..61f273d 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -205,6 +205,16 @@ function fetchVaultRecords($user = null) { * @return int The total balance of the given user (or all users if no user is given). */ function vaultLoop ($name=null) { + $liveBalance = $name === null + ? null + : fetchLiveVaultBalance($name); + + if ($liveBalance !== null) { + return $liveBalance; + } + + // Fallback: derive from stored entries. Used when the live /money call + // fails or is not configured for the user. $pdo = getDatabaseConnection(); if ($name === null) {