Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add exception code for bad values.
James Cole610bc9f4bc23
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex b905734676..2004c46515 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -614,10 +614,9 @@ class OperatorQuerySearch implements SearchInterface// amount//case 'amount_is':-// strip comma's, make dots.+ Log::debug(sprintf('Original value "%s"', $value));$value = str_replace(',', '.', (string) $value);-$amount = app('steam')->positive($value);Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));$this->collector->amountIs($amount);diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 43d2be481e..bb3fe857f3 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -34,6 +34,7 @@ use JsonException;use Log;use stdClass;use Str;+use ValueError;/*** Class Steam.@@ -627,8 +628,14 @@ class Steamif ('' === $amount) {return '0';}- if (bccomp($amount, '0') === -1) {- $amount = bcmul($amount, '-1');+ try {+ if (bccomp($amount, '0') === -1) {+ $amount = bcmul($amount, '-1');+ }+ } catch (ValueError $e) {+ Log::error(sprintf('ValueError in Steam::positive("%s"): %s', $amount, $e->getMessage()));+ Log::error($e->getTraceAsString());+ return '0';}return $amount;