From 617b3648f4006f447347ff22a7e1bab1efac1af7 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 14 Jun 2021 10:54:32 +0200 Subject: [PATCH 1/2] remove check decays for being at least 100 GDD cent - remove debugging lines and empty lines --- .../src/Model/Table/TransactionsTable.php | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index c4bc4b698..5b4099c34 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -178,25 +178,18 @@ class TransactionsTable extends Table } if($prev && $decay == true) { - if($prev->balance > 0) { - // var_dump($stateUserTransactions); $current = $su_transaction; - //echo "decay between " . $prev->transaction_id . " and " . $current->transaction_id . "
"; + $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); - $balance = floatval($prev->balance - $calculated_decay['balance']); - // skip small decays (smaller than 0,00 GDD) + $balance = floatval($prev->balance - $calculated_decay['balance']); - if(abs($balance) >= 100) { - //echo $interval->format('%R%a days'); - //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "
"; - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), - 'memo' => '' - ]; - } + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), + 'memo' => '' + ]; } } @@ -207,9 +200,7 @@ class TransactionsTable extends Table // date // balance $transaction = $transaction_indiced[$su_transaction->transaction_id]; - /*echo "transaction:
"; - var_dump($transaction); - echo "
";*/ + if($su_transaction->transaction_type_id == 1) { // creation $creation = $transaction->transaction_creation; $balance = $stateBalancesTable->calculateDecay($creation->amount, $creation->target_date, $transaction->received); @@ -270,15 +261,14 @@ class TransactionsTable extends Table $duration = $decay_start_date->timeAgoInWords(); } $balance = floatval($su_transaction->balance - $calculated_decay['balance']); - if($balance > 100) { - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $duration, - 'last_decay' => true, - 'memo' => '' - ]; - } + + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $duration, + 'last_decay' => true, + 'memo' => '' + ]; } } From c2d91a20967b4eb99ff037128edb18de11bba81c Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Mon, 14 Jun 2021 11:51:21 +0200 Subject: [PATCH 2/2] add checking at least that decay balance is more than 0 --- .../src/Model/Table/TransactionsTable.php | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 5b4099c34..7e59c2d88 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -184,12 +184,15 @@ class TransactionsTable extends Table $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); $balance = floatval($prev->balance - $calculated_decay['balance']); - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), - 'memo' => '' - ]; + if($balance) + { + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), + 'memo' => '' + ]; + } } } @@ -262,13 +265,16 @@ class TransactionsTable extends Table } $balance = floatval($su_transaction->balance - $calculated_decay['balance']); - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => $balance, - 'decay_duration' => $duration, - 'last_decay' => true, - 'memo' => '' - ]; + if($balance) + { + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $duration, + 'last_decay' => true, + 'memo' => '' + ]; + } } }