Better compare for amounts because floatval can be inaccurate.

This commit is contained in:
James Cole 2015-07-17 17:35:04 +02:00
parent 31114a2ca5
commit ce5beeaf2c

View File

@ -252,13 +252,13 @@ class JournalRepository implements JournalRepositoryInterface
// update the from and to transaction.
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
if (floatval($transaction->amount) < 0) {
if ($transaction->amount < 0) {
// this is the from transaction, negative amount:
$transaction->amount = $data['amount'] * -1;
$transaction->account_id = $fromAccount->id;
$transaction->save();
}
if (floatval($transaction->amount) > 0) {
if ($transaction->amount > 0) {
$transaction->amount = $data['amount'];
$transaction->account_id = $toAccount->id;
$transaction->save();