Fix cast error in PHP 8.0

This commit is contained in:
James Cole 2020-12-25 12:45:34 +01:00
parent 232cc39325
commit b34f16535c
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
2 changed files with 4 additions and 2 deletions

View File

@ -95,7 +95,7 @@ class IndexController extends Controller
Log::debug('Start of IndexController::index()');
// collect some basic vars:
$range = app('preferences')->get('viewRange', '1M')->data;
$range = (string) app('preferences')->get('viewRange', '1M')->data;
$start = $start ?? session('start', Carbon::now()->startOfMonth());
$end = $end ?? app('navigation')->endOfPeriod($start, $range);
$defaultCurrency = app('amount')->getDefaultCurrency();
@ -276,6 +276,7 @@ class IndexController extends Controller
// complement budget with budget limits in range, and expenses in currency X in range.
/** @var Budget $current */
foreach ($collection as $current) {
Log::debug(sprintf('Working on budget #%d ("%s")', $current->id, $current->name));
$array = $current->toArray();
$array['spent'] = [];
$array['budgeted'] = [];
@ -284,6 +285,7 @@ class IndexController extends Controller
$budgetLimits = $this->blRepository->getBudgetLimits($current, $start, $end);
/** @var BudgetLimit $limit */
foreach ($budgetLimits as $limit) {
Log::debug(sprintf('Working on budget limit #%d', $limit->id));
$currency = $limit->transactionCurrency ?? $defaultCurrency;
$array['budgeted'][] = [
'id' => $limit->id,

View File

@ -105,7 +105,7 @@ trait ModifiesPiggyBanks
$leftOnAccount = $this->leftOnAccount($piggyBank, today(config('app.timezone')));
$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
$maxAmount = (string)min(round((float) $leftOnAccount, 12), round($leftToSave, 12));
$maxAmount = (string)min(round((float) $leftOnAccount, 12), round((float)$leftToSave, 12));
$compare = bccomp($amount, $maxAmount);
$result = $compare <= 0;