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

This commit is contained in:
James Cole 2015-01-18 09:49:53 +01:00
parent 1068dcb8a4
commit 03e0510c4f
3 changed files with 36 additions and 29 deletions

View File

@ -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();
}

View File

@ -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')

View File

@ -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