Capture running_balance from v2 API data.balance

This commit is contained in:
Keith Solomon
2026-08-03 21:54:40 -05:00
parent 2e1bd050e1
commit af7a233272
2 changed files with 20 additions and 10 deletions
+5 -2
View File
@@ -147,11 +147,14 @@ function processLogEntries($logEntries, $user, $insertStmt) {
continue;
}
$runningBalance = isset($entry['data']['balance']) ? (int)$entry['data']['balance'] : null;
$insertStmt->bindValue(':id', $id);
$insertStmt->bindValue(':user', $user);
$insertStmt->bindValue(':timestamp', $timestamp);
$insertStmt->bindValue(':description', $description);
$insertStmt->bindValue(':amount', $amount);
$insertStmt->bindValue(':running_balance', $runningBalance);
$insertStmt->execute();
}
}
@@ -250,8 +253,8 @@ function fetchAndStoreLogPage($pdo, $user, $url) {
validateApiResponse($responseData);
$insertStmt = $pdo->prepare(
'INSERT INTO vault (id, user, timestamp, description, amount) '
. 'VALUES (:id, :user, :timestamp, :description, :amount) '
'INSERT INTO vault (id, user, timestamp, description, amount, running_balance) '
. 'VALUES (:id, :user, :timestamp, :description, :amount, :running_balance) '
. 'ON CONFLICT(id) DO NOTHING'
);