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 @@ transactions[1]->amount);?> @if($journal->transactiontype->type == 'Withdrawal') - {{Amount::formatTransaction($journal->transactions[1],false)}} + {{Amount::formatTransaction($journal->transactions[1],false)}} @endif @if($journal->transactiontype->type == 'Deposit') - {{Amount::formatTransaction($journal->transactions[1],false)}} + {{Amount::formatTransaction($journal->transactions[1],false)}} @endif @if($journal->transactiontype->type == 'Transfer') - {{Amount::formatTransaction($journal->transactions[1],false)}} + {{Amount::formatTransaction($journal->transactions[1],false)}} @endif {{$journal->date->format('j F Y')}} - @if($journal->transactions[1]->account->accounttype->description == 'Cash account') - (cash) - @else - {{{$journal->transactions[1]->account->name}}} - @endif + @foreach($journal->transactions as $t) + @if(floatval($t->amount < 0)) + @if($t->account->accounttype->description == 'Cash account') + (cash) + @else + {{{$t->account->name}}} + @endif + @endif + @endforeach @endforeach