lets try to get around some rounding issue for balance and transactions

This commit is contained in:
Sebastian Grewe 2013-05-20 20:01:45 +02:00
parent 0f379d8b11
commit a120d41612
3 changed files with 4 additions and 2 deletions

View File

@ -62,6 +62,8 @@ if (! empty($users)) {
} else {
verbose("FAILED\n");
}
} else {
verbose("SKIPPED\n");
}
}
} else {

View File

@ -65,7 +65,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
$aData['payout'] = number_format(round(( $aData['percentage'] / 100 ) * $config['reward'], 8), 8);
// Calculate donation amount for Donation transaction
$aData['donation'] = $user->getDonatePercent($user->getUserId($aData['username'])) / 100 * $aData['payout'];
$aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * $aData['payout'], 8), 8);
// Verbose output of this users calculations
verbose($aData['id'] . "\t" .

View File

@ -76,7 +76,7 @@ class Transaction {
public function getBalance($account_id) {
$stmt = $this->mysqli->prepare("
SELECT IFNULL(t1.credit, 0) - IFNULL(t2.debit, 0) - IFNULL(t3.other, 0) AS balance
SELECT ROUND(IFNULL(t1.credit, 0) - IFNULL(t2.debit, 0) - IFNULL(t3.other, 0), 8) AS balance
FROM
(
SELECT sum(t.amount) AS credit