[FIX] Do not include orphans in transaction summary

This commit is contained in:
Sebastian Grewe 2013-10-27 02:18:49 +01:00
parent d23358a2f7
commit 1d180c3e3d

View File

@ -53,9 +53,17 @@ class Transaction extends Base {
* @return data array type and total
**/
public function getTransactionSummary($account_id=NULL) {
$sql = "SELECT SUM(t.amount) AS total, t.type AS type FROM $this->table AS t";
$sql = "
SELECT
SUM(t.amount) AS total, t.type AS type
FROM transactions AS t
LEFT OUTER JOIN blocks AS b
ON b.id = t.block_id
WHERE b.confirmations > 0
OR b.id IS NULL
";
if (!empty($account_id)) {
$sql .= " WHERE t.account_id = ? ";
$sql .= " AND t.account_id = ? ";
$this->addParam('i', $account_id);
}
$sql .= " GROUP BY t.type";