From 382131c413a7f7ea12312c1d7a11051ddcc11a2d Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 3 May 2016 13:40:16 +0200 Subject: [PATCH] Fix displayed pending amount in user wallet There was a (UI only) difference between details and total. note: the paid amount was correct (the one showed in show details) --- web/yaamp/core/exchange/exchange.php | 7 +++++ web/yaamp/core/functions/yaamp.php | 8 +++--- .../modules/site/results/wallet_results.php | 27 ++++++++++--------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/web/yaamp/core/exchange/exchange.php b/web/yaamp/core/exchange/exchange.php index 1f028aa..035c7a5 100644 --- a/web/yaamp/core/exchange/exchange.php +++ b/web/yaamp/core/exchange/exchange.php @@ -39,6 +39,13 @@ function getMarketUrl($coin, $marketName) $parts = explode(' ',$marketName); $market = $parts[0]; $base = $parts[1]; + if (empty($base)) { + debuglog("warning: invalid market name '$marketName'"); + $base = dboscalar( + "SELECT base_coin FROM markets WHERE coinid=:id AND name=:name", array( + ':id'=>$coin->id, ':name'=>$marketName, + )); + } } $lowbase = strtolower($base); diff --git a/web/yaamp/core/functions/yaamp.php b/web/yaamp/core/functions/yaamp.php index 8935a84..5a29fdc 100755 --- a/web/yaamp/core/functions/yaamp.php +++ b/web/yaamp/core/functions/yaamp.php @@ -293,12 +293,12 @@ function yaamp_convert_earnings_user($user, $status) $value = 0.; if (YAAMP_ALLOW_EXCHANGE) { if(!$refcoin) $refcoin = getdbosql('db_coins', "symbol='BTC'"); - if(!$refcoin || $refcoin->price2 <= 0) return 0; + if(!$refcoin || $refcoin->price <= 0) return 0; $value = dboscalar("SELECT sum(amount*price) FROM earnings WHERE $status AND userid={$user->id}"); - $value = $value / $refcoin->price2; - } else if ($refcoin && $refcoin->price2 > 0.) { + $value = $value / $refcoin->price; + } else if ($refcoin && $refcoin->price > 0.) { $value = dboscalar("SELECT sum(amount*price) FROM earnings WHERE $status AND userid={$user->id}"); - $value = $value / $refcoin->price2; + $value = $value / $refcoin->price; } else if ($user->coinid) { $value = dboscalar("SELECT sum(amount) FROM earnings WHERE $status AND userid={$user->id} AND coinid=".$user->coinid); } diff --git a/web/yaamp/modules/site/results/wallet_results.php b/web/yaamp/modules/site/results/wallet_results.php index 1ea2034..7954571 100644 --- a/web/yaamp/modules/site/results/wallet_results.php +++ b/web/yaamp/modules/site/results/wallet_results.php @@ -116,30 +116,31 @@ $total_pending = bitcoinvaluetoa($total_pending); if(!$show_details && $total_unsold > 0) { - echo " -