From 4733944f2fbbf80ca5be379347089193b84c47f4 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Mon, 10 May 2021 18:57:10 +0000 Subject: [PATCH] fix bug in merged code --- .../src/Model/Table/TransactionsTable.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 3bccb7bbf..742ce7882 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -184,21 +184,21 @@ class TransactionsTable extends Table $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 - $diff_amount); + $balance = floatval($prev->balance - $calculated_decay['balance']); // skip small decays (smaller than 0,00 GDD) 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' => floatval($prev->balance - $calculated_decay['balance']), - 'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), - 'memo' => '' - ]; + //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' => '' + ]; + } } } - } // sender or receiver when user has sended money // group name if creation @@ -269,17 +269,17 @@ class TransactionsTable extends Table if($decay_start_date > $su_transaction->balance_date) { $duration = $decay_start_date->timeAgoInWords(); } - $balance = floatval($su_transaction->balance - $state_balance->decay); + $balance = floatval($su_transaction->balance - $calculated_decay['balance']); if($balance > 100) { - $final_transactions[] = [ - 'type' => 'decay', - 'balance' => floatval($su_transaction->balance - $calculated_decay['balance']), - 'decay_duration' => $duration, - 'memo' => '' - ]; + $final_transactions[] = [ + 'type' => 'decay', + 'balance' => $balance, + 'decay_duration' => $duration, + 'memo' => '' + ]; + } } } - } return $final_transactions;