This commit is contained in:
James Cole
2021-11-24 20:27:57 +01:00
parent afd4700758
commit b2eeeed0af
4 changed files with 10 additions and 6 deletions

View File

@@ -143,9 +143,9 @@ class EditController extends Controller
'BIC' => $repository->getMetaValue($account, 'BIC'), 'BIC' => $repository->getMetaValue($account, 'BIC'),
'opening_balance_date' => $openingBalanceDate, 'opening_balance_date' => $openingBalanceDate,
'liability_type_id' => $account->account_type_id, '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'), '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, 'currency_id' => $currency->id,
'include_net_worth' => $includeNetWorth, 'include_net_worth' => $includeNetWorth,
'interest' => $repository->getMetaValue($account, 'interest'), 'interest' => $repository->getMetaValue($account, 'interest'),

View File

@@ -102,7 +102,8 @@ class EditController extends Controller
'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id, 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
]; ];
if ($autoBudget) { 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"). // put previous url in session if not redirect from store (not "return_to_edit").

View File

@@ -28,6 +28,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\PiggyBankUpdateRequest; use FireflyIII\Http\Requests\PiggyBankUpdateRequest;
use FireflyIII\Models\PiggyBank; use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@@ -41,6 +42,7 @@ class EditController extends Controller
{ {
private AttachmentHelperInterface $attachments; private AttachmentHelperInterface $attachments;
private PiggyBankRepositoryInterface $piggyRepos; private PiggyBankRepositoryInterface $piggyRepos;
private AccountRepositoryInterface $accountRepository;
/** /**
* PiggyBankController constructor. * PiggyBankController constructor.
@@ -58,7 +60,7 @@ class EditController extends Controller
$this->attachments = app(AttachmentHelperInterface::class); $this->attachments = app(AttachmentHelperInterface::class);
$this->piggyRepos = app(PiggyBankRepositoryInterface::class); $this->piggyRepos = app(PiggyBankRepositoryInterface::class);
$this->accountRepository = app(AccountRepositoryInterface::class);
return $next($request); return $next($request);
} }
); );
@@ -81,10 +83,11 @@ class EditController extends Controller
// Flash some data to fill the form. // Flash some data to fill the form.
$targetDate = $piggyBank->targetdate?->format('Y-m-d'); $targetDate = $piggyBank->targetdate?->format('Y-m-d');
$startDate = $piggyBank->startdate?->format('Y-m-d'); $startDate = $piggyBank->startdate?->format('Y-m-d');
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account);
$preFilled = ['name' => $piggyBank->name, $preFilled = ['name' => $piggyBank->name,
'account_id' => $piggyBank->account_id, 'account_id' => $piggyBank->account_id,
'targetamount' => $piggyBank->targetamount, 'targetamount' => number_format((float)$piggyBank->targetamount, $currency->decimal_places),
'targetdate' => $targetDate, 'targetdate' => $targetDate,
'startdate' => $startDate, 'startdate' => $startDate,
'object_group' => $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '', 'object_group' => $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '',

View File

@@ -146,7 +146,7 @@ class MassController extends Controller
// reverse amounts // reverse amounts
foreach ($journals as $index => $journal) { 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'] ? $journals[$index]['foreign_amount'] = null === $journal['foreign_amount'] ?
null : app('steam')->positive($journal['foreign_amount']); null : app('steam')->positive($journal['foreign_amount']);
} }