mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Creating and editing an account now allows the opening balance to be set in a certain currency. Issue #37
This commit is contained in:
parent
5a890c5c3a
commit
725f5b7110
@ -105,10 +105,11 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
/** @var \FireflyIII\Database\TransactionType\TransactionType $typeRepository */
|
||||
$typeRepository = \App::make('FireflyIII\Database\TransactionType\TransactionType');
|
||||
$type = $typeRepository->findByWhat('opening');
|
||||
$currency = \Amount::getDefaultCurrency();
|
||||
$currency = $journals->getJournalCurrencyById(intval($data['balance_currency_id']));
|
||||
//$currency = \Amount::getDefaultCurrency();
|
||||
|
||||
$opening = ['transaction_type_id' => $type->id, 'transaction_currency_id' => $currency->id, 'amount' => $balance, 'from' => $fromAccount,
|
||||
'completed' => 0, 'currency' => 'EUR', 'what' => 'opening', 'to' => $toAccount, 'date' => $date,
|
||||
'completed' => 0, 'what' => 'opening', 'to' => $toAccount, 'date' => $date,
|
||||
'description' => 'Opening balance for new account ' . $account->name,];
|
||||
|
||||
$validation = $journals->validate($opening);
|
||||
|
@ -140,7 +140,7 @@ class Form
|
||||
$classes = self::getHolderClasses($name);
|
||||
$value = self::fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$defaultCurrency = \Amount::getDefaultCurrency();
|
||||
$defaultCurrency = isset($options['currency']) ? $options['currency'] : \Amount::getDefaultCurrency();
|
||||
$currencies = \TransactionCurrency::orderBy('code','ASC')->get();
|
||||
$html = \View::make('form.balance', compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
return $html;
|
||||
|
@ -26,7 +26,7 @@
|
||||
<div class="panel-body">
|
||||
{{Form::ffCheckbox('active','1')}}
|
||||
@if($account->accounttype->type == 'Default account' || $account->accounttype->type == 'Asset account')
|
||||
{{Form::ffBalance('openingBalance')}}
|
||||
{{Form::ffBalance('openingBalance',null, ['currency' => $openingBalance->transactionCurrency])}}
|
||||
{{Form::ffDate('openingBalanceDate')}}
|
||||
{{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}
|
||||
@endif
|
||||
|
@ -3,16 +3,17 @@
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
{{$defaultCurrency->symbol}} <span class="caret"></span>
|
||||
<button type="button" class="btn btn-default dropdown-toggle balanceCurrencyDropdown" data-toggle="dropdown" aria-expanded="false">
|
||||
<span id="balanceCurrentSymbol">{{$defaultCurrency->symbol}}</span> <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
@foreach($currencies as $currency)
|
||||
<li><a href="#">{{{$currency->name}}}</a></li>
|
||||
<li><a href="#" class="currencySelect" data-id="{{{$currency->id}}}" data-field="balance" data-currency="{{{$currency->code}}}" data-symbol="{{{$currency->symbol}}}">{{{$currency->name}}}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
{{Form::input('number', $name, $value, $options)}}
|
||||
{{Form::input('hidden','balance_currency_id',$defaultCurrency->id)}}
|
||||
@include('form.feedback')
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,11 +10,11 @@ function currencySelect(e) {
|
||||
var code = target.data('code');
|
||||
var id = target.data('id');
|
||||
var fieldType = target.data('field');
|
||||
var menu = $('.' + fieldType + 'currencyDropdown');
|
||||
var menu = $('.' + fieldType + 'CurrencyDropdown');
|
||||
|
||||
var symbolHolder = $('#' + fieldType + 'CurrentSymbol');
|
||||
symbolHolder.text(symbol);
|
||||
$('input[name="amount_currency_id"]').val(id);
|
||||
$('input[name="' + fieldType + '_currency_id"]').val(id);
|
||||
|
||||
// close dropdown (hack hack)
|
||||
menu.click();
|
||||
|
Loading…
Reference in New Issue
Block a user