mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixes #151
This commit is contained in:
parent
4cded0bf57
commit
1aea4045a3
@ -97,7 +97,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
}
|
||||
|
||||
// stuff outside of budgets:
|
||||
$noBudget = $repository->getWithoutBudgetSum($start, $end);
|
||||
$noBudget = $repository->getWithoutBudgetSum($accounts, $start, $end);
|
||||
$budgetLine = new BudgetLine;
|
||||
$budgetLine->setOverspent($noBudget);
|
||||
$budgetLine->setSpent($noBudget);
|
||||
|
@ -200,7 +200,7 @@ class BudgetController extends Controller
|
||||
$allEntries->push([$name, $left, $spent, $overspent, $amount, $expenses]);
|
||||
}
|
||||
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($accounts, $start, $end);
|
||||
$allEntries->push([trans('firefly.noBudget'), '0', '0', $noBudgetExpenses, '0', '0']);
|
||||
$data = $this->generator->frontpage($allEntries);
|
||||
$cache->store($data);
|
||||
@ -266,7 +266,7 @@ class BudgetController extends Controller
|
||||
// this might be a good moment to collect no budget stuff.
|
||||
if (is_null($budget->id)) {
|
||||
// get without budget sum in range:
|
||||
$spent = $repository->getWithoutBudgetSum($currentStart, $currentEnd) * -1;
|
||||
$spent = $repository->getWithoutBudgetSum($accounts, $currentStart, $currentEnd) * -1;
|
||||
} else {
|
||||
if (isset($set[$id]['entries'][$year])) {
|
||||
$spent = $set[$id]['entries'][$year] * -1;
|
||||
|
@ -472,13 +472,15 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWithoutBudgetSum(Carbon $start, Carbon $end): string
|
||||
public function getWithoutBudgetSum(Collection $accounts, Carbon $start, Carbon $end): string
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$entry = $this->user
|
||||
->transactionjournals()
|
||||
->whereNotIn(
|
||||
@ -499,6 +501,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
|
||||
}
|
||||
)
|
||||
->whereIn('transactions.account_id', $ids)
|
||||
->transactionTypes([TransactionType::WITHDRAWAL])
|
||||
->first([DB::raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
|
||||
if (is_null($entry->journalAmount)) {
|
||||
|
@ -168,12 +168,13 @@ interface BudgetRepositoryInterface
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWithoutBudgetSum(Carbon $start, Carbon $end): string;
|
||||
public function getWithoutBudgetSum(Collection $accounts, Carbon $start, Carbon $end): string;
|
||||
|
||||
/**
|
||||
* Returns an array with the following key:value pairs:
|
||||
|
Loading…
Reference in New Issue
Block a user