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

@ -136,6 +136,15 @@ class ReportHelper implements ReportHelperInterface
}
// then a new line for without budget.
$empty = new BalanceLine;
foreach ($accounts as $account) {
$spent = $this->query->spentNoBudget($account, $start, $end);
$balanceEntry = new BalanceEntry;
$balanceEntry->setAccount($account);
$balanceEntry->setSpent($spent);
$empty->addBalanceEntry($balanceEntry);
}
$balance->addBalanceLine($empty);
$balance->setBalanceHeader($header);

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

View File

@ -65,7 +65,17 @@ interface ReportQueryInterface
*
* @return float
*/
public function spentInBudget(Account $account, Budget $budget, Carbon $start, Carbon $end, $shared = false); // I think shared is irrelevant.
public function spentInBudget(Account $account, Budget $budget, Carbon $start, Carbon $end, $shared = false);
/**
* @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);
/**

View File

@ -18,7 +18,13 @@
<!-- make rows -->
{% for balanceLine in balance.getBalanceLines %}
<tr>
<td>{{ balanceLine.getBudget.name }}</td>
<td>
{% if balanceLine.getBudget %}
<a href="{{ route('budgets.show',balanceLine.getBudget.id) }}">{{ balanceLine.getBudget.name }}</a>
{% else %}
{{ 'noBudget'|_ }}
{% endif %}
</td>
<td>{{ balanceLine.getBudgetAmount|formatAmount }}</td>
{% for balanceEntry in balanceLine.getBalanceEntries %}
<td class="text-danger">