mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Also make sure that the account create screen sets the correct currency id.
This commit is contained in:
parent
953c38563b
commit
adb16e4560
@ -70,7 +70,8 @@ class AccountController extends Controller
|
|||||||
{
|
{
|
||||||
/** @var CurrencyRepositoryInterface $repository */
|
/** @var CurrencyRepositoryInterface $repository */
|
||||||
$repository = app(CurrencyRepositoryInterface::class);
|
$repository = app(CurrencyRepositoryInterface::class);
|
||||||
$currencies = ExpandedForm::makeSelectList($repository->get());
|
$allCurrencies = $repository->get();
|
||||||
|
$currencySelectList = ExpandedForm::makeSelectList($allCurrencies);
|
||||||
$defaultCurrency = Amount::getDefaultCurrency();
|
$defaultCurrency = Amount::getDefaultCurrency();
|
||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||||
$subTitle = trans('firefly.make_new_' . $what . '_account');
|
$subTitle = trans('firefly.make_new_' . $what . '_account');
|
||||||
@ -91,7 +92,7 @@ class AccountController extends Controller
|
|||||||
$request->session()->flash('gaEventCategory', 'accounts');
|
$request->session()->flash('gaEventCategory', 'accounts');
|
||||||
$request->session()->flash('gaEventAction', 'create-' . $what);
|
$request->session()->flash('gaEventAction', 'create-' . $what);
|
||||||
|
|
||||||
return view('accounts.create', compact('subTitleIcon', 'what', 'subTitle', 'currencies', 'roles'));
|
return view('accounts.create', compact('subTitleIcon', 'what', 'subTitle', 'currencySelectList','allCurrencies', 'roles'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +338,6 @@ class AccountController extends Controller
|
|||||||
{
|
{
|
||||||
$data = $request->getAccountData();
|
$data = $request->getAccountData();
|
||||||
$account = $repository->store($data);
|
$account = $repository->store($data);
|
||||||
|
|
||||||
$request->session()->flash('success', strval(trans('firefly.stored_new_account', ['name' => $account->name])));
|
$request->session()->flash('success', strval(trans('firefly.stored_new_account', ['name' => $account->name])));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
|
@ -43,14 +43,12 @@ class AccountFormRequest extends Request
|
|||||||
'accountType' => $this->string('what'),
|
'accountType' => $this->string('what'),
|
||||||
'currency_id' => $this->integer('currency_id'),
|
'currency_id' => $this->integer('currency_id'),
|
||||||
'virtualBalance' => $this->float('virtualBalance'),
|
'virtualBalance' => $this->float('virtualBalance'),
|
||||||
'virtualBalanceCurrency' => $this->integer('amount_currency_id_virtualBalance'),
|
|
||||||
'iban' => $this->string('iban'),
|
'iban' => $this->string('iban'),
|
||||||
'BIC' => $this->string('BIC'),
|
'BIC' => $this->string('BIC'),
|
||||||
'accountNumber' => $this->string('accountNumber'),
|
'accountNumber' => $this->string('accountNumber'),
|
||||||
'accountRole' => $this->string('accountRole'),
|
'accountRole' => $this->string('accountRole'),
|
||||||
'openingBalance' => $this->float('openingBalance'),
|
'openingBalance' => $this->float('openingBalance'),
|
||||||
'openingBalanceDate' => $this->date('openingBalanceDate'),
|
'openingBalanceDate' => $this->date('openingBalanceDate'),
|
||||||
'openingBalanceCurrency' => $this->integer('amount_currency_id_openingBalance'),
|
|
||||||
'ccType' => $this->string('ccType'),
|
'ccType' => $this->string('ccType'),
|
||||||
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
|
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
|
||||||
];
|
];
|
||||||
|
@ -455,6 +455,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
{
|
{
|
||||||
$amount = $data['openingBalance'];
|
$amount = $data['openingBalance'];
|
||||||
$name = $data['name'];
|
$name = $data['name'];
|
||||||
|
$currencyId = $data['currency_id'];
|
||||||
$opposing = $this->storeOpposingAccount($name);
|
$opposing = $this->storeOpposingAccount($name);
|
||||||
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@ -462,7 +463,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
[
|
[
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'transaction_type_id' => $transactionType->id,
|
'transaction_type_id' => $transactionType->id,
|
||||||
'transaction_currency_id' => $data['openingBalanceCurrency'],
|
'transaction_currency_id' => $currencyId,
|
||||||
'description' => 'Initial balance for "' . $account->name . '"',
|
'description' => 'Initial balance for "' . $account->name . '"',
|
||||||
'completed' => true,
|
'completed' => true,
|
||||||
'date' => $data['openingBalanceDate'],
|
'date' => $data['openingBalanceDate'],
|
||||||
@ -530,9 +531,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
// opening balance data? update it!
|
// opening balance data? update it!
|
||||||
if (!is_null($openingBalance->id)) {
|
if (!is_null($openingBalance->id)) {
|
||||||
|
|
||||||
Log::debug('Opening balance journal found, update journal.');
|
Log::debug('Opening balance journal found, update journal.');
|
||||||
|
|
||||||
$this->updateOpeningBalanceJournal($account, $openingBalance, $data);
|
$this->updateOpeningBalanceJournal($account, $openingBalance, $data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** global: Modernizr */
|
/** global: Modernizr, currencies */
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -17,4 +17,14 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// on change currency drop down list:
|
||||||
|
$('#ffInput_currency_id').change(updateCurrencyItems);
|
||||||
|
updateCurrencyItems();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function updateCurrencyItems() {
|
||||||
|
var value = $('#ffInput_currency_id').val();
|
||||||
|
var symbol = currencies[value];
|
||||||
|
$('.non-selectable-currency-symbol').text(symbol);
|
||||||
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
{{ ExpandedForm.text('name') }}
|
{{ ExpandedForm.text('name') }}
|
||||||
{% if what == 'asset' %}
|
{% if what == 'asset' %}
|
||||||
{# Not really mandatory but OK #}
|
{# Not really mandatory but OK #}
|
||||||
{{ ExpandedForm.select('currency_id', currencies, null, {helpText:'account_default_currency'|_}) }}
|
{{ ExpandedForm.select('currency_id', currencySelectList, null, {helpText:'account_default_currency'|_}) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -39,10 +39,10 @@
|
|||||||
|
|
||||||
{% if what == 'asset' %}
|
{% if what == 'asset' %}
|
||||||
|
|
||||||
{{ ExpandedForm.balance('openingBalance') }}
|
{{ ExpandedForm.nonSelectableBalance('openingBalance') }}
|
||||||
{{ ExpandedForm.date('openingBalanceDate') }}
|
{{ ExpandedForm.date('openingBalanceDate') }}
|
||||||
{{ ExpandedForm.select('accountRole', roles,null,{'helpText' : 'asset_account_role_help'|_}) }}
|
{{ ExpandedForm.select('accountRole', roles,null,{'helpText' : 'asset_account_role_help'|_}) }}
|
||||||
{{ ExpandedForm.balance('virtualBalance') }}
|
{{ ExpandedForm.nonSelectableBalance('virtualBalance') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -70,6 +70,13 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script type="text/javascript" src="js/lib/modernizr-custom.js"></script>
|
<script type="text/javascript" src="js/lib/modernizr-custom.js"></script>
|
||||||
<script type="text/javascript" src="js/lib/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="js/lib/jquery-ui.min.js"></script>
|
||||||
|
{# JS currency list for update thing #}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var currencies = [];
|
||||||
|
{% for currency in allCurrencies %}
|
||||||
|
currencies[{{ currency.id }}] = "{{ currency.symbol }}";
|
||||||
|
{% endfor %}
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="js/ff/accounts/create.js"></script>
|
<script type="text/javascript" src="js/ff/accounts/create.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user