From efdbff8e5329b456b9d0a7481d5533fd6178d8c4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 7 Jun 2013 20:07:55 +0200 Subject: [PATCH 1/2] Do not include unconfirmed transactions in balance view This will fix #139 showing wrong liquid asset counts. Since that was confusing I ensured confirmations are included in the calculations. --- public/include/classes/transaction.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 020140d3..e4ff684e 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -142,7 +142,9 @@ class Transaction { ( SELECT sum(t.amount) AS credit FROM $this->table AS t + LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE t.type = 'Credit' + AND b.confirmations >= " . $this->config['confirmations'] . " ) AS t1, ( SELECT sum(t.amount) AS debit @@ -152,7 +154,9 @@ class Transaction { ( SELECT sum(t.amount) AS other FROM " . $this->table . " AS t + LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE t.type IN ('Donation','Fee') + AND b.confirmations >= " . $this->config['confirmations'] . " ) AS t3"); if ($this->checkStmt($stmt) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch()) return $dBalance; From 02eb400de9dbbeac1860a95d40e3e645448ce074 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 7 Jun 2013 20:09:54 +0200 Subject: [PATCH 2/2] proper whitespacing --- public/include/classes/transaction.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index e4ff684e..a487e5ec 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -142,9 +142,9 @@ class Transaction { ( SELECT sum(t.amount) AS credit FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id + LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE t.type = 'Credit' - AND b.confirmations >= " . $this->config['confirmations'] . " + AND b.confirmations >= " . $this->config['confirmations'] . " ) AS t1, ( SELECT sum(t.amount) AS debit @@ -154,9 +154,9 @@ class Transaction { ( SELECT sum(t.amount) AS other FROM " . $this->table . " AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id + LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE t.type IN ('Donation','Fee') - AND b.confirmations >= " . $this->config['confirmations'] . " + AND b.confirmations >= " . $this->config['confirmations'] . " ) AS t3"); if ($this->checkStmt($stmt) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch()) return $dBalance;