mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-27 03:10:32 -06:00
Fix round() calls for PHP 8.0
This commit is contained in:
parent
fe66bb1984
commit
670bf26510
@ -149,7 +149,7 @@ class AccountController extends Controller
|
|||||||
foreach ($tempData as $entry) {
|
foreach ($tempData as $entry) {
|
||||||
$currencyId = $entry['currency_id'];
|
$currencyId = $entry['currency_id'];
|
||||||
$name = $entry['name'];
|
$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);
|
$chartData = array_values($chartData);
|
||||||
|
|
||||||
|
@ -491,13 +491,13 @@ class BudgetController extends Controller
|
|||||||
// get budget limit in this period for this currency.
|
// get budget limit in this period for this currency.
|
||||||
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
|
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
|
||||||
if (null !== $limit) {
|
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.
|
// get spent amount in this period for this currency.
|
||||||
$sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency);
|
$sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency);
|
||||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
$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 = clone $currentEnd;
|
||||||
$currentStart->addDay()->startOfDay();
|
$currentStart->addDay()->startOfDay();
|
||||||
@ -543,7 +543,7 @@ class BudgetController extends Controller
|
|||||||
$title = $currentStart->formatLocalized($titleFormat);
|
$title = $currentStart->formatLocalized($titleFormat);
|
||||||
$sum = $this->nbRepository->sumExpenses($currentStart, $currentEnd, $accounts, $currency);
|
$sum = $this->nbRepository->sumExpenses($currentStart, $currentEnd, $accounts, $currency);
|
||||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
$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);
|
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +236,8 @@ class ReportController extends Controller
|
|||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
$key = $currentStart->format($format);
|
$key = $currentStart->format($format);
|
||||||
$title = $currentStart->formatLocalized($titleFormat);
|
$title = $currentStart->formatLocalized($titleFormat);
|
||||||
$income['entries'][$title] = round($currency[$key]['earned'] ?? '0', $currency['currency_decimal_places']);
|
$income['entries'][$title] = round((float) ($currency[$key]['earned'] ?? '0'), $currency['currency_decimal_places']);
|
||||||
$expense['entries'][$title] = round($currency[$key]['spent'] ?? '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);
|
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +192,8 @@ class ReconcileController extends Controller
|
|||||||
$startDate->subDay();
|
$startDate->subDay();
|
||||||
|
|
||||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||||
$startBalance = round(app('steam')->balance($account, $startDate), $currency->decimal_places);
|
$startBalance = round((float) app('steam')->balance($account, $startDate), $currency->decimal_places);
|
||||||
$endBalance = round(app('steam')->balance($account, $end), $currency->decimal_places);
|
$endBalance = round((float) app('steam')->balance($account, $end), $currency->decimal_places);
|
||||||
|
|
||||||
// get the transactions
|
// get the transactions
|
||||||
$selectionStart = clone $start;
|
$selectionStart = clone $start;
|
||||||
|
@ -265,7 +265,7 @@ class BudgetController extends Controller
|
|||||||
$total = $sums[$currencyId]['sum'] ?? '0';
|
$total = $sums[$currencyId]['sum'] ?? '0';
|
||||||
$pct = '0';
|
$pct = '0';
|
||||||
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
|
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;
|
$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ trait ModifiesPiggyBanks
|
|||||||
$leftOnAccount = $this->leftOnAccount($piggyBank, today(config('app.timezone')));
|
$leftOnAccount = $this->leftOnAccount($piggyBank, today(config('app.timezone')));
|
||||||
$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
|
$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
$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);
|
$compare = bccomp($amount, $maxAmount);
|
||||||
$result = $compare <= 0;
|
$result = $compare <= 0;
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ class WholePeriodChartGenerator
|
|||||||
$earnedInfoKey = sprintf('earned-in-%s', $code);
|
$earnedInfoKey = sprintf('earned-in-%s', $code);
|
||||||
$spentAmount = $spent[$key][$currencyId]['sum'] ?? '0';
|
$spentAmount = $spent[$key][$currencyId]['sum'] ?? '0';
|
||||||
$earnedAmount = $earned[$key][$currencyId]['sum'] ?? '0';
|
$earnedAmount = $earned[$key][$currencyId]['sum'] ?? '0';
|
||||||
$chartData[$spentInfoKey]['entries'][$label] = round($spentAmount, $currency['currency_decimal_places']);
|
$chartData[$spentInfoKey]['entries'][$label] = round((float) $spentAmount, $currency['currency_decimal_places']);
|
||||||
$chartData[$earnedInfoKey]['entries'][$label] = round($earnedAmount, $currency['currency_decimal_places']);
|
$chartData[$earnedInfoKey]['entries'][$label] = round((float) $earnedAmount, $currency['currency_decimal_places']);
|
||||||
}
|
}
|
||||||
$current = app('navigation')->addPeriod($current, $step, 0);
|
$current = app('navigation')->addPeriod($current, $step, 0);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class ExpandedForm
|
|||||||
|
|
||||||
// make sure value is formatted nicely:
|
// make sure value is formatted nicely:
|
||||||
if (null !== $value && '' !== $value) {
|
if (null !== $value && '' !== $value) {
|
||||||
$value = round($value, 8);
|
$value = round((float) $value, 8);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$html = view('form.amount-no-currency', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
$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:
|
// make sure value is formatted nicely:
|
||||||
if (null !== $value && '' !== $value) {
|
if (null !== $value && '' !== $value) {
|
||||||
$value = round($value, $selectedCurrency->decimal_places);
|
$value = round((float) $value, $selectedCurrency->decimal_places);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
|
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||||
|
@ -151,7 +151,7 @@ class CurrencyForm
|
|||||||
|
|
||||||
// make sure value is formatted nicely:
|
// make sure value is formatted nicely:
|
||||||
if (null !== $value && '' !== $value) {
|
if (null !== $value && '' !== $value) {
|
||||||
$value = round($value, $defaultCurrency->decimal_places);
|
$value = round((float) $value, $defaultCurrency->decimal_places);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
$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:
|
// make sure value is formatted nicely:
|
||||||
if (null !== $value && '' !== $value) {
|
if (null !== $value && '' !== $value) {
|
||||||
$value = round($value, $defaultCurrency->decimal_places);
|
$value = round((float) $value, $defaultCurrency->decimal_places);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||||
|
@ -310,10 +310,10 @@ class BudgetReportGenerator
|
|||||||
$budgetedPct = '0';
|
$budgetedPct = '0';
|
||||||
|
|
||||||
if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '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')) {
|
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['sums'][$currencyId]['budgeted'] = $this->report['sums'][$currencyId]['budgeted'] ?? '0';
|
||||||
$this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;
|
$this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;
|
||||||
|
Loading…
Reference in New Issue
Block a user