mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 11:19:16 +00:00
Fix #948
This commit is contained in:
@@ -26,6 +26,7 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
@@ -81,7 +82,7 @@ class NewUserController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @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:
|
// create normal asset account:
|
||||||
$this->createAssetAccount($request, $repository);
|
$this->createAssetAccount($request, $repository);
|
||||||
@@ -89,6 +90,16 @@ class NewUserController extends Controller
|
|||||||
// create savings account
|
// create savings account
|
||||||
$this->createSavingsAccount($request, $repository);
|
$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')));
|
Session::flash('success', strval(trans('firefly.stored_new_accounts_new_user')));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
@@ -137,7 +148,7 @@ class NewUserController extends Controller
|
|||||||
'accountRole' => 'savingAsset',
|
'accountRole' => 'savingAsset',
|
||||||
'openingBalance' => round($request->input('savings_balance'), 12),
|
'openingBalance' => round($request->input('savings_balance'), 12),
|
||||||
'openingBalanceDate' => new Carbon,
|
'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);
|
$repository->store($savingsAccount);
|
||||||
|
|
||||||
|
@@ -111,7 +111,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
$currency = TransactionCurrency::find($currencyId);
|
$currency = TransactionCurrency::find($currencyId);
|
||||||
if (is_null($currency)) {
|
if (is_null($currency)) {
|
||||||
$currency = new TransactionCurrency;
|
$currency = new TransactionCurrency;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $currency;
|
return $currency;
|
||||||
|
@@ -300,7 +300,6 @@ class ExpandedForm
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param null $value
|
* @param null $value
|
||||||
@@ -331,6 +330,27 @@ class ExpandedForm
|
|||||||
return $html;
|
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 $type
|
||||||
* @param $name
|
* @param $name
|
||||||
|
@@ -176,6 +176,7 @@ return [
|
|||||||
'is_safe' => [
|
'is_safe' => [
|
||||||
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
|
'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location',
|
||||||
'multiRadio', 'file', 'multiCheckbox', 'staticText', 'amountSmall', 'password', 'nonSelectableBalance', 'nonSelectableAmount',
|
'multiRadio', 'file', 'multiCheckbox', 'staticText', 'amountSmall', 'password', 'nonSelectableBalance', 'nonSelectableAmount',
|
||||||
|
'number'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'Form' => [
|
'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'|_ }}
|
{{ 'savings_balance_text'|_ }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{ ExpandedForm.balance('savings_balance',0) }}
|
{{ ExpandedForm.number('savings_balance',0) }}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ 'finish_up_new_user'|_ }}
|
{{ 'finish_up_new_user'|_ }}
|
||||||
|
Reference in New Issue
Block a user