Experimental budget lines. #129

This commit is contained in:
James Cole 2015-12-12 08:21:46 +01:00
parent e59fd098a3
commit 8316afb176
2 changed files with 7 additions and 8 deletions

View File

@ -343,7 +343,7 @@ class ReportHelper implements ReportHelperInterface
$repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); $repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$set = $repository->getCategories(); $set = $repository->getCategories();
foreach ($set as $category) { foreach ($set as $category) {
$spent = $repository->balanceInPeriodForList($category, $start, $end, $accounts); $spent = $repository->balanceInPeriodForList($category, $start, $end, $accounts);
$category->spent = $spent; $category->spent = $spent;
$object->addCategory($category); $object->addCategory($category);
} }
@ -560,10 +560,9 @@ class ReportHelper implements ReportHelperInterface
$budgetLine->setBudget($budget); $budgetLine->setBudget($budget);
$budgetLine->setRepetition($repetition); $budgetLine->setRepetition($repetition);
$expenses = $repository->balanceInPeriodForList($budget, $start, $end, $accounts); $expenses = $repository->balanceInPeriodForList($budget, $start, $end, $accounts);
$expenses = $expenses * -1; $left = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? bcadd($repetition->amount, $expenses) : 0;
$left = $expenses < $repetition->amount ? bcsub($repetition->amount, $expenses) : 0; $spent = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? 0 : $expenses;
$spent = $expenses > $repetition->amount ? 0 : $expenses; $overspent = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? bcadd($expenses, $repetition->amount) : 0;
$overspent = $expenses > $repetition->amount ? bcsub($expenses, $repetition->amount) : 0;
$budgetLine->setLeft($left); $budgetLine->setLeft($left);
$budgetLine->setSpent($spent); $budgetLine->setSpent($spent);
@ -605,8 +604,8 @@ class ReportHelper implements ReportHelperInterface
$balance = new Balance; $balance = new Balance;
// build a balance header: // build a balance header:
$header = new BalanceHeader; $header = new BalanceHeader;
$budgets = $repository->getBudgets(); $budgets = $repository->getBudgets();
foreach ($accounts as $account) { foreach ($accounts as $account) {
$header->addAccount($account); $header->addAccount($account);
} }

View File

@ -39,7 +39,7 @@
</td> </td>
<td> <td>
{% if budgetLine.getSpent != 0 %} {% if budgetLine.getSpent != 0 %}
<span class="text-danger">{{ budgetLine.getSpent|formatAmountPlain }}</span> {{ budgetLine.getSpent|formatAmount }}
{% endif %} {% endif %}
{% if budgetLine.getSpent == 0 %} {% if budgetLine.getSpent == 0 %}