mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-30 10:47:06 -06:00
Add exception code for bad values.
This commit is contained in:
parent
3d1233314a
commit
610bc9f4bc
@ -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);
|
||||
|
@ -34,6 +34,7 @@ use JsonException;
|
||||
use Log;
|
||||
use stdClass;
|
||||
use Str;
|
||||
use ValueError;
|
||||
|
||||
/**
|
||||
* Class Steam.
|
||||
@ -627,8 +628,14 @@ class Steam
|
||||
if ('' === $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;
|
||||
|
Loading…
Reference in New Issue
Block a user