This commit is contained in:
James Cole
2015-05-16 08:14:26 +02:00
parent 3896a66122
commit 3270d3bf96
5 changed files with 0 additions and 225 deletions

View File

@@ -85,55 +85,4 @@ class ReportHelper implements ReportHelperInterface
return $months;
}
/**
* @param Carbon $date
* @param bool $includeShared
*
* @return array
*/
public function yearBalanceReport(Carbon $date, $includeShared = false)
{
$start = clone $date;
$end = clone $date;
$sharedAccounts = [];
if ($includeShared === false) {
$sharedCollection = Auth::user()->accounts()
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
->where('account_meta.name', '=', 'accountRole')
->where('account_meta.data', '=', json_encode('sharedAsset'))
->get(['accounts.id']);
foreach ($sharedCollection as $account) {
$sharedAccounts[] = $account->id;
}
}
$accounts = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->orderBy('accounts.name', 'ASC')->get(['accounts.*'])
->filter(
function (Account $account) use ($sharedAccounts) {
if (!in_array($account->id, $sharedAccounts)) {
return $account;
}
return null;
}
);
$report = [];
$start->startOfYear()->subDay();
$end->endOfYear();
foreach ($accounts as $account) {
$startBalance = Steam::balance($account, $start);
$endBalance = Steam::balance($account, $end);
$report[] = [
'start' => $startBalance,
'end' => $endBalance,
'hide' => ($startBalance == 0 && $endBalance == 0),
'account' => $account,
'shared' => $account->accountRole == 'sharedAsset'
];
}
return $report;
}
}