mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Improve edit routine for split transactions.
This commit is contained in:
parent
7cd51a7747
commit
91fe1493a7
@ -33,6 +33,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
@ -114,7 +115,7 @@ class SplitController extends Controller
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$accountArray[$account->id] = $account;
|
||||
$accountArray[$account->id]['currency_id'] = (int)$account->getMeta('currency_id');
|
||||
$accountArray[$account->id]['currency_id'] = (int)$this->accounts->getMetaValue($account, 'currency_id');
|
||||
}
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
@ -235,11 +236,19 @@ class SplitController extends Controller
|
||||
$set = $collector->getJournals();
|
||||
$transactions = [];
|
||||
$transformer = new TransactionTransformer(new ParameterBag);
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
if ($transaction->transaction_amount > 0) {
|
||||
$transactions[] = $transformer->transform($transaction);
|
||||
$res = [];
|
||||
if ((float)$transaction->transaction_amount > 0 && $journal->transactionType->type === TransactionType::DEPOSIT) {
|
||||
$res = $transformer->transform($transaction);
|
||||
}
|
||||
if ((float)$transaction->transaction_amount < 0 && $journal->transactionType->type !== TransactionType::DEPOSIT) {
|
||||
$res = $transformer->transform($transaction);
|
||||
}
|
||||
|
||||
if (count($res) > 0) {
|
||||
$res['amount'] = app('steam')->positive((string)$res['amount']);
|
||||
$transactions[] = $res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ class Transaction extends Twig_Extension
|
||||
{
|
||||
$res = '';
|
||||
if ($transaction->is_split === true) {
|
||||
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>!!!';
|
||||
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||
}
|
||||
|
||||
if ($transaction->is_split === null) {
|
||||
|
@ -215,7 +215,6 @@ class TransactionTransformer extends TransformerAbstract
|
||||
if (null !== $transaction->transaction_foreign_amount) {
|
||||
$data['foreign_amount'] = round($transaction->transaction_foreign_amount, (int)$transaction->foreign_currency_dp);
|
||||
}
|
||||
|
||||
// switch on type for consistency
|
||||
switch ($transaction->transaction_type_type) {
|
||||
case TransactionType::WITHDRAWAL:
|
||||
|
@ -33,6 +33,7 @@
|
||||
<h3 class="box-title">{{ 'mandatoryFields'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
|
||||
{# ALWAYS AVAILABLE #}
|
||||
{{ ExpandedForm.text('description',journal.description) }}
|
||||
|
||||
@ -81,7 +82,11 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% if what == 'withdrawal' %}
|
||||
{{ ExpandedForm.select('budget_id',budgetList,data['budget_id']) }}
|
||||
{% if budgetList|length > 1 %}
|
||||
{{ ExpandedForm.select('budget_id', budgetList, data['budget_id']) }}
|
||||
{% else %}
|
||||
{{ ExpandedForm.select('budget_id', budgetList, data['budget_id'], {helpText: trans('firefly.no_budget_pointer')}) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{{ ExpandedForm.text('category',data['category']) }}
|
||||
{{ ExpandedForm.text('tags') }}
|
||||
@ -209,8 +214,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="source_account_currency" value="0" />
|
||||
<input type="hidden" name="destination_account_currency" value="0" />
|
||||
<input type="hidden" name="source_account_currency" value="0"/>
|
||||
<input type="hidden" name="destination_account_currency" value="0"/>
|
||||
</form>
|
||||
|
||||
|
||||
|
@ -228,7 +228,7 @@
|
||||
{% if preFilled.what == 'withdrawal' %}
|
||||
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12">
|
||||
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][destination_name]"
|
||||
value="{{ transaction.destination_name }}" class="form-control"/>
|
||||
value="{% if transaction.destination_type != 'Cash account' %}{{ transaction.destination_name }}{% endif %}" class="form-control"/>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user