WiP to disable fees for specific accounts

* added new account table column: `no_fee`
* honor `no_fee` flag during payout process
* added upgrade SQL file for this feature

Address #260
This commit is contained in:
Sebastian Grewe 2013-07-17 11:21:20 +02:00
parent 44c31fe630
commit 3cfef93580
5 changed files with 6 additions and 3 deletions

View File

@ -130,7 +130,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
$aData['fee' ] = 0;
$aData['donation'] = 0;
if ($config['fees'] > 0)
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8);
// Calculate donation amount, fees not included
$aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8);

View File

@ -72,7 +72,7 @@ foreach ($aAccountShares as $aData) {
$aData['donation'] = 0;
// Calculate block fees
if ($config['fees'] > 0)
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8);
// Calculate donation amount
$aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8);

View File

@ -66,7 +66,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
$aData['fee' ] = 0;
$aData['donation'] = 0;
if ($config['fees'] > 0)
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8);
// Calculate donation amount, fees not included
$aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8);

View File

@ -97,6 +97,7 @@ class Share {
SELECT
a.id,
SUBSTRING_INDEX( s.username , '.', 1 ) as username,
a.no_fees AS no_fees,
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid
FROM $this->table AS s
@ -135,6 +136,7 @@ class Share {
SELECT
a.id,
SUBSTRING_INDEX( s.username , '.', 1 ) as account,
a.no_fees AS no_fees,
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid
FROM $this->tableArchive AS s

View File

@ -0,0 +1 @@
ALTER TABLE `accounts` ADD `no_fees` BOOLEAN NOT NULL DEFAULT FALSE AFTER `is_anonymous` ;