This fixes part of #738 (not everything).

This commit is contained in:
James Cole
2017-08-19 18:24:04 +02:00
parent c4fe9a6a51
commit bd924b993b
2 changed files with 22 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ use ExpandedForm;
use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -94,13 +95,22 @@ class SplitController extends Controller
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
$currencies = $this->currencies->get();
$assetAccounts = ExpandedForm::makeSelectList($this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
$accountList = $this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$assetAccounts = ExpandedForm::makeSelectList($accountList);
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets());
$preFilled = $this->arrayFromJournal($request, $journal);
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
$subTitleIcon = 'fa-pencil';
$accountArray = [];
// account array to display currency info:
/** @var Account $account */
foreach ($accountList as $account) {
$accountArray[$account->id] = $account;
}
Session::flash('gaEventCategory', 'transactions');
Session::flash('gaEventAction', 'edit-split-' . $preFilled['what']);
@@ -115,7 +125,7 @@ class SplitController extends Controller
compact(
'subTitleIcon', 'currencies', 'optionalFields',
'preFilled', 'subTitle', 'uploadSize', 'assetAccounts',
'budgets', 'journal'
'budgets', 'journal','accountArray'
)
);
}

View File

@@ -56,9 +56,16 @@
{% endif %}
{# TOTAL AMOUNT IS STATIC TEXT #}
{# TODO this does not reflect the actual currency (currencies) #}
{{ ExpandedForm.staticText('journal_amount', preFilled.journal_amount|formatAmount ) }}
<input type="hidden" name="journal_amount" value="{{ preFilled.journal_amount }}"/>
{% if preFilled.what == 'withdrawal' or preFilled.what == 'transfer' %}
{{ ExpandedForm.staticText('journal_amount', formatAmountByAccount(accountArray[preFilled.journal_source_account_id], preFilled.journal_amount, true) ) }}
<input type="hidden" name="journal_amount" value="{{ preFilled.journal_amount }}"/>
{% endif %}
{% if preFilled.what == 'deposit' %}
{{ ExpandedForm.staticText('journal_amount', formatAmountByAccount(accountArray[preFilled.journal_destination_account_id], preFilled.journal_amount, true) ) }}
<input type="hidden" name="journal_amount" value="{{ preFilled.journal_amount }}"/>
{% endif %}
{# DATE #}
{{ ExpandedForm.date('date', journal.date) }}