From 2f2b3f578cd085f567e01fabd54594522e0a0d0f Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 30 Jun 2014 09:07:16 +0200 Subject: [PATCH] [UPDATE] Do not round balances from SQL --- include/classes/transaction.class.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/include/classes/transaction.class.php b/include/classes/transaction.class.php index d01b53e3..990a6555 100644 --- a/include/classes/transaction.class.php +++ b/include/classes/transaction.class.php @@ -296,11 +296,11 @@ class Transaction extends Base { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT - ROUND(( + ( SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR t.type = 'Credit_PPS', t.amount, 0 ) ) - SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) - ), 8) AS balance + ) AS balance FROM $this->table AS t LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id @@ -319,19 +319,19 @@ class Transaction extends Base { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT - IFNULL(ROUND(( + IFNULL(( SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR t.type = 'Credit_PPS', t.amount, 0 ) ) - SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) - ), 8), 0) AS confirmed, - IFNULL(ROUND(( + ), 0) AS confirmed, + IFNULL(( SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) - SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) - ), 8), 0) AS unconfirmed, - IFNULL(ROUND(( + ), 0) AS unconfirmed, + IFNULL(( SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations = -1, t.amount, 0) ) - SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations = -1, t.amount, 0) ) - ), 8), 0) AS orphaned + ), 0) AS orphaned FROM $this->table AS t LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id @@ -357,12 +357,10 @@ class Transaction extends Base { a.ap_threshold, a.coin_address, IFNULL( - ROUND( ( SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= " . $this->config['confirmations'] . ") OR t.type = 'Credit_PPS', t.amount, 0 ) ) - SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= " . $this->config['confirmations'] . ") OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) - ), 8 ), 0 ) AS confirmed FROM $this->table AS t @@ -449,12 +447,10 @@ class Transaction extends Base { a.coin_address, p.id AS payout_id, IFNULL( - ROUND( ( SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= " . $this->config['confirmations'] . ") OR t.type = 'Credit_PPS', t.amount, 0 ) ) - SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= " . $this->config['confirmations'] . ") OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) - ), 8 ), 0 ) AS confirmed FROM " . $this->payout->getTableName() . " AS p