diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.php index 9fee614b95..6270038851 100644 --- a/app/Console/Commands/UpgradeDatabase.php +++ b/app/Console/Commands/UpgradeDatabase.php @@ -219,7 +219,7 @@ class UpgradeDatabase extends Command } // when mismatch in transaction: - if ($transaction->transaction_currency_id !== $currency->id) { + if (!(intval($transaction->transaction_currency_id) === intval($currency->id))) { $transaction->foreign_currency_id = $transaction->transaction_currency_id; $transaction->foreign_amount = $transaction->amount; $transaction->transaction_currency_id = $currency->id; @@ -402,14 +402,14 @@ class UpgradeDatabase extends Command // has no currency ID? Must have, so fill in using account preference: if (null === $transaction->transaction_currency_id) { - $transaction->transaction_currency_id = $currency->id; + $transaction->transaction_currency_id = intval($currency->id); Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code)); $transaction->save(); } // does not match the source account (see above)? Can be fixed // when mismatch in transaction and NO foreign amount is set: - if ($transaction->transaction_currency_id !== $currency->id && null === $transaction->foreign_amount) { + if (!(intval($transaction->transaction_currency_id) === intval($currency->id)) && null === $transaction->foreign_amount) { Log::debug( sprintf( 'Transaction #%d has a currency setting (#%d) (%s) that should be #%d (%s). Amount remains %s, currency is changed.', @@ -421,7 +421,7 @@ class UpgradeDatabase extends Command $transaction->amount ) ); - $transaction->transaction_currency_id = $currency->id; + $transaction->transaction_currency_id = intval($currency->id); $transaction->save(); } @@ -439,7 +439,7 @@ class UpgradeDatabase extends Command } // if the destination account currency is the same, both foreign_amount and foreign_currency_id must be NULL for both transactions: - if ($opposingCurrency->id === $currency->id) { + if (intval($opposingCurrency->id) === intval($currency->id)) { // update both transactions to match: $transaction->foreign_amount = null; $transaction->foreign_currency_id = null; @@ -453,7 +453,7 @@ class UpgradeDatabase extends Command return; } // if destination account currency is different, both transactions must have this currency as foreign currency id. - if ($opposingCurrency->id !== $currency->id) { + if (!(intval($opposingCurrency->id) === intval($currency->id))) { $transaction->foreign_currency_id = $opposingCurrency->id; $opposing->foreign_currency_id = $opposingCurrency->id; $transaction->save(); @@ -516,7 +516,7 @@ class UpgradeDatabase extends Command $content = ob_get_contents(); ob_end_clean(); - return $content; + return trim($content); } }