Skip to content

Firefly III: a personal finances manager

Fixed a bug where certain reports would not show incomes from shared accounts.

James Cole03e0510c4f99
diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php
index 5cef244661..c56d7ae08a 100644
--- a/app/controllers/TransactionController.php
+++ b/app/controllers/TransactionController.php
@@ -254,10 +254,11 @@ class TransactionController extends BaseController
Session::flash('errors', $messages['errors']);
if ($messages['errors']->count() > 0) {
Session::flash('error', 'Could not store transaction: ' . $messages['errors']->first());
+ return Redirect::route('transactions.create', $data['what'])->withInput();
}
// return to create screen:
- if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
+ if ($data['post_submit_action'] == 'validate_only') {
return Redirect::route('transactions.create', $data['what'])->withInput();
}
diff --git a/app/lib/FireflyIII/Report/ReportQuery.php b/app/lib/FireflyIII/Report/ReportQuery.php
index a83a544d95..7ac2cd18bd 100644
--- a/app/lib/FireflyIII/Report/ReportQuery.php
+++ b/app/lib/FireflyIII/Report/ReportQuery.php
@@ -306,23 +306,8 @@ class ReportQuery implements ReportQueryInterface
}
)
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- // not shared, withdrawal
- ->where(
- function ($q) {
- $q->where(
- function ($q) {
- $q->where('transaction_types.type', 'Withdrawal');
- $q->where('acm_from.data', '!=', '"sharedExpense"');
- }
- )->orWhere(
- function ($q) {
- $q->where('transaction_types.type', 'Transfer');
- $q->where('acm_from.data', '=', '"sharedExpense"');
- }
- );
- }
- )
- // shared, transfer?
+ ->where('transaction_types.type', 'Withdrawal')
+ ->where('acm_from.data', '!=', '"sharedExpense"')
->before($end)
->after($start)
->where('transaction_journals.user_id', \Auth::user()->id)
@@ -336,10 +321,11 @@ class ReportQuery implements ReportQueryInterface
*
* @param Carbon $start
* @param Carbon $end
+ * @param int $limit
*
* @return Collection
*/
- public function journalsByRevenueAccount(Carbon $start, Carbon $end)
+ public function journalsByRevenueAccount(Carbon $start, Carbon $end, $limit = 15)
{
return \TransactionJournal::
leftJoin(
@@ -365,8 +351,24 @@ class ReportQuery implements ReportQueryInterface
}
)
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->where('transaction_types.type', 'Deposit')
- ->where('acm_to.data', '!=', '"sharedExpense"')
+ ->where(
+ function ($query) {
+ $query->where(
+ function ($q) {
+ $q->where('transaction_types.type', 'Deposit');
+ $q->where('acm_to.data', '!=', '"sharedExpense"');
+ }
+ );
+ $query->orWhere(
+ function ($q) {
+ $q->where('transaction_types.type', 'Transfer');
+ $q->where('acm_from.data', '=', '"sharedExpense"');
+ }
+ );
+ }
+ )
+ // ->where('transaction_types.type', 'Deposit')
+ // ->where('acm_to.data', '!=', '"sharedExpense"')
->before($end)->after($start)
->where('transaction_journals.user_id', \Auth::user()->id)
->groupBy('t_from.account_id')->orderBy('amount')
diff --git a/app/views/list/journals-small.blade.php b/app/views/list/journals-small.blade.php
index 9bf33f4b0b..b1ba57dacf 100644
--- a/app/views/list/journals-small.blade.php
+++ b/app/views/list/journals-small.blade.php
@@ -9,24 +9,28 @@
<td>
<?php $tableSum += floatval($journal->transactions[1]->amount);?>
@if($journal->transactiontype->type == 'Withdrawal')
- <span class="text-danger">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
+ <span class="text-danger">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
@endif
@if($journal->transactiontype->type == 'Deposit')
- <span class="text-success">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
+ <span class="text-success">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
@endif
@if($journal->transactiontype->type == 'Transfer')
- <span class="text-info">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
+ <span class="text-info">{{Amount::formatTransaction($journal->transactions[1],false)}}</span>
@endif
</td>
<td>
{{$journal->date->format('j F Y')}}
</td>
<td>
- @if($journal->transactions[1]->account->accounttype->description == 'Cash account')
- <span class="text-success">(cash)</span>
- @else
- <a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
- @endif
+ @foreach($journal->transactions as $t)
+ @if(floatval($t->amount < 0))
+ @if($t->account->accounttype->description == 'Cash account')
+ <span class="text-success">(cash)</span>
+ @else
+ <a href="{{route('accounts.show',$t->account_id)}}">{{{$t->account->name}}}</a>
+ @endif
+ @endif
+ @endforeach
</td>
</tr>
@endforeach