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;
}
}

View File

@@ -30,11 +30,4 @@ interface ReportHelperInterface
*/
public function listOfMonths(Carbon $date);
/**
* @param Carbon $date
* @param bool $includeShared
*
* @return array
*/
public function yearBalanceReport(Carbon $date, $includeShared = false);
}

View File

@@ -437,58 +437,6 @@ class ReportQuery implements ReportQueryInterface
return $data;
}
/**
* This method returns all deposits into asset accounts, grouped by the revenue account,
*
* @param Carbon $start
* @param Carbon $end
* @param bool $includeShared
*
* @return Collection
*/
public function journalsByRevenueAccount(Carbon $start, Carbon $end, $includeShared = false)
{
$query = $this->queryJournalsWithTransactions($start, $end);
if ($includeShared === false) {
// show queries where transfer type is deposit, and its not to a shared account
// or where its a transfer and its from a shared account (both count as incomes)
$query->where(
function (Builder $query) {
$query->where(
function (Builder $q) {
$q->where('transaction_types.type', 'Deposit');
$q->where('acm_to.data', '!=', '"sharedAsset"');
}
);
$query->orWhere(
function (Builder $q) {
$q->where('transaction_types.type', 'Transfer');
$q->where('acm_from.data', '=', '"sharedAsset"');
}
);
}
);
} else {
// any deposit goes:
$query->where('transaction_types.type', 'Deposit');
}
$query->groupBy('t_from.account_id')->orderBy('queryAmount');
$data = $query->get(
['t_from.account_id as account_id', 'ac_from.name as name', 'ac_from.encrypted as encrypted', DB::Raw('SUM(t_from.amount) as `queryAmount`')]
);
// decrypt
$data->each(
function (Model $object) {
$object->name = intval($object->encrypted) == 1 ? Crypt::decrypt($object->name) : $object->name;
}
);
return $data;
}
/**
* With an equally misleading name, this query returns are transfers to shared accounts. These are considered
* expenses.

View File

@@ -138,17 +138,6 @@ interface ReportQueryInterface
*/
public function journalsByExpenseAccount(Carbon $start, Carbon $end, $includeShared = false);
/**
* This method returns all deposits into asset accounts, grouped by the revenue account,
*
* @param Carbon $start
* @param Carbon $end
* @param bool $includeShared
*
* @return Collection
*/
public function journalsByRevenueAccount(Carbon $start, Carbon $end, $includeShared = false);
/**
* With an equally misleading name, this query returns are transfers to shared accounts. These are considered
* expenses.