diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php index 3e9136e434..f604fc7ee4 100644 --- a/app/Api/V1/Controllers/Chart/AccountController.php +++ b/app/Api/V1/Controllers/Chart/AccountController.php @@ -149,7 +149,7 @@ class AccountController extends Controller foreach ($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/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 69e1c1431d..a3518a925a 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -491,13 +491,13 @@ class BudgetController extends Controller // get budget limit in this period for this currency. $limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd); if (null !== $limit) { - $chartData[1]['entries'][$title] = round($limit->amount, $currency->decimal_places); + $chartData[1]['entries'][$title] = round((float) $limit->amount, $currency->decimal_places); } // get spent amount in this period for this currency. $sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency); $amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0'); - $chartData[0]['entries'][$title] = round($amount, $currency->decimal_places); + $chartData[0]['entries'][$title] = round((float) $amount, $currency->decimal_places); $currentStart = clone $currentEnd; $currentStart->addDay()->startOfDay(); @@ -543,7 +543,7 @@ class BudgetController extends Controller $title = $currentStart->formatLocalized($titleFormat); $sum = $this->nbRepository->sumExpenses($currentStart, $currentEnd, $accounts, $currency); $amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0'); - $chartData[$title] = round($amount, $currency->decimal_places); + $chartData[$title] = round((float) $amount, $currency->decimal_places); $currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0); } diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php index c6332d14b2..5c24bd889d 100644 --- a/app/Http/Controllers/Chart/ReportController.php +++ b/app/Http/Controllers/Chart/ReportController.php @@ -236,8 +236,8 @@ class ReportController extends Controller while ($currentStart <= $end) { $key = $currentStart->format($format); $title = $currentStart->formatLocalized($titleFormat); - $income['entries'][$title] = round($currency[$key]['earned'] ?? '0', $currency['currency_decimal_places']); - $expense['entries'][$title] = round($currency[$key]['spent'] ?? '0', $currency['currency_decimal_places']); + $income['entries'][$title] = round((float) ($currency[$key]['earned'] ?? '0'), $currency['currency_decimal_places']); + $expense['entries'][$title] = round((float) ($currency[$key]['spent'] ?? '0'), $currency['currency_decimal_places']); $currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0); } diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php index 79d0a0779d..80e4029f09 100644 --- a/app/Http/Controllers/Json/ReconcileController.php +++ b/app/Http/Controllers/Json/ReconcileController.php @@ -192,8 +192,8 @@ class ReconcileController extends Controller $startDate->subDay(); $currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); - $startBalance = round(app('steam')->balance($account, $startDate), $currency->decimal_places); - $endBalance = round(app('steam')->balance($account, $end), $currency->decimal_places); + $startBalance = round((float) app('steam')->balance($account, $startDate), $currency->decimal_places); + $endBalance = round((float) app('steam')->balance($account, $end), $currency->decimal_places); // get the transactions $selectionStart = clone $start; diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php index e7d51ac5f7..27e9e4f1a8 100644 --- a/app/Http/Controllers/Report/BudgetController.php +++ b/app/Http/Controllers/Report/BudgetController.php @@ -265,7 +265,7 @@ class BudgetController extends Controller $total = $sums[$currencyId]['sum'] ?? '0'; $pct = '0'; if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) { - $pct = round(bcmul(bcdiv($sum, $total), '100')); + $pct = round((float) bcmul(bcdiv($sum, $total), '100')); } $report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct; } diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php index 6e78f706ba..4f9852d597 100644 --- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php +++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php @@ -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($leftOnAccount, 12), round($leftToSave, 12)); + $maxAmount = (string)min(round((float) $leftOnAccount, 12), round($leftToSave, 12)); $compare = bccomp($amount, $maxAmount); $result = $compare <= 0; diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.php index d7149e93d9..c6c7c45bd4 100644 --- a/app/Support/Chart/Category/WholePeriodChartGenerator.php +++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php @@ -119,8 +119,8 @@ class WholePeriodChartGenerator $earnedInfoKey = sprintf('earned-in-%s', $code); $spentAmount = $spent[$key][$currencyId]['sum'] ?? '0'; $earnedAmount = $earned[$key][$currencyId]['sum'] ?? '0'; - $chartData[$spentInfoKey]['entries'][$label] = round($spentAmount, $currency['currency_decimal_places']); - $chartData[$earnedInfoKey]['entries'][$label] = round($earnedAmount, $currency['currency_decimal_places']); + $chartData[$spentInfoKey]['entries'][$label] = round((float) $spentAmount, $currency['currency_decimal_places']); + $chartData[$earnedInfoKey]['entries'][$label] = round((float) $earnedAmount, $currency['currency_decimal_places']); } $current = app('navigation')->addPeriod($current, $step, 0); } diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php index a92b013279..dacf236793 100644 --- a/app/Support/ExpandedForm.php +++ b/app/Support/ExpandedForm.php @@ -59,7 +59,7 @@ class ExpandedForm // make sure value is formatted nicely: if (null !== $value && '' !== $value) { - $value = round($value, 8); + $value = round((float) $value, 8); } try { $html = view('form.amount-no-currency', compact('classes', 'name', 'label', 'value', 'options'))->render(); @@ -252,7 +252,7 @@ class ExpandedForm // make sure value is formatted nicely: if (null !== $value && '' !== $value) { - $value = round($value, $selectedCurrency->decimal_places); + $value = round((float) $value, $selectedCurrency->decimal_places); } try { $html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render(); diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php index 32e15793d0..f6faa0b0ab 100644 --- a/app/Support/Form/CurrencyForm.php +++ b/app/Support/Form/CurrencyForm.php @@ -151,7 +151,7 @@ class CurrencyForm // make sure value is formatted nicely: if (null !== $value && '' !== $value) { - $value = round($value, $defaultCurrency->decimal_places); + $value = round((float) $value, $defaultCurrency->decimal_places); } try { $html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render(); @@ -202,7 +202,7 @@ class CurrencyForm // make sure value is formatted nicely: if (null !== $value && '' !== $value) { - $value = round($value, $defaultCurrency->decimal_places); + $value = round((float) $value, $defaultCurrency->decimal_places); } try { $html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render(); diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php index b2d900bc9b..40b1e24fa9 100644 --- a/app/Support/Report/Budget/BudgetReportGenerator.php +++ b/app/Support/Report/Budget/BudgetReportGenerator.php @@ -310,10 +310,10 @@ class BudgetReportGenerator $budgetedPct = '0'; if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) { - $spentPct = round(bcmul(bcdiv($spent, $totalSpent), '100')); + $spentPct = round((float) bcmul(bcdiv($spent, $totalSpent), '100')); } if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) { - $budgetedPct = round(bcmul(bcdiv($budgeted, $totalBudgeted), '100')); + $budgetedPct = round((float) bcmul(bcdiv($budgeted, $totalBudgeted), '100')); } $this->report['sums'][$currencyId]['budgeted'] = $this->report['sums'][$currencyId]['budgeted'] ?? '0'; $this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;