diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index 2854740f00..43a2a73b51 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -96,7 +96,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface ]; foreach ($entries as $entry) { $data['labels'][] = trim($entry['date']->formatLocalized($format)); - $data['datasets'][0]['data'][] = floatval($entry['net-worth']); + $data['datasets'][0]['data'][] = round($entry['net-worth'], 2); } return $data; diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 791d206394..48b285486a 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -157,7 +157,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface $piggyBank->name = $data['name']; $piggyBank->account_id = intval($data['account_id']); - $piggyBank->targetamount = floatval($data['targetamount']); + $piggyBank->targetamount = round($data['targetamount'], 2); $piggyBank->targetdate = $data['targetdate']; $piggyBank->startdate = $data['startdate']; diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 2fa746dbb1..c5ac2b7f28 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -42,7 +42,7 @@ class Amount public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true): string { $locale = setlocale(LC_MONETARY, 0); - $float = floatval($amount); + $float = round($amount, 2); $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); $result = $formatter->formatCurrency($float, $format->code); @@ -71,9 +71,9 @@ class Amount public function formatJournal(TransactionJournal $journal, bool $coloured = true): string { $locale = setlocale(LC_MONETARY, 0); - $float = floatval($journal->destination_amount); + $float = round($journal->destination_amount, 2); if ($journal->isWithdrawal()) { - $float = floatval($journal->source_amount); + $float = round($journal->source_amount, 2); } $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); $currencyCode = $journal->transaction_currency_code ?? $journal->transactionCurrency->code;