From a120d41612d948840d660f4582dbc3ce4ef9fb6d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 20 May 2013 20:01:45 +0200 Subject: [PATCH] lets try to get around some rounding issue for balance and transactions --- cronjobs/auto_payout.php | 2 ++ cronjobs/pps_payout.php | 2 +- public/include/classes/transaction.class.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cronjobs/auto_payout.php b/cronjobs/auto_payout.php index fef0d484..3454ad9c 100755 --- a/cronjobs/auto_payout.php +++ b/cronjobs/auto_payout.php @@ -62,6 +62,8 @@ if (! empty($users)) { } else { verbose("FAILED\n"); } + } else { + verbose("SKIPPED\n"); } } } else { diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 8f7a08d7..329104c5 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -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" . diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 465e9a0f..5fff814b 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -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