diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 21c044f762..29a3610556 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -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(); diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 90cd841829..09a65833d7 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -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; diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 80cc0b0c26..b65b400f64 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -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; } diff --git a/resources/twig/list/journals-tiny.twig b/resources/twig/list/journals-tiny.twig index e2c24b72db..664e8323f7 100644 --- a/resources/twig/list/journals-tiny.twig +++ b/resources/twig/list/journals-tiny.twig @@ -1,6 +1,5 @@