[UPDATE] Do not round balances from SQL

This commit is contained in:
Sebastian Grewe 2014-06-30 09:07:16 +02:00
parent 52dcd05c99
commit 2f2b3f578c

View File

@ -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