Merge pull request #768 from TheSerapher/issue-767
[FIX] Do not include orphans in transaction summary
This commit is contained in:
commit
7bfa2f590c
@ -53,9 +53,17 @@ class Transaction extends Base {
|
|||||||
* @return data array type and total
|
* @return data array type and total
|
||||||
**/
|
**/
|
||||||
public function getTransactionSummary($account_id=NULL) {
|
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)) {
|
if (!empty($account_id)) {
|
||||||
$sql .= " WHERE t.account_id = ? ";
|
$sql .= " AND t.account_id = ? ";
|
||||||
$this->addParam('i', $account_id);
|
$this->addParam('i', $account_id);
|
||||||
}
|
}
|
||||||
$sql .= " GROUP BY t.type";
|
$sql .= " GROUP BY t.type";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user