mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-30 12:43:57 -06:00
Also make sure that the account create screen sets the correct currency id.
This commit is contained in:
parent
953c38563b
commit
adb16e4560
@ -69,12 +69,13 @@ class AccountController extends Controller
|
||||
public function create(Request $request, string $what = 'asset')
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$currencies = ExpandedForm::makeSelectList($repository->get());
|
||||
$defaultCurrency = Amount::getDefaultCurrency();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||
$subTitle = trans('firefly.make_new_' . $what . '_account');
|
||||
$roles = [];
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$allCurrencies = $repository->get();
|
||||
$currencySelectList = ExpandedForm::makeSelectList($allCurrencies);
|
||||
$defaultCurrency = Amount::getDefaultCurrency();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||
$subTitle = trans('firefly.make_new_' . $what . '_account');
|
||||
$roles = [];
|
||||
foreach (config('firefly.accountRoles') as $role) {
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
@ -91,7 +92,7 @@ class AccountController extends Controller
|
||||
$request->session()->flash('gaEventCategory', 'accounts');
|
||||
$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'));
|
||||
|
||||
}
|
||||
|
||||
@ -193,8 +194,8 @@ class AccountController extends Controller
|
||||
|
||||
return view(
|
||||
'accounts.edit', compact(
|
||||
'allCurrencies', 'currencySelectList', 'account', 'currency', 'subTitle', 'subTitleIcon', 'openingBalance', 'what', 'roles'
|
||||
)
|
||||
'allCurrencies', 'currencySelectList', 'account', 'currency', 'subTitle', 'subTitleIcon', 'openingBalance', 'what', 'roles'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -337,7 +338,6 @@ class AccountController extends Controller
|
||||
{
|
||||
$data = $request->getAccountData();
|
||||
$account = $repository->store($data);
|
||||
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_new_account', ['name' => $account->name])));
|
||||
Preferences::mark();
|
||||
|
||||
|
@ -43,14 +43,12 @@ class AccountFormRequest extends Request
|
||||
'accountType' => $this->string('what'),
|
||||
'currency_id' => $this->integer('currency_id'),
|
||||
'virtualBalance' => $this->float('virtualBalance'),
|
||||
'virtualBalanceCurrency' => $this->integer('amount_currency_id_virtualBalance'),
|
||||
'iban' => $this->string('iban'),
|
||||
'BIC' => $this->string('BIC'),
|
||||
'accountNumber' => $this->string('accountNumber'),
|
||||
'accountRole' => $this->string('accountRole'),
|
||||
'openingBalance' => $this->float('openingBalance'),
|
||||
'openingBalanceDate' => $this->date('openingBalanceDate'),
|
||||
'openingBalanceCurrency' => $this->integer('amount_currency_id_openingBalance'),
|
||||
'ccType' => $this->string('ccType'),
|
||||
'ccMonthlyPaymentDate' => $this->string('ccMonthlyPaymentDate'),
|
||||
];
|
||||
|
@ -455,6 +455,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
$amount = $data['openingBalance'];
|
||||
$name = $data['name'];
|
||||
$currencyId = $data['currency_id'];
|
||||
$opposing = $this->storeOpposingAccount($name);
|
||||
$transactionType = TransactionType::whereType(TransactionType::OPENING_BALANCE)->first();
|
||||
/** @var TransactionJournal $journal */
|
||||
@ -462,7 +463,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
[
|
||||
'user_id' => $this->user->id,
|
||||
'transaction_type_id' => $transactionType->id,
|
||||
'transaction_currency_id' => $data['openingBalanceCurrency'],
|
||||
'transaction_currency_id' => $currencyId,
|
||||
'description' => 'Initial balance for "' . $account->name . '"',
|
||||
'completed' => true,
|
||||
'date' => $data['openingBalanceDate'],
|
||||
@ -530,9 +531,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
// opening balance data? update it!
|
||||
if (!is_null($openingBalance->id)) {
|
||||
|
||||
Log::debug('Opening balance journal found, update journal.');
|
||||
|
||||
$this->updateOpeningBalanceJournal($account, $openingBalance, $data);
|
||||
|
||||
return true;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/** global: Modernizr */
|
||||
/** global: Modernizr, currencies */
|
||||
|
||||
$(document).ready(function () {
|
||||
"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') }}
|
||||
{% if what == 'asset' %}
|
||||
{# 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 %}
|
||||
</div>
|
||||
</div>
|
||||
@ -39,10 +39,10 @@
|
||||
|
||||
{% if what == 'asset' %}
|
||||
|
||||
{{ ExpandedForm.balance('openingBalance') }}
|
||||
{{ ExpandedForm.nonSelectableBalance('openingBalance') }}
|
||||
{{ ExpandedForm.date('openingBalanceDate') }}
|
||||
{{ ExpandedForm.select('accountRole', roles,null,{'helpText' : 'asset_account_role_help'|_}) }}
|
||||
{{ ExpandedForm.balance('virtualBalance') }}
|
||||
{{ ExpandedForm.nonSelectableBalance('virtualBalance') }}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
@ -70,6 +70,13 @@
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" src="js/lib/modernizr-custom.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>
|
||||
{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user