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

View File

@ -44,7 +44,7 @@ class ReportQuery implements ReportQueryInterface
->where('active', 1)
->where(
function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"');
$query->where('account_meta.data', '!=', '"sharedAsset"');
$query->orWhereNull('account_meta.data');
}
)
@ -119,7 +119,7 @@ class ReportQuery implements ReportQueryInterface
)
->where(
function (Builder $query) {
$query->where('account_meta.data', '!=', '"sharedExpense"');
$query->where('account_meta.data', '!=', '"sharedAsset"');
$query->orWhereNull('account_meta.data');
}
)
@ -211,13 +211,13 @@ class ReportQuery implements ReportQueryInterface
$query->where(
function ($q) {
$q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedExpense"');
$q->where('acm_to.data', '!=', '"sharedAsset"');
}
);
$query->orWhere(
function ($q) {
$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')
->where('transaction_journals.date', '>=', $start->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')
->groupBy('budgets.id')
->orderBy('budgets.name', 'ASC')
@ -301,7 +301,7 @@ class ReportQuery implements ReportQueryInterface
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
->where('transaction_journals.date', '>=', $start->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')
->groupBy('categories.id')
->orderBy('amount')
@ -351,13 +351,13 @@ class ReportQuery implements ReportQueryInterface
$query->where(
function ($q) {
$q->where('transaction_types.type', 'Withdrawal');
$q->where('acm_from.data', '!=', '"sharedExpense"');
$q->where('acm_from.data', '!=', '"sharedAsset"');
}
);
$query->orWhere(
function ($q) {
$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(
function ($q) {
$q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedExpense"');
$q->where('acm_to.data', '!=', '"sharedAsset"');
}
);
$query->orWhere(
function ($q) {
$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');
}
)
->where('account_meta.data', '"sharedExpense"')
->where('account_meta.data', '"sharedAsset"')
->after($start)
->before($end)
->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'
)
->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id')
->where('account_meta.data', '"sharedExpense"')
->where('account_meta.data', '"sharedAsset"')
->after($start)
->before($end)
->where('transaction_types.type', 'Transfer')

View File

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

View File

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