Shared expense should of course be shared asset.

This commit is contained in:
James Cole 2015-03-02 11:27:46 +01:00
parent c6042a9053
commit b261b0b447
4 changed files with 20 additions and 16 deletions

View File

@ -141,7 +141,7 @@ class ReportHelper implements ReportHelperInterface
$sharedCollection = \Auth::user()->accounts() $sharedCollection = \Auth::user()->accounts()
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id') ->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
->where('account_meta.name', '=', 'accountRole') ->where('account_meta.name', '=', 'accountRole')
->where('account_meta.data', '=', json_encode('sharedExpense')) ->where('account_meta.data', '=', json_encode('sharedAsset'))
->get(['accounts.id']); ->get(['accounts.id']);
foreach ($sharedCollection as $account) { foreach ($sharedCollection as $account) {
@ -166,7 +166,7 @@ class ReportHelper implements ReportHelperInterface
'start' => \Steam::balance($account, $start), 'start' => \Steam::balance($account, $start),
'end' => \Steam::balance($account, $end), 'end' => \Steam::balance($account, $end),
'account' => $account, 'account' => $account,
'shared' => $account->accountRole == 'sharedExpense' 'shared' => $account->accountRole == 'sharedAsset'
]; ];
} }

View File

@ -44,7 +44,7 @@ class ReportQuery implements ReportQueryInterface
->where('active', 1) ->where('active', 1)
->where( ->where(
function (Builder $query) { function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"'); $query->where('account_meta.data', '!=', '"sharedAsset"');
$query->orWhereNull('account_meta.data'); $query->orWhereNull('account_meta.data');
} }
) )
@ -119,7 +119,7 @@ class ReportQuery implements ReportQueryInterface
) )
->where( ->where(
function (Builder $query) { function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"'); $query->where('account_meta.data', '!=', '"sharedAsset"');
$query->orWhereNull('account_meta.data'); $query->orWhereNull('account_meta.data');
} }
) )
@ -211,13 +211,13 @@ class ReportQuery implements ReportQueryInterface
$query->where( $query->where(
function ($q) { function ($q) {
$q->where('transaction_types.type', 'Deposit'); $q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedExpense"'); $q->where('acm_to.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function ($q) { function ($q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_from.data', '=', '"sharedExpense"'); $q->where('acm_from.data', '=', '"sharedAsset"');
} }
); );
} }
@ -264,7 +264,7 @@ class ReportQuery implements ReportQueryInterface
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id') ->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('account_meta.data', '!=', '"sharedExpense"') ->where('account_meta.data', '!=', '"sharedAsset"')
->where('transaction_types.type', 'Withdrawal') ->where('transaction_types.type', 'Withdrawal')
->groupBy('budgets.id') ->groupBy('budgets.id')
->orderBy('budgets.name', 'ASC') ->orderBy('budgets.name', 'ASC')
@ -301,7 +301,7 @@ class ReportQuery implements ReportQueryInterface
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id') ->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d')) ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
->where('transaction_journals.date', '<=', $end->format('Y-m-d')) ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
->where('account_meta.data', '!=', '"sharedExpense"') ->where('account_meta.data', '!=', '"sharedAsset"')
->where('transaction_types.type', 'Withdrawal') ->where('transaction_types.type', 'Withdrawal')
->groupBy('categories.id') ->groupBy('categories.id')
->orderBy('amount') ->orderBy('amount')
@ -351,13 +351,13 @@ class ReportQuery implements ReportQueryInterface
$query->where( $query->where(
function ($q) { function ($q) {
$q->where('transaction_types.type', 'Withdrawal'); $q->where('transaction_types.type', 'Withdrawal');
$q->where('acm_from.data', '!=', '"sharedExpense"'); $q->where('acm_from.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function ($q) { function ($q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_to.data', '=', '"sharedExpense"'); $q->where('acm_to.data', '=', '"sharedAsset"');
} }
); );
} }
@ -409,13 +409,13 @@ class ReportQuery implements ReportQueryInterface
$query->where( $query->where(
function ($q) { function ($q) {
$q->where('transaction_types.type', 'Deposit'); $q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedExpense"'); $q->where('acm_to.data', '!=', '"sharedAsset"');
} }
); );
$query->orWhere( $query->orWhere(
function ($q) { function ($q) {
$q->where('transaction_types.type', 'Transfer'); $q->where('transaction_types.type', 'Transfer');
$q->where('acm_from.data', '=', '"sharedExpense"'); $q->where('acm_from.data', '=', '"sharedAsset"');
} }
); );
} }
@ -452,7 +452,7 @@ class ReportQuery implements ReportQueryInterface
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole'); $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
} }
) )
->where('account_meta.data', '"sharedExpense"') ->where('account_meta.data', '"sharedAsset"')
->after($start) ->after($start)
->before($end) ->before($end)
->where('transaction_types.type', 'Transfer') ->where('transaction_types.type', 'Transfer')
@ -494,7 +494,7 @@ class ReportQuery implements ReportQueryInterface
'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id' 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
) )
->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id') ->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id')
->where('account_meta.data', '"sharedExpense"') ->where('account_meta.data', '"sharedAsset"')
->after($start) ->after($start)
->before($end) ->before($end)
->where('transaction_types.type', 'Transfer') ->where('transaction_types.type', 'Transfer')

View File

@ -18,8 +18,8 @@ return [
], ],
'accountRoles' => [ 'accountRoles' => [
'defaultExpense' => 'Default expense account', 'defaultAsset' => 'Default asset account',
'sharedExpense' => 'Shared expense account' 'sharedAsset' => 'Shared asset account'
], ],
'range_to_text' => [ 'range_to_text' => [

View File

@ -2,7 +2,9 @@
<tr> <tr>
<th>&nbsp;</th> <th>&nbsp;</th>
<th>Name</th> <th>Name</th>
@if(isset($what) && $what == 'asset')
<th>Role</th> <th>Role</th>
@endif
<th>Current balance</th> <th>Current balance</th>
<th>Active</th> <th>Active</th>
<th>Last activity</th> <th>Last activity</th>
@ -16,7 +18,9 @@
</div> </div>
</td> </td>
<td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td> <td><a href="{{route('accounts.show',$account->id)}}">{{{$account->name}}}</a></td>
@if(isset($what) && $what == 'asset')
<td>{{{$account->accountRole}}}</td> <td>{{{$account->accountRole}}}</td>
@endif
<td>{!! Amount::format(Steam::balance($account)) !!}</td> <td>{!! Amount::format(Steam::balance($account)) !!}</td>
<td> <td>
@if($account->active) @if($account->active)