Skip to content

Firefly III: a personal finances manager

Various fixes for #916

James Cole401ae92a6205
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index 28116cd052..c53443cf21 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -91,8 +91,6 @@ class JournalCollector implements JournalCollectorInterface
'account_types.type as account_type',
];
- /** @var bool */
- private $filterTransfers = false;
/** @var array */
private $filters = [InternalTransferFilter::class];
@@ -125,7 +123,7 @@ class JournalCollector implements JournalCollectorInterface
public function addFilter(string $filter): JournalCollectorInterface
{
$interfaces = class_implements($filter);
- if (in_array(FilterInterface::class, $interfaces)) {
+ if (in_array(FilterInterface::class, $interfaces) && !in_array($filter, $this->filters) ) {
Log::debug(sprintf('Enabled filter %s', $filter));
$this->filters[] = $filter;
}
@@ -237,7 +235,6 @@ class JournalCollector implements JournalCollectorInterface
if ($accounts->count() > 1) {
$this->addFilter(TransferFilter::class);
- $this->filterTransfers = true;
}
@@ -261,7 +258,6 @@ class JournalCollector implements JournalCollectorInterface
if ($accounts->count() > 1) {
$this->addFilter(TransferFilter::class);
- $this->filterTransfers = true;
}
return $this;
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index 754a854999..9f961bf06d 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -17,13 +17,12 @@ use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
+use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Http\Requests\BudgetFormRequest;
use FireflyIII\Http\Requests\BudgetIncomeRequest;
-use FireflyIII\Models\AccountType;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionType;
-use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
@@ -447,8 +446,6 @@ class BudgetController extends Controller
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
-
-
$start = session('first', Carbon::create()->startOfYear());
$end = new Carbon;
$limits = $this->getLimits($budget, $start, $end);
@@ -541,15 +538,12 @@ class BudgetController extends Controller
return $cache->get(); // @codeCoverageIgnore
}
- /** @var AccountRepositoryInterface $accountRepository */
- $accountRepository = app(AccountRepositoryInterface::class);
- $accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
- $set = $this->repository->getBudgetLimits($budget, $start, $end);
- $limits = new Collection();
+ $set = $this->repository->getBudgetLimits($budget, $start, $end);
+ $limits = new Collection();
/** @var BudgetLimit $entry */
foreach ($set as $entry) {
- $entry->spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $entry->start_date, $entry->end_date);
+ $entry->spent = $this->repository->spentInPeriod(new Collection([$budget]), new Collection(), $entry->start_date, $entry->end_date);
$limits->push($entry);
}
$cache->store($limits);
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index e3f137717a..04fd3dbd2b 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -175,7 +175,7 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
- $collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget);
+ $collector->setAllAssetAccounts()->setBudget($budget);
if (!is_null($budgetLimit->id)) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
@@ -220,7 +220,7 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
- $collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withCategoryInformation();
+ $collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation();
if (!is_null($budgetLimit->id)) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
@@ -244,7 +244,6 @@ class BudgetController extends Controller
$data = $this->generator->pieChart($chartData);
$cache->store($data);
-
return Response::json($data);
}
@@ -439,7 +438,7 @@ class BudgetController extends Controller
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
- $accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::EXPENSE]);
+ $accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::CASH]);
$grouped = $accounts->groupBy('id')->toArray();
$return = [];
foreach ($accountIds as $accountId) {
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index a3a4d33aac..4961d8987d 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -492,7 +492,7 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setBudgets($budgets);
+ $collector->setRange($start, $end)->setBudgets($budgets)->withBudgetInformation();
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);