Fixed some other displays of money

This commit is contained in:
James Cole 2015-05-20 18:09:44 +02:00
parent 568ab26db1
commit 411f77fd29
4 changed files with 27 additions and 9 deletions

View File

@ -81,7 +81,10 @@ class CategoryController extends Controller
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
foreach ($set as $entry) {
$chart->addRow($entry['name'], floatval($entry['sum']));
$sum = floatval($entry['sum']);
if($sum != 0) {
$chart->addRow($entry['name'], $sum);
}
}
$chart->generate();

View File

@ -133,7 +133,7 @@ class TagController extends Controller
* changes to an advancePayment.
*/
if ($tag->tagMode == 'balancingAct') {
if ($tag->tagMode == 'balancingAct' || $tag->tagMode == 'nothing') {
foreach ($tag->transactionjournals as $journal) {
if ($journal->transactionType->type == 'Transfer') {
$allowToAdvancePayment = false;

View File

@ -96,12 +96,12 @@ class TransactionJournal extends Model
}
// if journal is part of advancePayment AND journal is a withdrawal,
// then journal is being repaid by other journals, so the actual amount will lower:
/** @var Tag $tag */
$tag = $this->tags()->where('tagMode', 'advancePayment')->first();
if ($tag && $this->transactionType->type == 'Withdrawal') {
/** @var Tag $advancePayment */
$advancePayment = $this->tags()->where('tagMode', 'advancePayment')->first();
if ($advancePayment && $this->transactionType->type == 'Withdrawal') {
// loop other deposits, remove from our amount.
$others = $tag->transactionJournals()->transactionTypes(['Deposit'])->get();
$others = $advancePayment->transactionJournals()->transactionTypes(['Deposit'])->get();
foreach ($others as $other) {
$amount -= $other->actualAmount;
}
@ -111,10 +111,27 @@ class TransactionJournal extends Model
// if this journal is part of an advancePayment AND the journal is a deposit,
// then the journal amount is correcting a withdrawal, and the amount is zero:
if ($tag && $this->transactionType->type == 'Deposit') {
if ($advancePayment && $this->transactionType->type == 'Deposit') {
return 0;
}
// is balancing act?
$balancingAct = $this->tags()->where('tagMode', 'balancingAct')->first();
if ($balancingAct) {
// this is the transfer
// this is the expense:
if ($this->transactionType->type == 'Withdrawal') {
$transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first();
if ($transfer) {
$amount -= $transfer->actualAmount;
return $amount;
}
}
}
return $amount;
}

View File

@ -1,6 +1,5 @@
<div class="list-group">
{% for journal in transactions %}
{% if journal.amount != 0 %}
<a class="list-group-item" title="{{journal.date.format('jS M Y')}}" href="{{route('transactions.show',journal.id)}}">
@ -14,6 +13,5 @@
</span>
</a>
{% endif %}
{% endfor %}
</div>