mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Cleaned up reports and associated views.
This commit is contained in:
@@ -22,11 +22,11 @@ class ReportHelper implements ReportHelperInterface
|
||||
* This method gets some kind of list for a monthly overview.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgetsForMonth(Carbon $date, $showSharedReports = false)
|
||||
public function getBudgetsForMonth(Carbon $date, $includeShared = false)
|
||||
{
|
||||
/** @var \FireflyIII\Helpers\Report\ReportQueryInterface $query */
|
||||
$query = App::make('FireflyIII\Helpers\Report\ReportQueryInterface');
|
||||
@@ -44,7 +44,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
->get(['budgets.*', 'budget_limits.amount as queryAmount']);
|
||||
|
||||
$budgets = Steam::makeArray($set);
|
||||
$amountSet = $query->journalsByBudget($start, $end, $showSharedReports);
|
||||
$amountSet = $query->journalsByBudget($start, $end, $includeShared);
|
||||
$amounts = Steam::makeArray($amountSet);
|
||||
$budgets = Steam::mergeArrays($budgets, $amounts);
|
||||
$budgets[0]['spent'] = isset($budgets[0]['spent']) ? $budgets[0]['spent'] : 0.0;
|
||||
@@ -53,7 +53,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
|
||||
// find transactions to shared asset accounts, which are without a budget by default:
|
||||
// which is only relevant when shared asset accounts are hidden.
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
$transfers = $query->sharedExpenses($start, $end)->sum('queryAmount');
|
||||
$budgets[0]['spent'] += floatval($transfers) * -1;
|
||||
}
|
||||
@@ -87,37 +87,16 @@ class ReportHelper implements ReportHelperInterface
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listOfYears(Carbon $date)
|
||||
{
|
||||
$start = clone $date;
|
||||
$end = Carbon::now();
|
||||
$years = [];
|
||||
while ($start <= $end) {
|
||||
$years[] = $start->year;
|
||||
$start->addYear();
|
||||
}
|
||||
$years[] = Carbon::now()->year;
|
||||
// force the current year.
|
||||
$years = array_unique($years);
|
||||
|
||||
return $years;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param bool $showSharedReports
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function yearBalanceReport(Carbon $date, $showSharedReports = false)
|
||||
public function yearBalanceReport(Carbon $date, $includeShared = false)
|
||||
{
|
||||
$start = clone $date;
|
||||
$end = clone $date;
|
||||
$sharedAccounts = [];
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
$sharedCollection = Auth::user()->accounts()
|
||||
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
|
||||
->where('account_meta.name', '=', 'accountRole')
|
||||
|
@@ -17,10 +17,11 @@ interface ReportHelperInterface
|
||||
* This method gets some kind of list for a monthly overview.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgetsForMonth(Carbon $date);
|
||||
public function getBudgetsForMonth(Carbon $date, $includeShared = false);
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
@@ -31,16 +32,9 @@ interface ReportHelperInterface
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listOfYears(Carbon $date);
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param bool $showSharedReports
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function yearBalanceReport(Carbon $date, $showSharedReports = false);
|
||||
public function yearBalanceReport(Carbon $date, $includeShared = false);
|
||||
}
|
||||
|
@@ -22,38 +22,6 @@ use Steam;
|
||||
class ReportQuery implements ReportQueryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* This query retrieves a list of accounts that are active and not shared.
|
||||
*
|
||||
* @param bool $showSharedReports
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function accountList($showSharedReports = false)
|
||||
{
|
||||
$query = Auth::user()->accounts();
|
||||
if ($showSharedReports === false) {
|
||||
|
||||
$query->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', "accountRole");
|
||||
}
|
||||
)->where(
|
||||
function (Builder $query) {
|
||||
$query->where('account_meta.data', '!=', '"sharedAsset"');
|
||||
$query->orWhereNull('account_meta.data');
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
$query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->whereIn('account_types.type', ['Default account', 'Cash account', 'Asset account'])
|
||||
->where('active', 1)
|
||||
->orderBy('accounts.name', 'ASC');
|
||||
|
||||
return $query->get(['accounts.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will get a list of all expenses in a certain time period that have no budget
|
||||
* and are balanced by a transfer to make up for it.
|
||||
@@ -123,15 +91,15 @@ class ReportQuery implements ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllAccounts(Carbon $start, Carbon $end, $showSharedReports = false)
|
||||
public function getAllAccounts(Carbon $start, Carbon $end, $includeShared = false)
|
||||
{
|
||||
$query = Auth::user()->accounts()->orderBy('accounts.name', 'ASC')
|
||||
->accountTypeIn(['Default account', 'Asset account', 'Cash account']);
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
$query->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||
@@ -208,14 +176,14 @@ class ReportQuery implements ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function incomeByPeriod(Carbon $start, Carbon $end, $showSharedReports = false)
|
||||
public function incomeInPeriod(Carbon $start, Carbon $end, $includeShared = false)
|
||||
{
|
||||
$query = $this->queryJournalsWithTransactions($start, $end);
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
// only get deposits not to a shared account
|
||||
// and transfers to a shared account.
|
||||
$query->where(
|
||||
@@ -268,11 +236,11 @@ class ReportQuery implements ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByBudget(Carbon $start, Carbon $end, $showSharedReports = false)
|
||||
public function journalsByBudget(Carbon $start, Carbon $end, $includeShared = false)
|
||||
{
|
||||
$query = Auth::user()->transactionjournals()
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
@@ -283,7 +251,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
}
|
||||
)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id');
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
|
||||
$query->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
@@ -307,11 +275,11 @@ class ReportQuery implements ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByCategory(Carbon $start, Carbon $end, $showSharedReports = false)
|
||||
public function journalsByCategory(Carbon $start, Carbon $end, $includeShared = false)
|
||||
{
|
||||
$query = Auth::user()->transactionjournals()
|
||||
->leftJoin(
|
||||
@@ -324,7 +292,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
}
|
||||
)
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id');
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
$query->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||
@@ -358,14 +326,14 @@ class ReportQuery implements ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByExpenseAccount(Carbon $start, Carbon $end, $showSharedReports = false)
|
||||
public function journalsByExpenseAccount(Carbon $start, Carbon $end, $includeShared = false)
|
||||
{
|
||||
$query = $this->queryJournalsWithTransactions($start, $end);
|
||||
if ($showSharedReports === false) {
|
||||
if ($includeShared === false) {
|
||||
// get all withdrawals not from a shared accounts
|
||||
// and all transfers to a shared account
|
||||
$query->where(
|
||||
@@ -410,14 +378,14 @@ class ReportQuery implements ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByRevenueAccount(Carbon $start, Carbon $end, $showSharedReports = false)
|
||||
public function journalsByRevenueAccount(Carbon $start, Carbon $end, $includeShared = false)
|
||||
{
|
||||
$query = $this->queryJournalsWithTransactions($start, $end);
|
||||
if ($showSharedReports === false) {
|
||||
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)
|
||||
|
@@ -14,15 +14,6 @@ use Illuminate\Support\Collection;
|
||||
interface ReportQueryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* This query retrieves a list of accounts that are active and not shared.
|
||||
*
|
||||
* @param bool $showSharedReports
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function accountList($showSharedReports = false);
|
||||
|
||||
/**
|
||||
* This method will get a list of all expenses in a certain time period that have no budget
|
||||
* and are balanced by a transfer to make up for it.
|
||||
@@ -52,11 +43,11 @@ interface ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllAccounts(Carbon $start, Carbon $end, $showSharedReports = false);
|
||||
public function getAllAccounts(Carbon $start, Carbon $end, $includeShared = false);
|
||||
|
||||
/**
|
||||
* Grabs a summary of all expenses grouped by budget, related to the account.
|
||||
@@ -88,22 +79,23 @@ interface ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
*/
|
||||
public function incomeByPeriod(Carbon $start, Carbon $end, $showSharedReports = false);
|
||||
public function incomeInPeriod(Carbon $start, Carbon $end, $includeShared = false);
|
||||
|
||||
/**
|
||||
* Gets a list of expenses grouped by the budget they were filed under.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByBudget(Carbon $start, Carbon $end, $showSharedReports = false);
|
||||
public function journalsByBudget(Carbon $start, Carbon $end, $includeShared = false);
|
||||
|
||||
/**
|
||||
* Gets a list of categories and the expenses therein, grouped by the relevant category.
|
||||
@@ -111,11 +103,11 @@ interface ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByCategory(Carbon $start, Carbon $end, $showSharedReports = false);
|
||||
public function journalsByCategory(Carbon $start, Carbon $end, $includeShared = false);
|
||||
|
||||
/**
|
||||
* Gets a list of expense accounts and the expenses therein, grouped by that expense account.
|
||||
@@ -125,22 +117,23 @@ interface ReportQueryInterface
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
*/
|
||||
public function journalsByExpenseAccount(Carbon $start, Carbon $end, $showSharedReports = false);
|
||||
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 $showSharedReports
|
||||
* @param bool $includeShared
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function journalsByRevenueAccount(Carbon $start, Carbon $end, $showSharedReports = false);
|
||||
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
|
||||
|
Reference in New Issue
Block a user