Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix round() call for PHP 8.0
James Cole21619544f58d
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.phpindex edebaaf010..3e9136e434 100644--- a/app/Api/V1/Controllers/Chart/AccountController.php+++ b/app/Api/V1/Controllers/Chart/AccountController.php@@ -206,11 +206,11 @@ class AccountController extends Controller/** @var Carbon $currentStart */$currentStart = clone $start;$range = app('steam')->balanceInRange($account, $start, clone $end);- $previous = round(array_values($range)[0], 12);+ $previous = round((float) array_values($range)[0], 12);while ($currentStart <= $end) {$format = $currentStart->format('Y-m-d');$label = $currentStart->format('Y-m-d');- $balance = array_key_exists($format, $range) ? round($range[$format], 12) : $previous;+ $balance = array_key_exists($format, $range) ? round((float) $range[$format], 12) : $previous;$previous = $balance;$currentStart->addDay();$currentSet['entries'][$label] = $balance;@@ -300,7 +300,7 @@ class AccountController extends Controllerforeach ($tempData as $entry) {$currencyId = $entry['currency_id'];$name = $entry['name'];- $chartData[$currencyId]['entries'][$name] = round($entry['difference'], $chartData[$currencyId]['currency_decimal_places']);+ $chartData[$currencyId]['entries'][$name] = round((float) $entry['difference'], $chartData[$currencyId]['currency_decimal_places']);}$chartData = array_values($chartData);diff --git a/app/Api/V1/Controllers/Chart/AvailableBudgetController.php b/app/Api/V1/Controllers/Chart/AvailableBudgetController.phpindex e299a504f4..0d9ba69a34 100644--- a/app/Api/V1/Controllers/Chart/AvailableBudgetController.php+++ b/app/Api/V1/Controllers/Chart/AvailableBudgetController.php@@ -105,7 +105,7 @@ class AvailableBudgetController extends Controller'currency_decimal_places' => $currency->decimal_places,'type' => 'line', // line, area or bar'yAxisID' => 0, // 0, 1, 2- 'entries' => [round($left, $currency->decimal_places)],+ 'entries' => [round((float) $left, $currency->decimal_places)],],];diff --git a/app/Api/V1/Controllers/SummaryController.php b/app/Api/V1/Controllers/SummaryController.phpindex 56ebbff539..ad3957cbd8 100644--- a/app/Api/V1/Controllers/SummaryController.php+++ b/app/Api/V1/Controllers/SummaryController.php@@ -185,7 +185,7 @@ class SummaryController extends Controller$return[] = ['key' => sprintf('balance-in-%s', $currency->code),'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),- 'monetary_value' => round($sums[$currencyId] ?? 0, $currency->decimal_places),+ 'monetary_value' => round((float) $sums[$currencyId] ?? 0, $currency->decimal_places),'currency_id' => $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,@@ -198,7 +198,7 @@ class SummaryController extends Controller$return[] = ['key' => sprintf('spent-in-%s', $currency->code),'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),- 'monetary_value' => round($expenses[$currencyId] ?? 0, $currency->decimal_places),+ 'monetary_value' => round((float) $expenses[$currencyId] ?? 0, $currency->decimal_places),'currency_id' => $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,@@ -210,7 +210,7 @@ class SummaryController extends Controller$return[] = ['key' => sprintf('earned-in-%s', $currency->code),'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),- 'monetary_value' => round($incomes[$currencyId] ?? 0, $currency->decimal_places),+ 'monetary_value' => round((float) $incomes[$currencyId] ?? 0, $currency->decimal_places),'currency_id' => $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,@@ -248,7 +248,7 @@ class SummaryController extends Controller$return[] = ['key' => sprintf('bills-paid-in-%s', $currency->code),'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $currency->symbol]),- 'monetary_value' => round($amount, $currency->decimal_places),+ 'monetary_value' => round((float) $amount, $currency->decimal_places),'currency_id' => $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,@@ -268,7 +268,7 @@ class SummaryController extends Controller$return[] = ['key' => sprintf('bills-unpaid-in-%s', $currency->code),'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $currency->symbol]),- 'monetary_value' => round($amount, $currency->decimal_places),+ 'monetary_value' => round((float) $amount, $currency->decimal_places),'currency_id' => $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,@@ -312,7 +312,7 @@ class SummaryController extends Controller$return[] = ['key' => sprintf('left-to-spend-in-%s', $row['currency_code']),'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),- 'monetary_value' => round($leftToSpend, $row['currency_decimal_places']),+ 'monetary_value' => round((float) $leftToSpend, $row['currency_decimal_places']),'currency_id' => $row['currency_id'],'currency_code' => $row['currency_code'],'currency_symbol' => $row['currency_symbol'],@@ -372,7 +372,7 @@ class SummaryController extends Controllerforeach ($netWorthSet as $data) {/** @var TransactionCurrency $currency */$currency = $data['currency'];- $amount = round($data['balance'], $currency->decimal_places);+ $amount = round((float) $data['balance'], $currency->decimal_places);if (0.0 === $amount) {continue;}diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.phpindex 39e4fcf787..1df9f7e456 100644--- a/app/Support/Chart/Category/FrontpageChartGenerator.php+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php@@ -40,20 +40,14 @@ use Illuminate\Support\Collection;class FrontpageChartGenerator{use AugumentData;- /** @var AccountRepositoryInterface */- private $accountRepos;- /** @var array */- private $currencies;- /** @var Carbon */- private $end;- /** @var NoCategoryRepositoryInterface */- private $noCatRepos;- /** @var OperationsRepositoryInterface */- private $opsRepos;- /** @var CategoryRepositoryInterface */- private $repository;- /** @var Carbon */- private $start;++ private AccountRepositoryInterface $accountRepos;+ private array $currencies;+ private Carbon $end;+ private NoCategoryRepositoryInterface $noCatRepos;+ private OperationsRepositoryInterface $opsRepos;+ private CategoryRepositoryInterface $repository;+ private Carbon $start;/*** FrontpageChartGenerator constructor.@@ -110,7 +104,7 @@ class FrontpageChartGenerator*/private function addCurrency(array $currency): void{- $currencyId = (int) $currency['currency_id'];+ $currencyId = (int)$currency['currency_id'];$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? ['currency_id' => $currencyId,@@ -136,8 +130,8 @@ class FrontpageChartGenerator$tempData[] = ['name' => $category->name,'sum' => $currency['sum'],- 'sum_float' => round($currency['sum'], $currency['currency_decimal_places']),- 'currency_id' => (int) $currency['currency_id'],+ 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places']),+ 'currency_id' => (int)$currency['currency_id'],];}@@ -158,8 +152,8 @@ class FrontpageChartGenerator$tempData[] = ['name' => trans('firefly.no_category'),'sum' => $currency['sum'],- 'sum_float' => round($currency['sum'], $currency['currency_decimal_places'] ?? 2),- 'currency_id' => (int) $currency['currency_id'],+ 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places'] ?? 2),+ 'currency_id' => (int)$currency['currency_id'],];}@@ -181,7 +175,7 @@ class FrontpageChartGeneratorforeach ($this->currencies as $currencyId => $currency) {$key = sprintf('spent-%d', $currencyId);$return[$key] = [- 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currency['currency_name']),+ 'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currency['currency_name']),'type' => 'bar','currency_symbol' => $currency['currency_symbol'],'entries' => $names,