Some expanded things.

This commit is contained in:
James Cole
2015-05-16 16:47:52 +02:00
parent c576902501
commit 2e7edd033c
4 changed files with 53 additions and 5 deletions

View File

@@ -138,7 +138,6 @@ class ReportQuery implements ReportQueryInterface
}
/**
* This method returns all "income" journals in a certain period, which are both transfers from a shared account
* and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
@@ -203,7 +202,6 @@ class ReportQuery implements ReportQueryInterface
}
/**
* Gets a list of expense accounts and the expenses therein, grouped by that expense account.
* This result excludes transfers to shared accounts which are expenses, technically.
@@ -273,8 +271,9 @@ class ReportQuery implements ReportQueryInterface
return floatval(
Auth::user()->transactionjournals()
->leftJoin('transactions' , 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->transactionTypes(['Withdrawal'])
->where('transactions.amount', '<', 0)
->where('transactions.account_id', $account->id)
->before($end)
@@ -284,6 +283,30 @@ class ReportQuery implements ReportQueryInterface
);
}
/**
* @param Account $account
* @param Carbon $start
* @param Carbon $end
* @param bool $shared
*
* @return float
*/
public function spentNoBudget(Account $account, Carbon $start, Carbon $end, $shared = false)
{
return floatval(
Auth::user()->transactionjournals()
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.amount', '<', 0)
->transactionTypes(['Withdrawal'])
->where('transactions.account_id', $account->id)
->before($end)
->after($start)
->whereNull('budget_transaction_journal.budget_id')
->sum('transactions.amount')
);
}
/**
* @param Carbon $start
* @param Carbon $end