add checking at least that decay balance is more than 0

This commit is contained in:
einhorn_b 2021-06-14 11:51:21 +02:00
parent 617b3648f4
commit c2d91a2096

View File

@ -184,12 +184,15 @@ class TransactionsTable extends Table
$calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true);
$balance = floatval($prev->balance - $calculated_decay['balance']); $balance = floatval($prev->balance - $calculated_decay['balance']);
$final_transactions[] = [ if($balance)
'type' => 'decay', {
'balance' => $balance, $final_transactions[] = [
'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'), 'type' => 'decay',
'memo' => '' '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']); $balance = floatval($su_transaction->balance - $calculated_decay['balance']);
$final_transactions[] = [ if($balance)
'type' => 'decay', {
'balance' => $balance, $final_transactions[] = [
'decay_duration' => $duration, 'type' => 'decay',
'last_decay' => true, 'balance' => $balance,
'memo' => '' 'decay_duration' => $duration,
]; 'last_decay' => true,
'memo' => ''
];
}
} }
} }