Remove many references to (float)

This commit is contained in:
James Cole
2022-12-24 05:06:39 +01:00
parent e43372b2ce
commit c47980a737
41 changed files with 230 additions and 208 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* FrontpageController.php
* Copyright (c) 2019 james@firefly-iii.org
@@ -37,7 +38,7 @@ class FrontpageController extends Controller
/**
* Piggy bank pie chart.
*
* @param PiggyBankRepositoryInterface $repository
* @param PiggyBankRepositoryInterface $repository
*
* @return JsonResponse
*/
@@ -51,7 +52,7 @@ class FrontpageController extends Controller
if (1 === bccomp($amount, '0')) {
// percentage!
$pct = 0;
if (0.0 !== (float) $piggyBank->targetamount) {
if (0 !== bccomp($piggyBank->targetamount, '0')) {
$pct = round(($amount / $piggyBank->targetamount) * 100);
}
@@ -70,12 +71,10 @@ class FrontpageController extends Controller
if (!empty($info)) {
try {
$html = view('json.piggy-banks', compact('info'))->render();
} catch (Throwable $e) { // @phpstan-ignore-line
Log::error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage()));
$html = 'Could not render view.';
}
}
return response()->json(['html' => $html]);

View File

@@ -238,8 +238,8 @@ class ReconcileController extends Controller
$startDate->subDay();
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
$startBalance = round((float) app('steam')->balance($account, $startDate), $currency->decimal_places);
$endBalance = round((float) app('steam')->balance($account, $end), $currency->decimal_places);
$startBalance = app('steam')->bcround(app('steam')->balance($account, $startDate), $currency->decimal_places);
$endBalance = app('steam')->bcround(app('steam')->balance($account, $end), $currency->decimal_places);
// get the transactions
$selectionStart = clone $start;