Show correct amount [skip ci]

This commit is contained in:
James Cole 2015-05-18 17:04:10 +02:00
parent 064e60e9d5
commit 374b90fb00
2 changed files with 23 additions and 1 deletions

View File

@ -152,6 +152,28 @@ class TransactionJournal extends Model
return $this->hasMany('FireflyIII\Models\Transaction');
}
/**
* @return float
*/
public function getCorrectedActualAmountAttribute()
{
$amount = 0;
$type = $this->transactionType->type;
/** @var Transaction $t */
foreach ($this->transactions as $t) {
if ($t->amount > 0 && $type != 'Withdrawal') {
$amount = floatval($t->amount);
break;
}
if ($t->amount < 0 && $type == 'Withdrawal') {
$amount = floatval($t->amount);
break;
}
}
return $amount;
}
/**
* @codeCoverageIgnore
* @return array

View File

@ -57,7 +57,7 @@
{% if not hideTags %}
{{ relevantTags(journal)|raw }}
{% else %}
{{ journal.actualAmount|formatAmount }}
{{ journal.correctedActualAmount|formatAmount }}
{% endif %}
</td>
<td>