diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php index ccb34ce85a..19ad0f357f 100644 --- a/app/Http/Controllers/Account/EditController.php +++ b/app/Http/Controllers/Account/EditController.php @@ -143,9 +143,9 @@ class EditController extends Controller 'BIC' => $repository->getMetaValue($account, 'BIC'), 'opening_balance_date' => $openingBalanceDate, 'liability_type_id' => $account->account_type_id, - 'opening_balance' => $openingBalanceAmount, + 'opening_balance' => number_format((float)$openingBalanceAmount, $currency->decimal_places), 'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'), - 'virtual_balance' => $account->virtual_balance, + 'virtual_balance' => number_format((float)$account->virtual_balance, $currency->decimal_places), 'currency_id' => $currency->id, 'include_net_worth' => $includeNetWorth, 'interest' => $repository->getMetaValue($account, 'interest'), diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.php index 7f77a47c30..4e382046a9 100644 --- a/app/Http/Controllers/Budget/EditController.php +++ b/app/Http/Controllers/Budget/EditController.php @@ -102,7 +102,8 @@ class EditController extends Controller 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id, ]; if ($autoBudget) { - $preFilled['auto_budget_amount'] = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount; + $amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount; + $preFilled['auto_budget_amount'] = number_format((float)$amount, $autoBudget->transactionCurrency->decimal_places); } // put previous url in session if not redirect from store (not "return_to_edit"). diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.php index 5abdfa02fa..0b1e293d96 100644 --- a/app/Http/Controllers/PiggyBank/EditController.php +++ b/app/Http/Controllers/PiggyBank/EditController.php @@ -28,6 +28,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\PiggyBankUpdateRequest; use FireflyIII\Models\PiggyBank; +use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use Illuminate\Contracts\View\Factory; use Illuminate\Http\RedirectResponse; @@ -41,6 +42,7 @@ class EditController extends Controller { private AttachmentHelperInterface $attachments; private PiggyBankRepositoryInterface $piggyRepos; + private AccountRepositoryInterface $accountRepository; /** * PiggyBankController constructor. @@ -58,7 +60,7 @@ class EditController extends Controller $this->attachments = app(AttachmentHelperInterface::class); $this->piggyRepos = app(PiggyBankRepositoryInterface::class); - + $this->accountRepository = app(AccountRepositoryInterface::class); return $next($request); } ); @@ -81,10 +83,11 @@ class EditController extends Controller // Flash some data to fill the form. $targetDate = $piggyBank->targetdate?->format('Y-m-d'); $startDate = $piggyBank->startdate?->format('Y-m-d'); + $currency = $this->accountRepository->getAccountCurrency($piggyBank->account); $preFilled = ['name' => $piggyBank->name, 'account_id' => $piggyBank->account_id, - 'targetamount' => $piggyBank->targetamount, + 'targetamount' => number_format((float)$piggyBank->targetamount, $currency->decimal_places), 'targetdate' => $targetDate, 'startdate' => $startDate, 'object_group' => $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '', diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index aca4ad0619..49892fe98f 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -146,7 +146,7 @@ class MassController extends Controller // reverse amounts foreach ($journals as $index => $journal) { - $journals[$index]['amount'] = app('steam')->positive($journal['amount']); + $journals[$index]['amount'] = number_format((float) app('steam')->positive($journal['amount']), $journal['currency_decimal_places']); $journals[$index]['foreign_amount'] = null === $journal['foreign_amount'] ? null : app('steam')->positive($journal['foreign_amount']); }