Skip to content

Firefly III: a personal finances manager

Fix #948

James Cole5e3729e4b4bf
diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php
index ebcaba34a5..3d46778d37 100644
--- a/app/Http/Controllers/NewUserController.php
+++ b/app/Http/Controllers/NewUserController.php
@@ -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);
diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php
index 21987fd91c..af0e383460 100644
--- a/app/Repositories/Currency/CurrencyRepository.php
+++ b/app/Repositories/Currency/CurrencyRepository.php
@@ -111,7 +111,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
$currency = TransactionCurrency::find($currencyId);
if (is_null($currency)) {
$currency = new TransactionCurrency;
-
}
return $currency;
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 7d1554cb99..9b5f04986f 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -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
diff --git a/config/twigbridge.php b/config/twigbridge.php
index b514e6681b..601364ccfe 100644
--- a/config/twigbridge.php
+++ b/config/twigbridge.php
@@ -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' => [
diff --git a/resources/views/form/number.twig b/resources/views/form/number.twig
new file mode 100644
index 0000000000..efffb5b8a0
--- /dev/null
+++ b/resources/views/form/number.twig
@@ -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>
diff --git a/resources/views/new-user/index.twig b/resources/views/new-user/index.twig
index b10c636183..4401962300 100644
--- a/resources/views/new-user/index.twig
+++ b/resources/views/new-user/index.twig
@@ -31,7 +31,7 @@
{{ 'savings_balance_text'|_ }}
</p>
- {{ ExpandedForm.balance('savings_balance',0) }}
+ {{ ExpandedForm.number('savings_balance',0) }}
<p>
{{ 'finish_up_new_user'|_ }}