mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-28 19:54:00 -06:00
Fix #948
This commit is contained in:
parent
d30d6b5e19
commit
5e3729e4b4
@ -26,6 +26,7 @@ namespace FireflyIII\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use View;
|
||||
@ -81,7 +82,7 @@ class NewUserController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function submit(NewUserFormRequest $request, AccountRepositoryInterface $repository)
|
||||
public function submit(NewUserFormRequest $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository)
|
||||
{
|
||||
// create normal asset account:
|
||||
$this->createAssetAccount($request, $repository);
|
||||
@ -89,6 +90,16 @@ class NewUserController extends Controller
|
||||
// create savings account
|
||||
$this->createSavingsAccount($request, $repository);
|
||||
|
||||
// also store currency preference from input:
|
||||
$currency = $currencyRepository->find(intval($request->input('amount_currency_id_bank_balance')));
|
||||
|
||||
if(!is_null($currency->id)) {
|
||||
// store currency preference:
|
||||
Preferences::set('currencyPreference', $currency->code);
|
||||
Preferences::mark();
|
||||
}
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.stored_new_accounts_new_user')));
|
||||
Preferences::mark();
|
||||
|
||||
@ -137,7 +148,7 @@ class NewUserController extends Controller
|
||||
'accountRole' => 'savingAsset',
|
||||
'openingBalance' => round($request->input('savings_balance'), 12),
|
||||
'openingBalanceDate' => new Carbon,
|
||||
'currency_id' => intval($request->input('amount_currency_id_savings_balance')),
|
||||
'currency_id' => intval($request->input('amount_currency_id_bank_balance')),
|
||||
];
|
||||
$repository->store($savingsAccount);
|
||||
|
||||
|
@ -111,7 +111,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
if (is_null($currency)) {
|
||||
$currency = new TransactionCurrency;
|
||||
|
||||
}
|
||||
|
||||
return $currency;
|
||||
|
@ -300,7 +300,6 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
@ -331,6 +330,27 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function number(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
unset($options['placeholder']);
|
||||
|
||||
$html = view('form.number', compact( 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @param $name
|
||||
|
@ -176,6 +176,7 @@ return [
|
||||
'is_safe' => [
|
||||
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
|
||||
'multiRadio', 'file', 'multiCheckbox', 'staticText', 'amountSmall', 'password', 'nonSelectableBalance', 'nonSelectableAmount',
|
||||
'number'
|
||||
],
|
||||
],
|
||||
'Form' => [
|
||||
|
8
resources/views/form/number.twig
Normal file
8
resources/views/form/number.twig
Normal file
@ -0,0 +1,8 @@
|
||||
<div class="{{ classes }}" id="{{ name }}_holder">
|
||||
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
||||
|
||||
<div class="col-sm-8">
|
||||
{{ Form.input('number', name, value, options) }}
|
||||
{% include 'form/feedback' %}
|
||||
</div>
|
||||
</div>
|
@ -31,7 +31,7 @@
|
||||
{{ 'savings_balance_text'|_ }}
|
||||
</p>
|
||||
|
||||
{{ ExpandedForm.balance('savings_balance',0) }}
|
||||
{{ ExpandedForm.number('savings_balance',0) }}
|
||||
|
||||
<p>
|
||||
{{ 'finish_up_new_user'|_ }}
|
||||
|
Loading…
Reference in New Issue
Block a user