Skip to content

Firefly III: a personal finances manager

Big refactor to remove the deprecated transaction collector.

James Cole8b7e87ae5783
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php
index 40adb4502c..7fb20a98ca 100644
--- a/app/Api/V1/Controllers/Chart/AccountController.php
+++ b/app/Api/V1/Controllers/Chart/AccountController.php
@@ -178,7 +178,7 @@ class AccountController extends Controller
$defaultSet = $this->repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
- if (0 === \count($frontPage->data)) {
+ if (0 === count($frontPage->data)) {
$frontPage->data = $defaultSet;
$frontPage->save();
}
diff --git a/app/Api/V1/Controllers/PreferenceController.php b/app/Api/V1/Controllers/PreferenceController.php
index 6399702481..267b7cf0a2 100644
--- a/app/Api/V1/Controllers/PreferenceController.php
+++ b/app/Api/V1/Controllers/PreferenceController.php
@@ -61,7 +61,7 @@ class PreferenceController extends Controller
// an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty.
$frontPageAccounts = app('preferences')->getForUser($user, 'frontPageAccounts', [])->data;
- if (0 === \count($frontPageAccounts)) {
+ if (0 === count($frontPageAccounts)) {
/** @var Collection $accounts */
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$accountIds = $accounts->pluck('id')->toArray();
diff --git a/app/Api/V1/Requests/RuleRequest.php b/app/Api/V1/Requests/RuleRequest.php
index 36ae924e7c..a1ee7ec0a0 100644
--- a/app/Api/V1/Requests/RuleRequest.php
+++ b/app/Api/V1/Requests/RuleRequest.php
@@ -141,7 +141,7 @@ class RuleRequest extends Request
$data = $validator->getData();
$actions = $data['actions'] ?? [];
// need at least one trigger
- if (0 === \count($actions)) {
+ if (0 === count($actions)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
}
}
@@ -156,7 +156,7 @@ class RuleRequest extends Request
$data = $validator->getData();
$triggers = $data['triggers'] ?? [];
// need at least one trugger
- if (0 === \count($triggers)) {
+ if (0 === count($triggers)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
}
}
diff --git a/app/Console/Commands/ApplyRules.php b/app/Console/Commands/ApplyRules.php
index ab2dc139f8..425505b959 100644
--- a/app/Console/Commands/ApplyRules.php
+++ b/app/Console/Commands/ApplyRules.php
@@ -222,7 +222,7 @@ class ApplyRules extends Command
$finalList = new Collection;
$accountList = explode(',', $accountString);
- if (0 === \count($accountList)) {
+ if (0 === count($accountList)) {
$this->error('Please use the --accounts to indicate the accounts to apply rules to.');
return false;
@@ -267,7 +267,7 @@ class ApplyRules extends Command
}
$ruleGroupList = explode(',', $ruleGroupString);
- if (0 === \count($ruleGroupList)) {
+ if (0 === count($ruleGroupList)) {
// can be empty.
return true;
@@ -299,7 +299,7 @@ class ApplyRules extends Command
$finalList = new Collection;
$ruleList = explode(',', $ruleString);
- if (0 === \count($ruleList)) {
+ if (0 === count($ruleList)) {
// can be empty.
return true;
diff --git a/app/Console/Commands/CreateImport.php b/app/Console/Commands/CreateImport.php
index eacf0a54b3..1e54d4782d 100644
--- a/app/Console/Commands/CreateImport.php
+++ b/app/Console/Commands/CreateImport.php
@@ -225,8 +225,8 @@ class CreateImport extends Command
if (null === $importJob->tag) {
$this->errorLine('No transactions have been imported :(.');
}
- if (\count($importJob->errors) > 0) {
- $this->infoLine(sprintf('%d error(s) occurred:', \count($importJob->errors)));
+ if (count($importJob->errors) > 0) {
+ $this->infoLine(sprintf('%d error(s) occurred:', count($importJob->errors)));
foreach ($importJob->errors as $err) {
$this->errorLine('- ' . $err);
}
diff --git a/app/Console/Commands/Upgrade/MigrateToRules.php b/app/Console/Commands/Upgrade/MigrateToRules.php
index 9baca93974..502e0669e4 100644
--- a/app/Console/Commands/Upgrade/MigrateToRules.php
+++ b/app/Console/Commands/Upgrade/MigrateToRules.php
@@ -99,7 +99,7 @@ class MigrateToRules extends Command
if (null === $ruleGroup) {
$array = RuleGroup::get(['order'])->pluck('order')->toArray();
- $order = \count($array) > 0 ? max($array) + 1 : 1;
+ $order = count($array) > 0 ? max($array) + 1 : 1;
$ruleGroup = RuleGroup::create(
[
'user_id' => $user->id,
diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php
index 934f211b34..0f5abc5859 100644
--- a/app/Factory/AccountFactory.php
+++ b/app/Factory/AccountFactory.php
@@ -229,8 +229,8 @@ class AccountFactory
Log::debug(sprintf('No account type found by ID, continue search for "%s".', $accountType));
/** @var array $types */
$types = config('firefly.accountTypeByIdentifier.' . $accountType) ?? [];
- if (\count($types) > 0) {
- Log::debug(sprintf('%d accounts in list from config', \count($types)), $types);
+ if (count($types) > 0) {
+ Log::debug(sprintf('%d accounts in list from config', count($types)), $types);
$result = AccountType::whereIn('type', $types)->first();
}
if (null === $result && null !== $accountType) {
diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php
index 74447a7257..52f9251661 100644
--- a/app/Generator/Chart/Basic/ChartJsGenerator.php
+++ b/app/Generator/Chart/Basic/ChartJsGenerator.php
@@ -121,7 +121,7 @@ class ChartJsGenerator implements GeneratorInterface
$labels = \is_array($first['entries']) ? array_keys($first['entries']) : [];
$chartData = [
- 'count' => \count($data),
+ 'count' => count($data),
'labels' => $labels, // take ALL labels from the first set.
'datasets' => [],
];
diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.php
index 7b0c457dbe..c85b22ee9e 100644
--- a/app/Generator/Report/Tag/MonthReportGenerator.php
+++ b/app/Generator/Report/Tag/MonthReportGenerator.php
@@ -30,7 +30,6 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
use FireflyIII\Generator\Report\Support;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Tag;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Log;
@@ -79,7 +78,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$reportType = 'tag';
$expenses = $this->getExpenses();
$income = $this->getIncome();
- $accountSummary = $this->getObjectSummary($this->summarizeByAccount($expenses), $this->summarizeByAccount($income));
+ $accountSummary = $this->getObjectSummary($this->summarizeByAssetAccount($expenses), $this->summarizeByAssetAccount($income));
$tagSummary = $this->getObjectSummary($this->summarizeByTag($expenses), $this->summarizeByTag($income));
$averageExpenses = $this->getAverages($expenses, SORT_ASC);
$averageIncome = $this->getAverages($income, SORT_DESC);
@@ -163,12 +162,14 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$result = [];
/** @var array $journal */
foreach ($array as $journal) {
- /** @var Tag $journalTag */
- foreach ($journal['tag_ids'] as $journalTag) {
- $journalTagId = (int)$journalTag;
- if (\in_array($journalTagId, $tagIds, true)) {
- $result[$journalTagId] = $result[$journalTagId] ?? '0';
- $result[$journalTagId] = bcadd($journal['amount'], $result[$journalTagId]);
+ /**
+ * @var int $id
+ * @var array $tag
+ */
+ foreach ($journal['tags'] as $id => $tag) {
+ if (in_array($id, $tagIds, true)) {
+ $result[$id] = $result[$id] ?? '0';
+ $result[$id] = bcadd($journal['amount'], $result[$id]);
}
}
}
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 0da5cd83c7..06e8cf0f79 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -204,7 +204,7 @@ class AttachmentHelper implements AttachmentHelperInterface
}
Log::debug('Done processing uploads.');
}
- if (!\is_array($files) || (\is_array($files) && 0 === \count($files))) {
+ if (!\is_array($files) || (\is_array($files) && 0 === count($files))) {
Log::debug('Array of files is not an array. Probably nothing uploaded. Will not store attachments.');
}
diff --git a/app/Helpers/Chart/MetaPieChart.php b/app/Helpers/Chart/MetaPieChart.php
index 749368bd2e..1f1e00e765 100644
--- a/app/Helpers/Chart/MetaPieChart.php
+++ b/app/Helpers/Chart/MetaPieChart.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Helpers\Chart;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Tag;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@@ -117,8 +116,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]);
- $journals = $collector->getExtractedJournals();
- $sum = $this->sumJournals($journals);
+ $sum = $collector->getSum();
$sum = bcmul($sum, '-1');
$sum = bcsub($sum, $this->total);
$chartData[$key] = $sum;
@@ -131,8 +129,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]);
- $journals = $collector->getExtractedJournals();
- $sum = $this->sumJournals($journals);
+ $sum = $collector->getSum();
$sum = bcsub($sum, $this->total);
$chartData[$key] = $sum;
}
@@ -220,22 +217,20 @@ class MetaPieChart implements MetaPieChartInterface
*
* @codeCoverageIgnore
*
- * @param Collection $set
+ * @param array $array
*
* @return array
*/
- private function groupByTag(Collection $set): array
+ private function groupByTag(array $array): array
{
$grouped = [];
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $journal = $transaction->transactionJournal;
- $tags = $journal->tags;
+ /** @var array $journal */
+ foreach ($array as $journal) {
+ $tags = $journal['tags'] ?? [];
/** @var Tag $tag */
- foreach ($tags as $tag) {
- $tagId = $tag->id;
- $grouped[$tagId] = $grouped[$tagId] ?? '0';
- $grouped[$tagId] = bcadd($transaction->transaction_amount, $grouped[$tagId]);
+ foreach ($tags as $id => $tag) {
+ $grouped[$id] = $grouped[$id] ?? '0';
+ $grouped[$id] = bcadd($journal['amount'], $grouped[$id]);
}
}
@@ -270,22 +265,6 @@ class MetaPieChart implements MetaPieChartInterface
return $chartData;
}
- /**
- * @param array $journals
- * @return string
- */
- private function sumJournals(array $journals): string
- {
- $sum = '0';
- /** @var array $journal */
- foreach ($journals as $journal) {
- $amount = (string)$journal['amount'];
- $sum = bcadd($sum, $amount);
- }
-
- return $sum;
- }
-
/**
* Accounts setter.
*
@@ -413,4 +392,6 @@ class MetaPieChart implements MetaPieChartInterface
return $this;
}
+
+
}
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index d774508cd8..5030440e54 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -130,23 +130,15 @@ class GroupCollector implements GroupCollectorInterface
}
/**
- * Return the transaction journals without group information. Is useful in some instances.
+ * Same as getGroups but everything is in a paginator.
*
- * @return array
+ * @return LengthAwarePaginator
*/
- public function getExtractedJournals(): array
+ public function getPaginatedGroups(): LengthAwarePaginator
{
- $selection = $this->getGroups();
- $return = [];
- /** @var array $group */
- foreach ($selection as $group) {
- foreach ($group['transactions'] as $journalId => $journal) {
- $journal['group_title'] = $group['title'];
- $return[$journalId] = $journal;
- }
- }
+ $set = $this->getGroups();
- return $return;
+ return new LengthAwarePaginator($set, $this->total, $this->limit, $this->page);
}
/**
@@ -330,18 +322,6 @@ class GroupCollector implements GroupCollectorInterface
return $groups;
}
- /**
- * Same as getGroups but everything is in a paginator.
- *
- * @return LengthAwarePaginator
- */
- public function getPaginatedGroups(): LengthAwarePaginator
- {
- $set = $this->getGroups();
-
- return new LengthAwarePaginator($set, $this->total, $this->limit, $this->page);
- }
-
/**
* Define which accounts can be part of the source and destination transactions.
*
@@ -554,7 +534,7 @@ class GroupCollector implements GroupCollectorInterface
$this->query->where('transaction_journals.date', '>=', $startStr);
$this->query->where('transaction_journals.date', '<=', $endStr);
- app('log')->debug(sprintf('TransactionCollector range is now %s - %s (inclusive)', $startStr, $endStr));
+ app('log')->debug(sprintf('GroupCollector range is now %s - %s (inclusive)', $startStr, $endStr));
return $this;
}
@@ -642,7 +622,7 @@ class GroupCollector implements GroupCollectorInterface
*/
private function startQuery(): void
{
- app('log')->debug('TransactionCollector::startQuery');
+ app('log')->debug('GroupCollector::startQuery');
$this->query = $this->user
->transactionGroups()
->leftJoin('transaction_journals', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
@@ -778,4 +758,76 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
+
+ /**
+ * Limit results to a transactions without a budget..
+ *
+ * @return GroupCollectorInterface
+ */
+ public function withoutBudget(): GroupCollectorInterface
+ {
+ $this->withBudgetInformation();
+ $this->query->where(
+ function (EloquentBuilder $q) {
+ $q->whereNull('budget_transaction_journal.budget_id');
+ }
+ );
+
+ return $this;
+ }
+
+ /**
+ * Limit results to a transactions without a category.
+ *
+ * @return GroupCollectorInterface
+ */
+ public function withoutCategory(): GroupCollectorInterface
+ {
+ $this->withCategoryInformation();
+ $this->query->where(
+ function (EloquentBuilder $q) {
+ $q->whereNull('category_transaction_journal.category_id');
+ }
+ );
+
+ return $this;
+ }
+
+ /**
+ * Return the sum of all journals.
+ *
+ * @return string
+ */
+ public function getSum(): string
+ {
+ $journals = $this->getExtractedJournals();
+ $sum = '0';
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $amount = (string)$journal['amount'];
+ $sum = bcadd($sum, $amount);
+ }
+
+ return $sum;
+ }
+
+ /**
+ * Return the transaction journals without group information. Is useful in some instances.
+ *
+ * @return array
+ */
+ public function getExtractedJournals(): array
+ {
+ $selection = $this->getGroups();
+ $return = [];
+ /** @var array $group */
+ foreach ($selection as $group) {
+ foreach ($group['transactions'] as $journalId => $journal) {
+ $journal['group_title'] = $group['title'];
+ $return[$journalId] = $journal;
+ }
+ }
+
+ return $return;
+ }
}
\ No newline at end of file
diff --git a/app/Helpers/Collector/GroupCollectorInterface.php b/app/Helpers/Collector/GroupCollectorInterface.php
index 8684b2b082..cb10f517c4 100644
--- a/app/Helpers/Collector/GroupCollectorInterface.php
+++ b/app/Helpers/Collector/GroupCollectorInterface.php
@@ -46,6 +46,13 @@ interface GroupCollectorInterface
*/
public function getExtractedJournals(): array;
+ /**
+ * Return the sum of all journals.
+ *
+ * @return string
+ */
+ public function getSum(): string;
+
/**
* Return the groups.
*
@@ -170,6 +177,20 @@ interface GroupCollectorInterface
*/
public function setTags(Collection $tags): GroupCollectorInterface;
+ /**
+ * Limit results to a transactions without a budget.
+ *
+ * @return GroupCollectorInterface
+ */
+ public function withoutBudget(): GroupCollectorInterface;
+
+ /**
+ * Limit results to a transactions without a category.
+ *
+ * @return GroupCollectorInterface
+ */
+ public function withoutCategory(): GroupCollectorInterface;
+
/**
* Limit the search to one specific transaction group.
*
diff --git a/app/Helpers/Collector/TransactionCollector.php b/app/Helpers/Collector/TransactionCollector.php
index e7d4777d42..bd8fe01126 100644
--- a/app/Helpers/Collector/TransactionCollector.php
+++ b/app/Helpers/Collector/TransactionCollector.php
@@ -458,7 +458,7 @@ class TransactionCollector implements TransactionCollectorInterface
public function setBudgets(Collection $budgets): TransactionCollectorInterface
{
$budgetIds = $budgets->pluck('id')->toArray();
- if (0 !== \count($budgetIds)) {
+ if (0 !== count($budgetIds)) {
$this->joinBudgetTables();
Log::debug('Journal collector will filter for budgets', $budgetIds);
@@ -481,7 +481,7 @@ class TransactionCollector implements TransactionCollectorInterface
public function setCategories(Collection $categories): TransactionCollectorInterface
{
$categoryIds = $categories->pluck('id')->toArray();
- if (0 !== \count($categoryIds)) {
+ if (0 !== count($categoryIds)) {
$this->joinCategoryTables();
$this->query->where(
@@ -721,7 +721,7 @@ class TransactionCollector implements TransactionCollectorInterface
*/
public function setTypes(array $types): TransactionCollectorInterface
{
- if (\count($types) > 0) {
+ if (count($types) > 0) {
Log::debug('Set query collector types', $types);
$this->query->whereIn('transaction_types.type', $types);
}
@@ -849,7 +849,7 @@ class TransactionCollector implements TransactionCollectorInterface
TransactionViewFilter::class => new TransactionViewFilter,
DoubleTransactionFilter::class => new DoubleTransactionFilter,
];
- Log::debug(sprintf('Will run %d filters on the set.', \count($this->filters)));
+ Log::debug(sprintf('Will run %d filters on the set.', count($this->filters)));
foreach ($this->filters as $enabled) {
if (isset($filters[$enabled])) {
Log::debug(sprintf('Before filter %s: %d', $enabled, $set->count()));
diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php
index 44734957f4..ffb205d47a 100644
--- a/app/Helpers/Report/PopupReport.php
+++ b/app/Helpers/Report/PopupReport.php
@@ -22,7 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Report;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
@@ -52,54 +52,54 @@ class PopupReport implements PopupReportInterface
/**
* Collect the transactions for one account and one budget.
*
- * @param Budget $budget
+ * @param Budget $budget
* @param Account $account
- * @param array $attributes
+ * @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function balanceForBudget(Budget $budget, Account $account, array $attributes): Collection
+ public function balanceForBudget(Budget $budget, Account $account, array $attributes): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])->setBudget($budget);
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
- * Collect the tranactions for one account and no budget.
+ * Collect the transactions for one account and no budget.
*
* @param Account $account
- * @param array $attributes
+ * @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function balanceForNoBudget(Account $account, array $attributes): Collection
+ public function balanceForNoBudget(Account $account, array $attributes): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector
->setAccounts(new Collection([$account]))
->setTypes([TransactionType::WITHDRAWAL])
->setRange($attributes['startDate'], $attributes['endDate'])
->withoutBudget();
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
- * Collect the tranactions for a budget.
+ * Collect the transactions for a budget.
*
* @param Budget $budget
- * @param array $attributes
+ * @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byBudget(Budget $budget, array $attributes): Collection
+ public function byBudget(Budget $budget, array $attributes): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($attributes['accounts'])->setRange($attributes['startDate'], $attributes['endDate']);
@@ -110,97 +110,93 @@ class PopupReport implements PopupReportInterface
$collector->setBudget($budget);
}
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
* Collect journals by a category.
*
* @param Category $category
- * @param array $attributes
+ * @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byCategory(Category $category, array $attributes): Collection
+ public function byCategory(Category $category, array $attributes): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setAccounts($attributes['accounts'])->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
- ->setRange($attributes['startDate'], $attributes['endDate'])->withOpposingAccount()
+ ->setRange($attributes['startDate'], $attributes['endDate'])->withAccountInformation()
->setCategory($category);
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
* Group transactions by expense.
*
* @param Account $account
- * @param array $attributes
+ * @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byExpenses(Account $account, array $attributes): Collection
+ public function byExpenses(Account $account, array $attributes): array
{
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$repository->setUser($account->user);
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]);
- $transactions = $collector->getTransactions();
-
+ $journals = $collector->getExtractedJournals();
$report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
- // filter for transfers and withdrawals TO the given $account
- $transactions = $transactions->filter(
- function (Transaction $transaction) use ($report, $repository) {
- // get the destinations:
- $sources = $repository->getJournalSourceAccounts($transaction->transactionJournal)->pluck('id')->toArray();
-
- // do these intersect with the current list?
- return !empty(array_intersect($report, $sources));
+ $filtered = [];
+ // TODO not sure if filter is necessary.
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ if (in_array($journal['source_account_id'], $report, true)) {
+ $filtered[] = $journal;
}
- );
-
- return $transactions;
+ }
+ return $filtered;
}
/**
* Collect transactions by income.
*
* @param Account $account
- * @param array $attributes
+ * @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byIncome(Account $account, array $attributes): Collection
+ public function byIncome(Account $account, array $attributes): array
{
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$repository->setUser($account->user);
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($attributes['startDate'], $attributes['endDate'])
- ->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]);
- $transactions = $collector->getTransactions();
- $report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
+ ->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
+ ->withAccountInformation();
+ $journals = $collector->getExtractedJournals();
+ $report = $attributes['accounts']->pluck('id')->toArray(); // accounts used in this report
// filter the set so the destinations outside of $attributes['accounts'] are not included.
- $transactions = $transactions->filter(
- function (Transaction $transaction) use ($report, $repository) {
- // get the destinations:
- $journal = $transaction->transactionJournal;
- $destinations = $repository->getJournalDestinationAccounts($journal)->pluck('id')->toArray();
-
- // do these intersect with the current list?
- return !empty(array_intersect($report, $destinations));
+ // TODO not sure if filter is necessary.
+ $filtered = [];
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ if (in_array($journal['destination_account_id'], $report, true)) {
+ $filtered[] = $journal;
}
- );
-
- return $transactions;
+ }
+ return $filtered;
}
}
diff --git a/app/Helpers/Report/PopupReportInterface.php b/app/Helpers/Report/PopupReportInterface.php
index ca38466bca..d8b05f093c 100644
--- a/app/Helpers/Report/PopupReportInterface.php
+++ b/app/Helpers/Report/PopupReportInterface.php
@@ -39,9 +39,9 @@ interface PopupReportInterface
* @param Account $account
* @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function balanceForBudget(Budget $budget, Account $account, array $attributes): Collection;
+ public function balanceForBudget(Budget $budget, Account $account, array $attributes): array;
/**
* Get balances for transactions without a budget.
@@ -49,9 +49,9 @@ interface PopupReportInterface
* @param Account $account
* @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function balanceForNoBudget(Account $account, array $attributes): Collection;
+ public function balanceForNoBudget(Account $account, array $attributes): array;
/**
* Group by budget.
@@ -59,9 +59,9 @@ interface PopupReportInterface
* @param Budget $budget
* @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byBudget(Budget $budget, array $attributes): Collection;
+ public function byBudget(Budget $budget, array $attributes): array;
/**
* Group by category.
@@ -69,9 +69,9 @@ interface PopupReportInterface
* @param Category $category
* @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byCategory(Category $category, array $attributes): Collection;
+ public function byCategory(Category $category, array $attributes): array;
/**
* Do something with expense. Sorry, I am not very inspirational here.
@@ -79,9 +79,9 @@ interface PopupReportInterface
* @param Account $account
* @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byExpenses(Account $account, array $attributes): Collection;
+ public function byExpenses(Account $account, array $attributes): array;
/**
* Do something with income. Sorry, I am not very inspirational here.
@@ -89,7 +89,7 @@ interface PopupReportInterface
* @param Account $account
* @param array $attributes
*
- * @return Collection
+ * @return array
*/
- public function byIncome(Account $account, array $attributes): Collection;
+ public function byIncome(Account $account, array $attributes): array;
}
diff --git a/app/Helpers/Update/UpdateTrait.php b/app/Helpers/Update/UpdateTrait.php
index e57b1f12a4..969f644aef 100644
--- a/app/Helpers/Update/UpdateTrait.php
+++ b/app/Helpers/Update/UpdateTrait.php
@@ -57,9 +57,9 @@ trait UpdateTrait
// get releases from array.
$releases = $request->getReleases();
- Log::debug(sprintf('Found %d releases', \count($releases)));
+ Log::debug(sprintf('Found %d releases', count($releases)));
- if (\count($releases) > 0) {
+ if (count($releases) > 0) {
// first entry should be the latest entry:
/** @var Release $first */
$first = reset($releases);
diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php
index dcaf2cd6d7..4112b660ee 100644
--- a/app/Http/Controllers/Account/CreateController.php
+++ b/app/Http/Controllers/Account/CreateController.php
@@ -136,7 +136,7 @@ class CreateController extends Controller
// update preferences if necessary:
$frontPage = app('preferences')->get('frontPageAccounts', [])->data;
- if (AccountType::ASSET === $account->accountType->type && \count($frontPage) > 0) {
+ if (AccountType::ASSET === $account->accountType->type && count($frontPage) > 0) {
// @codeCoverageIgnoreStart
$frontPage[] = $account->id;
app('preferences')->set('frontPageAccounts', $frontPage);
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php
index a3949e6392..91dad191a2 100644
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Account;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@@ -126,7 +125,7 @@ class ShowController extends Controller
$collector
->setAccounts(new Collection([$account]))
->setLimit($pageSize)
- ->setPage($page)
+ ->setPage($page)->withAccountInformation()
->setRange($start, $end);
$groups = $collector->getPaginatedGroups();
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
@@ -170,17 +169,17 @@ class ShowController extends Controller
}
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
$periods = new Collection;
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('accounts.show.all', [$account->id]));
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('accounts.show.all', [$account->id]));
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$showAll = true;
return view(
'accounts.show',
- compact('account', 'showAll', 'isLiability', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end')
+ compact('account', 'showAll', 'isLiability', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end')
);
}
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index 00cf0d3f19..ac95d3c86e 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -356,7 +356,7 @@ class BillController extends Controller
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
$this->attachments->saveAttachmentsForModel($bill, $files);
- if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
+ if (count($this->attachments->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
}
@@ -384,7 +384,7 @@ class BillController extends Controller
$this->attachments->saveAttachmentsForModel($bill, $files);
// flash messages
- if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
+ if (count($this->attachments->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
}
$redirect = redirect($this->getPreviousUri('bills.edit.uri'));
diff --git a/app/Http/Controllers/Budget/AmountController.php b/app/Http/Controllers/Budget/AmountController.php
index 1f760649b9..36a4e36f2b 100644
--- a/app/Http/Controllers/Budget/AmountController.php
+++ b/app/Http/Controllers/Budget/AmountController.php
@@ -25,7 +25,7 @@ namespace FireflyIII\Http\Controllers\Budget;
use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\BudgetIncomeRequest;
use FireflyIII\Models\Budget;
@@ -71,9 +71,9 @@ class AmountController extends Controller
/**
* Set the amount for a single budget in a specific period. Shows a waring when its a lot.
*
- * @param Request $request
+ * @param Request $request
* @param BudgetRepositoryInterface $repository
- * @param Budget $budget
+ * @param Budget $budget
*
* @return JsonResponse
*
@@ -147,6 +147,7 @@ class AmountController extends Controller
*
* @param Carbon $start
* @param Carbon $end
+ * TODO remove this feature
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
@@ -164,10 +165,10 @@ class AmountController extends Controller
Log::debug(sprintf('Average is %s, so total available is %s because days is %d.', $average, $available, $daysInPeriod));
// amount earned in this period:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();
- $earned = (string)$collector->getTransactions()->sum('transaction_amount');
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::DEPOSIT]);
+ $earned = $collector->getSum();
// Total amount earned divided by the number of days in the whole search period is the average amount earned per day.
// This is multiplied by the number of days in the current period, showing you the average.
$earnedAverage = bcmul(bcdiv($earned, (string)$daysInSearchPeriod), (string)$daysInPeriod);
@@ -175,10 +176,10 @@ class AmountController extends Controller
Log::debug(sprintf('Earned is %s, earned average is %s', $earned, $earnedAverage));
// amount spent in period
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();
- $spent = (string)$collector->getTransactions()->sum('transaction_amount');
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::WITHDRAWAL]);
+ $spent = $collector->getSum();
$spentAverage = app('steam')->positive(bcmul(bcdiv($spent, (string)$daysInSearchPeriod), (string)$daysInPeriod));
Log::debug(sprintf('Spent is %s, spent average is %s', $earned, $earnedAverage));
@@ -227,8 +228,8 @@ class AmountController extends Controller
* Shows the form to update available budget.
*
* @param Request $request
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php
index 0c136764f9..26cb9e5134 100644
--- a/app/Http/Controllers/Budget/ShowController.php
+++ b/app/Http/Controllers/Budget/ShowController.php
@@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers\Budget;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
@@ -66,7 +66,7 @@ class ShowController extends Controller
/**
* Show transactions without a budget.
*
- * @param Request $request
+ * @param Request $request
* @param Carbon|null $start
* @param Carbon|null $end
*
@@ -86,20 +86,20 @@ class ShowController extends Controller
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
- ->withoutBudget()->withOpposingAccount();
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('budgets.no-budget'));
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
+ ->withoutBudget()->withAccountInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('budgets.no-budget'));
- return view('budgets.no-budget', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
+ return view('budgets.no-budget', compact('groups', 'subTitle', 'periods', 'start', 'end'));
}
/**
* Shows ALL transactions without a budget.
*
- * @param Request $request
+ * @param Request $request
* @param JournalRepositoryInterface $repository
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
@@ -115,14 +115,14 @@ class ShowController extends Controller
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
- ->withoutBudget()->withOpposingAccount();
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('budgets.no-budget'));
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
+ ->withoutBudget()->withAccountInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('budgets.no-budget'));
- return view('budgets.no-budget', compact('transactions', 'subTitle', 'start', 'end'));
+ return view('budgets.no-budget', compact('groups', 'subTitle', 'start', 'end'));
}
@@ -130,7 +130,7 @@ class ShowController extends Controller
* Show a single budget.
*
* @param Request $request
- * @param Budget $budget
+ * @param Budget $budget
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
@@ -145,22 +145,22 @@ class ShowController extends Controller
$repetition = null;
// collector:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('budgets.show', [$budget->id]));
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('budgets.show', [$budget->id]));
$subTitle = (string)trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
- return view('budgets.show', compact('limits', 'budget', 'repetition', 'transactions', 'subTitle'));
+ return view('budgets.show', compact('limits', 'budget', 'repetition', 'groups', 'subTitle'));
}
/**
* Show a single budget by a budget limit.
*
- * @param Request $request
- * @param Budget $budget
+ * @param Request $request
+ * @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
@@ -184,17 +184,18 @@ class ShowController extends Controller
);
// collector:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($budgetLimit->start_date, $budgetLimit->end_date)
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
+ $collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
/** @var Carbon $start */
$start = session('first', Carbon::now()->startOfYear());
$end = new Carbon;
$limits = $this->getLimits($budget, $start, $end);
- return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'transactions', 'subTitle'));
+ return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'groups', 'subTitle'));
}
}
diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php
index 8dbc24f45f..803cb3498e 100644
--- a/app/Http/Controllers/Category/NoCategoryController.php
+++ b/app/Http/Controllers/Category/NoCategoryController.php
@@ -25,8 +25,7 @@ namespace FireflyIII\Http\Controllers\Category;
use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -66,7 +65,7 @@ class NoCategoryController extends Controller
/**
* Show transactions without a category.
*
- * @param Request $request
+ * @param Request $request
* @param Carbon|null $start
* @param Carbon|null $end
*
@@ -90,15 +89,15 @@ class NoCategoryController extends Controller
Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)
+ ->setLimit($pageSize)->setPage($page)->withoutCategory()
->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
- $collector->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('categories.no-category'));
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('categories.no-category'));
- return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
+ return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
}
@@ -125,14 +124,13 @@ class NoCategoryController extends Controller
Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()
->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
- $collector->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath(route('categories.no-category.all'));
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath(route('categories.no-category.all'));
- return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
+ return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
}
}
diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php
index 79c552729a..f3db0b5df3 100644
--- a/app/Http/Controllers/Category/ShowController.php
+++ b/app/Http/Controllers/Category/ShowController.php
@@ -24,8 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
@@ -69,8 +68,8 @@ class ShowController extends Controller
/**
* Show a single category.
*
- * @param Request $request
- * @param Category $category
+ * @param Request $request
+ * @param Category $category
* @param Carbon|null $start
* @param Carbon|null $end
*
@@ -94,23 +93,24 @@ class ShowController extends Controller
'end' => $end->formatLocalized($this->monthAndDayFormat),]
);
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)
+ ->withAccountInformation()
->setCategory($category)->withBudgetInformation()->withCategoryInformation();
- $collector->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath($path);
+
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath($path);
Log::debug('End of show()');
- return view('categories.show', compact('category', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
+ return view('categories.show', compact('category', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
}
/**
* Show all transactions within a category.
*
- * @param Request $request
+ * @param Request $request
* @param Category $category
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
@@ -133,14 +133,15 @@ class ShowController extends Controller
$path = route('categories.show.all', [$category->id]);
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)
+ ->withAccountInformation()
->setCategory($category)->withBudgetInformation()->withCategoryInformation();
- $collector->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath($path);
- return view('categories.show', compact('category', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath($path);
+
+ return view('categories.show', compact('category', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
}
}
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 24d4af028f..555ce5c9de 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -24,11 +24,10 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -147,7 +146,7 @@ class AccountController extends Controller
// loop all found currencies and build the data array for the chart.
/**
- * @var int $currencyId
+ * @var int $currencyId
* @var TransactionCurrency $currency
*/
foreach ($currencies as $currencyId => $currency) {
@@ -174,13 +173,28 @@ class AccountController extends Controller
return response()->json($data);
}
+ /**
+ * Expenses per budget for all time, as shown on account overview.
+ *
+ * @param AccountRepositoryInterface $repository
+ * @param Account $account
+ *
+ * @return JsonResponse
+ */
+ public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
+ {
+ $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
+ $end = Carbon::now();
+
+ return $this->expenseBudget($account, $start, $end);
+ }
/**
* Expenses per budget, as shown on account overview.
*
* @param Account $account
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return JsonResponse
*/
@@ -194,30 +208,28 @@ class AccountController extends Controller
if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore
}
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withBudgetInformation()->setTypes([TransactionType::WITHDRAWAL]);
- $transactions = $collector->getTransactions();
- $chartData = [];
- $result = [];
- $budgetIds = [];
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $jrnlBudgetId = (int)$transaction->transaction_journal_budget_id;
- $transBudgetId = (int)$transaction->transaction_budget_id;
- $currencyName = $transaction->transaction_currency_name;
- $budgetId = max($jrnlBudgetId, $transBudgetId);
- $combi = $budgetId . $currencyName;
- $budgetIds[] = $budgetId;
+ $journals = $collector->getExtractedJournals();
+ $chartData = [];
+ $result = [];
+ $budgetIds = [];
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $currencyName = $journal['currency_name'];
+ $budgetId = (int)$journal['budget_id'];
+ $combi = $budgetId . $currencyName;
+ $budgetIds[] = $budgetId;
if (!isset($result[$combi])) {
$result[$combi] = [
'total' => '0',
'budget_id' => $budgetId,
'currency' => $currencyName,
- 'currency_symbol' => $transaction->transaction_currency_symbol,
+ 'currency_symbol' => $journal['currency_symbol'],
];
}
- $result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
+ $result[$combi]['total'] = bcadd($journal['amount'], $result[$combi]['total']);
}
$names = $this->getBudgetNames($budgetIds);
@@ -236,28 +248,27 @@ class AccountController extends Controller
}
/**
- * Expenses per budget for all time, as shown on account overview.
+ * Expenses grouped by category for account.
*
* @param AccountRepositoryInterface $repository
- * @param Account $account
+ * @param Account $account
*
* @return JsonResponse
*/
- public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
+ public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
{
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
$end = Carbon::now();
- return $this->expenseBudget($account, $start, $end);
+ return $this->expenseCategory($account, $start, $end);
}
-
/**
* Expenses per category for one single account.
*
* @param Account $account
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return JsonResponse
*/
@@ -272,20 +283,18 @@ class AccountController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
- $transactions = $collector->getTransactions();
- $result = [];
- $chartData = [];
- $categoryIds = [];
-
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $jrnlCatId = (int)$transaction->transaction_journal_category_id;
- $transCatId = (int)$transaction->transaction_category_id;
- $currencyName = $transaction->transaction_currency_name;
- $categoryId = max($jrnlCatId, $transCatId);
+ $journals = $collector->getExtractedJournals();
+ $result = [];
+ $chartData = [];
+ $categoryIds = [];
+
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $currencyName = $journal['currency_name'];
+ $categoryId = $journal['category_id'];
$combi = $categoryId . $currencyName;
$categoryIds[] = $categoryId;
if (!isset($result[$combi])) {
@@ -293,10 +302,10 @@ class AccountController extends Controller
'total' => '0',
'category_id' => $categoryId,
'currency' => $currencyName,
- 'currency_symbol' => $transaction->transaction_currency_symbol,
+ 'currency_symbol' => $journal['currency_symbol'],
];
}
- $result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
+ $result[$combi]['total'] = bcadd($journal['amount'], $result[$combi]['total']);
}
$names = $this->getCategoryNames($categoryIds);
@@ -314,23 +323,6 @@ class AccountController extends Controller
return response()->json($data);
}
- /**
- * Expenses grouped by category for account.
- *
- * @param AccountRepositoryInterface $repository
- * @param Account $account
- *
- * @return JsonResponse
- */
- public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
- {
- $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
- $end = Carbon::now();
-
- return $this->expenseCategory($account, $start, $end);
- }
-
-
/**
* Shows the balances for all the user's frontpage accounts.
*
@@ -348,7 +340,7 @@ class AccountController extends Controller
Log::debug('Frontpage preference set is ', $frontPage->data);
- if (0 === \count($frontPage->data)) {
+ if (0 === count($frontPage->data)) {
$frontPage->data = $defaultSet;
Log::debug('frontpage set is empty!');
$frontPage->save();
@@ -358,13 +350,28 @@ class AccountController extends Controller
return response()->json($this->accountBalanceChart($accounts, $start, $end));
}
+ /**
+ * Shows the income grouped by category for an account, in all time.
+ *
+ * @param AccountRepositoryInterface $repository
+ * @param Account $account
+ *
+ * @return JsonResponse
+ */
+ public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
+ {
+ $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
+ $end = Carbon::now();
+
+ return $this->incomeCategory($account, $start, $end);
+ }
/**
* Shows all income per account for each category.
*
* @param Account $account
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return JsonResponse
*/
@@ -380,19 +387,18 @@ class AccountController extends Controller
}
// grab all journals:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
- $transactions = $collector->getTransactions();
- $result = [];
- $chartData = [];
- $categoryIds = [];
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $jrnlCatId = (int)$transaction->transaction_journal_category_id;
- $transCatId = (int)$transaction->transaction_category_id;
- $categoryId = max($jrnlCatId, $transCatId);
- $currencyName = $transaction->transaction_currency_name;
+ $journals = $collector->getExtractedJournals();
+ $result = [];
+ $chartData = [];
+ $categoryIds = [];
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $categoryId = $journal['category_id'];
+ $currencyName = $journal['currency_name'];
$combi = $categoryId . $currencyName;
$categoryIds[] = $categoryId;
if (!isset($result[$combi])) {
@@ -400,10 +406,10 @@ class AccountController extends Controller
'total' => '0',
'category_id' => $categoryId,
'currency' => $currencyName,
- 'currency_symbol' => $transaction->transaction_currency_symbol,
+ 'currency_symbol' => $journal['currency_symbol'],
];
}
- $result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
+ $result[$combi]['total'] = bcadd($journal['amount'], $result[$combi]['total']);
}
$names = $this->getCategoryNames($categoryIds);
@@ -419,32 +425,15 @@ class AccountController extends Controller
return response()->json($data);
}
- /**
- * Shows the income grouped by category for an account, in all time.
- *
- * @param AccountRepositoryInterface $repository
- * @param Account $account
- *
- * @return JsonResponse
- */
- public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
- {
- $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
- $end = Carbon::now();
-
- return $this->incomeCategory($account, $start, $end);
- }
-
-
/**
* Shows overview of account during a single period.
*
* TODO this chart is not multi-currency aware.
*
* @param Account $account
- * @param Carbon $start
+ * @param Carbon $start
*
- * @param Carbon $end
+ * @param Carbon $end
*
* @return JsonResponse
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -502,8 +491,8 @@ class AccountController extends Controller
*
* TODO this chart is not multi-currency aware.
*
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
* @param Collection $accounts
*
* @return JsonResponse
@@ -579,7 +568,7 @@ class AccountController extends Controller
// loop all found currencies and build the data array for the chart.
/**
- * @var int $currencyId
+ * @var int $currencyId
* @var TransactionCurrency $currency
*/
foreach ($currencies as $currencyId => $currency) {
diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php
index fbbfd3695c..f96e7a1f4e 100644
--- a/app/Http/Controllers/Chart/BillController.php
+++ b/app/Http/Controllers/Chart/BillController.php
@@ -24,15 +24,13 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Bill;
-use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\JsonResponse;
-use Illuminate\Support\Collection;
/**
* Class BillController.
@@ -99,12 +97,11 @@ class BillController extends Controller
/**
* Shows overview for a single bill.
*
- * @param TransactionCollectorInterface $collector
- * @param Bill $bill
+ * @param Bill $bill
*
* @return JsonResponse
*/
- public function single(TransactionCollectorInterface $collector, Bill $bill): JsonResponse
+ public function single(Bill $bill): JsonResponse
{
$cache = new CacheProperties;
$cache->addProperty('chart.bill.single');
@@ -113,23 +110,18 @@ class BillController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
- $results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getTransactions();
- // TODO remove me
- /** @var Collection $results */
- $results = $results->sortBy(
- function (Transaction $transaction) {
- return $transaction->date->format('U');
- }
- );
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $journals = $collector->setBill($bill)->getExtractedJournals();
+
$chartData = [
['type' => 'bar', 'label' => (string)trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
['type' => 'bar', 'label' => (string)trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
['type' => 'line', 'label' => (string)trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
];
- /** @var Transaction $entry */
- foreach ($results as $entry) {
- $date = $entry->date->formatLocalized((string)trans('config.month_and_day'));
+ foreach ($journals as $journal) {
+ $date = $journal['date']->formatLocalized((string)trans('config.month_and_day'));
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
@@ -137,7 +129,7 @@ class BillController extends Controller
if (!isset($chartData[2]['entries'][$date])) {
$chartData[2]['entries'][$date] = '0';
}
- $amount = bcmul($entry->transaction_amount, '-1');
+ $amount = bcmul($journal['amount'], '-1');
$chartData[2]['entries'][$date] = bcadd($chartData[2]['entries'][$date], $amount); // amount of journal
}
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 8677cbc236..ef36292918 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -25,11 +25,10 @@ namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\CacheProperties;
@@ -128,7 +127,7 @@ class BudgetController extends Controller
*
* TODO this chart is not multi-currency aware.
*
- * @param Budget $budget
+ * @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
@@ -177,7 +176,7 @@ class BudgetController extends Controller
*
* TODO this chart is not multi-currency aware.
*
- * @param Budget $budget
+ * @param Budget $budget
* @param BudgetLimit|null $budgetLimit
*
* @return JsonResponse
@@ -195,21 +194,20 @@ class BudgetController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setBudget($budget);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setBudget($budget);
if (null !== $budgetLimit) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
- $transactions = $collector->getTransactions();
- $result = [];
- $chartData = [];
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $assetId = (int)$transaction->account_id;
+ $journals = $collector->getExtractedJournals();
+ $result = [];
+ $chartData = [];
+ foreach ($journals as $journal) {
+ $assetId = (int)$journal['destination_account_id'];
$result[$assetId] = $result[$assetId] ?? '0';
- $result[$assetId] = bcadd($transaction->transaction_amount, $result[$assetId]);
+ $result[$assetId] = bcadd($journal['amount'], $result[$assetId]);
}
$names = $this->getAccountNames(array_keys($result));
@@ -229,7 +227,7 @@ class BudgetController extends Controller
*
* TODO this chart is not multi-currency aware.
*
- * @param Budget $budget
+ * @param Budget $budget
* @param BudgetLimit|null $budgetLimit
*
* @return JsonResponse
@@ -247,23 +245,20 @@ class BudgetController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation();
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setBudget($budget)->withCategoryInformation();
if (null !== $budgetLimit) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
- $transactions = $collector->getTransactions();
- $result = [];
- $chartData = [];
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $jrnlCatId = (int)$transaction->transaction_journal_category_id;
- $transCatId = (int)$transaction->transaction_category_id;
- $categoryId = max($jrnlCatId, $transCatId);
+ $journals = $collector->getExtractedJournals();
+ $result = [];
+ $chartData = [];
+ foreach ($journals as $journal) {
+ $categoryId = (int)$journal['category_id'];
$result[$categoryId] = $result[$categoryId] ?? '0';
- $result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);
+ $result[$categoryId] = bcadd($journal['amount'], $result[$categoryId]);
}
$names = $this->getCategoryNames(array_keys($result));
@@ -282,7 +277,7 @@ class BudgetController extends Controller
*
* TODO this chart is not multi-currency aware.
*
- * @param Budget $budget
+ * @param Budget $budget
* @param BudgetLimit|null $budgetLimit
*
* @return JsonResponse
@@ -300,21 +295,22 @@ class BudgetController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withOpposingAccount();
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
+ $collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();
if (null !== $budgetLimit) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
- $transactions = $collector->getTransactions();
- $result = [];
- $chartData = [];
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $opposingId = (int)$transaction->opposing_account_id;
+ $journals = $collector->getExtractedJournals();
+ $result = [];
+ $chartData = [];
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $opposingId = (int)$journal['destination_account_id'];
$result[$opposingId] = $result[$opposingId] ?? '0';
- $result[$opposingId] = bcadd($transaction->transaction_amount, $result[$opposingId]);
+ $result[$opposingId] = bcadd($journal['amount'], $result[$opposingId]);
}
$names = $this->getAccountNames(array_keys($result));
@@ -392,9 +388,9 @@ class BudgetController extends Controller
*
* TODO this chart is not multi-currency aware.
*
- * @param Budget $budget
- * @param Carbon $start
- * @param Carbon $end
+ * @param Budget $budget
+ * @param Carbon $start
+ * @param Carbon $end
* @param Collection $accounts
*
* @return JsonResponse
@@ -441,8 +437,8 @@ class BudgetController extends Controller
* TODO this chart is not multi-currency aware.
*
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return JsonResponse
*/
diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php
index 845f02d546..b2627ef8f1 100644
--- a/app/Http/Controllers/Chart/BudgetReportController.php
+++ b/app/Http/Controllers/Chart/BudgetReportController.php
@@ -201,7 +201,7 @@ class BudgetReportController extends Controller
$chartData[$budget->id]['entries'][$label] = bcmul($currentExpenses, '-1');
$chartData[$budget->id . '-sum']['entries'][$label] = bcmul($sumOfExpenses[$budget->id], '-1');
- if (\count($budgetLimits) > 0) {
+ if (count($budgetLimits) > 0) {
$budgetLimitId = $budgetLimits->first()->id;
$leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount');
$leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses);
diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php
index baa6ededed..8d335b545a 100644
--- a/app/Http/Controllers/Chart/ExpenseReportController.php
+++ b/app/Http/Controllers/Chart/ExpenseReportController.php
@@ -188,7 +188,7 @@ class ExpenseReportController extends Controller
$newSet[$key] = $chartData[$key];
}
}
- if (0 === \count($newSet)) {
+ if (0 === count($newSet)) {
$newSet = $chartData; // @codeCoverageIgnore
}
$data = $this->generator->multiSet($newSet);
diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.php
index 6be03027a3..4a4a46e950 100644
--- a/app/Http/Controllers/Chart/TagReportController.php
+++ b/app/Http/Controllers/Chart/TagReportController.php
@@ -200,7 +200,7 @@ class TagReportController extends Controller
$cache->addProperty($start);
$cache->addProperty($end);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ //return response()->json($cache->get()); // @codeCoverageIgnore
}
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
@@ -254,7 +254,7 @@ class TagReportController extends Controller
$labelOut = $tag->id . '-out';
$labelSumIn = $tag->id . '-total-in';
$labelSumOut = $tag->id . '-total-out';
- $currentIncome = $income[$tag->id] ?? '0';
+ $currentIncome = bcmul($income[$tag->id] ?? '0','-1');
$currentExpense = $expenses[$tag->id] ?? '0';
// add to sum:
@@ -272,6 +272,8 @@ class TagReportController extends Controller
/** @var Carbon $currentStart */
$currentStart = clone $currentEnd;
$currentStart->addDay();
+ $currentStart->startOfDay();
+
}
// remove all empty entries to prevent cluttering:
$newSet = [];
@@ -280,7 +282,7 @@ class TagReportController extends Controller
$newSet[$key] = $chartData[$key];
}
}
- if (0 === \count($newSet)) {
+ if (0 === count($newSet)) {
$newSet = $chartData; // @codeCoverageIgnore
}
$data = $this->generator->multiSet($newSet);
diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php
index 1a82e2cf24..2cca2c370a 100644
--- a/app/Http/Controllers/Json/AutoCompleteController.php
+++ b/app/Http/Controllers/Json/AutoCompleteController.php
@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@@ -98,12 +98,10 @@ class AutoCompleteController extends Controller
/**
* List of all journals.
*
- * @param Request $request
- * @param TransactionCollectorInterface $collector
- *
+ * @param Request $request
* @return JsonResponse
*/
- public function allTransactionJournals(Request $request, TransactionCollectorInterface $collector): JsonResponse
+ public function allTransactionJournals(Request $request): JsonResponse
{
$search = (string)$request->get('search');
$cache = new CacheProperties;
@@ -115,8 +113,22 @@ class AutoCompleteController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
// find everything:
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setLimit(250)->setPage(1);
- $return = array_values(array_unique($collector->getTransactions()->pluck('description')->toArray()));
+
+ $journals = $collector->getExtractedJournals();
+ $return = [];
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ if (strlen($journal['group_title']) > 0) {
+ $return[] = $journal['group_title'];
+ }
+ if (strlen($journal['description']) > 0) {
+ $return[] = $journal['description'];
+ }
+ }
+ $return = array_unique($return);
if ('' !== $search) {
$return = array_values(
@@ -136,7 +148,7 @@ class AutoCompleteController extends Controller
/**
* @param Request $request
- * @param string $subject
+ * @param string $subject
*
* @return JsonResponse
* @throws FireflyException
@@ -250,13 +262,12 @@ class AutoCompleteController extends Controller
/**
* List of journals with their ID.
*
- * @param Request $request
- * @param TransactionCollectorInterface $collector
- * @param TransactionJournal $except
+ * @param Request $request
+ * @param TransactionJournal $except
*
* @return JsonResponse
*/
- public function journalsWithId(Request $request, TransactionCollectorInterface $collector, TransactionJournal $except): JsonResponse
+ public function journalsWithId(Request $request, TransactionJournal $except): JsonResponse
{
$search = (string)$request->get('search');
$cache = new CacheProperties;
@@ -268,15 +279,17 @@ class AutoCompleteController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
// find everything:
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setLimit(400)->setPage(1);
- $set = $collector->getTransactions()->pluck('description', 'journal_id')->toArray();
+ $set = $collector->getExtractedJournals();
$return = [];
- foreach ($set as $id => $description) {
- $id = (int)$id;
+ foreach ($set as $journal) {
+ $id = (int)$journal['transaction_journal_id'];
if ($id !== $except->id) {
$return[] = [
'id' => $id,
- 'name' => $id . ': ' . $description,
+ 'name' => $id . ': ' . $journal['description'],
];
}
}
@@ -327,13 +340,12 @@ class AutoCompleteController extends Controller
/**
* List of journals by type.
*
- * @param Request $request
- * @param TransactionCollectorInterface $collector
- * @param string $what
+ * @param Request $request
+ * @param string $what
*
* @return JsonResponse
*/
- public function transactionJournals(Request $request, TransactionCollectorInterface $collector, string $what): JsonResponse
+ public function transactionJournals(Request $request, string $what): JsonResponse
{
$search = (string)$request->get('search');
$cache = new CacheProperties;
@@ -348,8 +360,15 @@ class AutoCompleteController extends Controller
$type = config('firefly.transactionTypesByWhat.' . $what);
$types = [$type];
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes($types)->setLimit(250)->setPage(1);
- $return = array_unique($collector->getTransactions()->pluck('description')->toArray());
+ $result = $collector->getExtractedJournals();
+ $return = [];
+ foreach ($result as $journal) {
+ $return[] = $journal['description'];
+ }
+ $return = array_unique($return);
sort($return);
if ('' !== $search) {
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index 77a452d9a3..4d00919c56 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -23,12 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Report\NetWorthInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -134,35 +133,33 @@ class BoxController extends Controller
$sums = [];
// collect income of user:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)
- ->setTypes([TransactionType::DEPOSIT])
- ->withOpposingAccount();
- $set = $collector->getTransactions();
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $currencyId = (int)$transaction->transaction_currency_id;
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)
+ ->setTypes([TransactionType::DEPOSIT]);
+ $set = $collector->getExtractedJournals();
+ /** @var array $journal */
+ foreach ($set as $journal) {
+ $currencyId = (int)$journal['currency_id'];
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
- $incomes[$currencyId] = bcadd($incomes[$currencyId], $transaction->transaction_amount);
+ $incomes[$currencyId] = bcadd($incomes[$currencyId], $journal['amount']);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
- $sums[$currencyId] = bcadd($sums[$currencyId], $transaction->transaction_amount);
+ $sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']);
}
// collect expenses
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)
- ->setTypes([TransactionType::WITHDRAWAL])
- ->withOpposingAccount();
- $set = $collector->getTransactions();
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $currencyId = (int)$transaction->transaction_currency_id;
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)
+ ->setTypes([TransactionType::WITHDRAWAL]);
+ $set = $collector->getExtractedJournals();
+ /** @var array $journal */
+ foreach ($set as $journal) {
+ $currencyId = (int)$journal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
- $expenses[$currencyId] = bcadd($expenses[$currencyId], $transaction->transaction_amount);
+ $expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount']);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
- $sums[$currencyId] = bcadd($sums[$currencyId], $transaction->transaction_amount);
+ $sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']);
}
// format amounts:
@@ -173,7 +170,7 @@ class BoxController extends Controller
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
}
- if (0 === \count($sums)) {
+ if (0 === count($sums)) {
$currency = app('amount')->getDefaultCurrency();
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);
@@ -184,7 +181,7 @@ class BoxController extends Controller
'incomes' => $incomes,
'expenses' => $expenses,
'sums' => $sums,
- 'size' => \count($sums),
+ 'size' => count($sums),
];
diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.php
index 1303ba1109..b193aad99f 100644
--- a/app/Http/Controllers/Json/FrontpageController.php
+++ b/app/Http/Controllers/Json/FrontpageController.php
@@ -64,7 +64,7 @@ class FrontpageController extends Controller
}
}
$html = '';
- if (\count($info) > 0) {
+ if (count($info) > 0) {
try {
$html = view('json.piggy-banks', compact('info'))->render();
// @codeCoverageIgnoreStart
diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.php
index 9ad233c2b1..76a9d4c564 100644
--- a/app/Http/Controllers/Json/IntroController.php
+++ b/app/Http/Controllers/Json/IntroController.php
@@ -47,7 +47,7 @@ class IntroController
$specificPage = $specificPage ?? '';
$steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage);
- if (0 === \count($specificSteps)) {
+ if (0 === count($specificSteps)) {
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
return response()->json($steps);
@@ -55,7 +55,7 @@ class IntroController
if ($this->hasOutroStep($route)) {
// @codeCoverageIgnoreStart
// save last step:
- $lastStep = $steps[\count($steps) - 1];
+ $lastStep = $steps[count($steps) - 1];
// remove last step:
array_pop($steps);
// merge arrays and add last step again
diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php
index 3e0f407f18..f98d2c076a 100644
--- a/app/Http/Controllers/Json/ReconcileController.php
+++ b/app/Http/Controllers/Json/ReconcileController.php
@@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers\Json;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@@ -44,7 +44,7 @@ use Throwable;
/**
*
* Class ReconcileController
- *
+ * TODO needs a full rewrite
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ReconcileController extends Controller
@@ -84,8 +84,8 @@ class ReconcileController extends Controller
*
* @param Request $request
* @param Account $account
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return JsonResponse
*
@@ -189,8 +189,8 @@ class ReconcileController extends Controller
* Returns a list of transactions in a modal.
*
* @param Account $account
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return mixed
*
@@ -220,14 +220,15 @@ class ReconcileController extends Controller
$selectionEnd->addDays(3);
// grab transactions:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setAccounts(new Collection([$account]))
- ->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withOpposingAccount()->withCategoryInformation();
- $transactions = $collector->getTransactions();
+ ->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withCategoryInformation();
+ $groups = $collector->getGroups();
try {
$html = view(
- 'accounts.reconcile.transactions', compact('account', 'transactions', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
+ 'accounts.reconcile.transactions', compact('account', 'groups', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
)->render();
// @codeCoverageIgnoreStart
} catch (Throwable $e) {
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php
index 439fd8f4ae..00d98419a0 100644
--- a/app/Http/Controllers/PreferencesController.php
+++ b/app/Http/Controllers/PreferencesController.php
@@ -72,7 +72,7 @@ class PreferencesController extends Controller
// an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty.
- if (0 === \count($frontPageAccounts->data)) {
+ if (0 === count($frontPageAccounts->data)) {
$frontPageAccounts = $accountIds;
}
@@ -105,7 +105,7 @@ class PreferencesController extends Controller
{
// front page accounts
$frontPageAccounts = [];
- if (\is_array($request->get('frontPageAccounts')) && \count($request->get('frontPageAccounts')) > 0) {
+ if (\is_array($request->get('frontPageAccounts')) && count($request->get('frontPageAccounts')) > 0) {
foreach ($request->get('frontPageAccounts') as $id) {
$frontPageAccounts[] = (int)$id;
}
diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php
index 03f47f7dee..155ed5205f 100644
--- a/app/Http/Controllers/Rule/CreateController.php
+++ b/app/Http/Controllers/Rule/CreateController.php
@@ -88,8 +88,8 @@ class CreateController extends Controller
$oldActions = $this->getPreviousActions($request);
}
- $triggerCount = \count($oldTriggers);
- $actionCount = \count($oldActions);
+ $triggerCount = count($oldTriggers);
+ $actionCount = count($oldActions);
$subTitleIcon = 'fa-clone';
// title depends on whether or not there is a rule group:
@@ -140,8 +140,8 @@ class CreateController extends Controller
$oldTriggers = $this->getTriggersForBill($bill);
$oldActions = $this->getActionsForBill($bill);
- $triggerCount = \count($oldTriggers);
- $actionCount = \count($oldActions);
+ $triggerCount = count($oldTriggers);
+ $actionCount = count($oldActions);
$subTitleIcon = 'fa-clone';
// title depends on whether or not there is a rule group:
diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php
index 299c613d37..b474878cf6 100644
--- a/app/Http/Controllers/Rule/EditController.php
+++ b/app/Http/Controllers/Rule/EditController.php
@@ -79,19 +79,19 @@ class EditController extends Controller
$oldActions = [];
$oldTriggers = [];
// has old input?
- if (\count($request->old()) > 0) {
+ if (count($request->old()) > 0) {
$oldTriggers = $this->getPreviousTriggers($request);
- $triggerCount = \count($oldTriggers);
+ $triggerCount = count($oldTriggers);
$oldActions = $this->getPreviousActions($request);
- $actionCount = \count($oldActions);
+ $actionCount = count($oldActions);
}
// overrule old input when it has no rule data:
if (0 === $triggerCount && 0 === $actionCount) {
$oldTriggers = $this->getCurrentTriggers($rule);
- $triggerCount = \count($oldTriggers);
+ $triggerCount = count($oldTriggers);
$oldActions = $this->getCurrentActions($rule);
- $actionCount = \count($oldActions);
+ $actionCount = count($oldActions);
}
$hasOldInput = null !== $request->old('_token');
diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php
index 1f3d54ec14..c8edd0cabd 100644
--- a/app/Http/Controllers/Rule/SelectController.php
+++ b/app/Http/Controllers/Rule/SelectController.php
@@ -145,7 +145,7 @@ class SelectController extends Controller
// build trigger array from response
$triggers = $this->getValidTriggerList($request);
- if (0 === \count($triggers)) {
+ if (0 === count($triggers)) {
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
}
@@ -212,7 +212,7 @@ class SelectController extends Controller
{
$triggers = $rule->ruleTriggers;
- if (0 === \count($triggers)) {
+ if (0 === count($triggers)) {
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
}
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index 040a9a89dd..f56d3bdcf4 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -24,8 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Requests\TagFormRequest;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
@@ -171,8 +170,8 @@ class TagController extends Controller
/**
* Show a single tag.
*
- * @param Request $request
- * @param Tag $tag
+ * @param Request $request
+ * @param Tag $tag
* @param Carbon|null $start
* @param Carbon|null $end
*
@@ -196,23 +195,23 @@ class TagController extends Controller
$periods = $this->getTagPeriodOverview($tag, $start);
$path = route('tags.show', [$tag->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
- ->setTag($tag)->withBudgetInformation()->withCategoryInformation()->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath($path);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()
+ ->setTag($tag)->withBudgetInformation()->withCategoryInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath($path);
$sums = $this->repository->sumsOfTag($tag, $start, $end);
- return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'transactions', 'start', 'end'));
+ return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end'));
}
/**
* Show a single tag over all time.
*
* @param Request $request
- * @param Tag $tag
+ * @param Tag $tag
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*
@@ -230,15 +229,15 @@ class TagController extends Controller
$start = $this->repository->firstUseDate($tag) ?? new Carbon;
$end = new Carbon;
$path = route('tags.show', [$tag->id, 'all']);
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
- ->setTag($tag)->withBudgetInformation()->withCategoryInformation()->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath($path);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()
+ ->setTag($tag)->withBudgetInformation()->withCategoryInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath($path);
$sums = $this->repository->sumsOfTag($tag, $start, $end);
- return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'transactions', 'start', 'end'));
+ return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end'));
}
/**
@@ -276,7 +275,7 @@ class TagController extends Controller
* Update a tag.
*
* @param TagFormRequest $request
- * @param Tag $tag
+ * @param Tag $tag
*
* @return RedirectResponse
*/
diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php
index 03180bc831..479186ca23 100644
--- a/app/Http/Controllers/Transaction/IndexController.php
+++ b/app/Http/Controllers/Transaction/IndexController.php
@@ -27,7 +27,7 @@ namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
-use FireflyIII\Support\Http\Controllers\ModelInformation;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\Http\Controllers\PeriodOverview;
use Illuminate\Http\Request;
@@ -37,20 +37,21 @@ use Illuminate\Http\Request;
class IndexController extends Controller
{
use PeriodOverview;
+
/**
* Index for a range of transactions.
*
- * @param Request $request
- * @param string $transactionType
+ * @param Request $request
+ * @param string $objectType
* @param Carbon|null $start
* @param Carbon|null $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
- public function index(Request $request, string $transactionType, Carbon $start = null, Carbon $end = null)
+ public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
{
- $subTitleIcon = config('firefly.transactionIconsByType.' . $transactionType);
- $types = config('firefly.transactionTypesByType.' . $transactionType);
+ $subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
+ $types = config('firefly.transactionTypesByType.' . $objectType);
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
if (null === $start) {
@@ -65,13 +66,12 @@ class IndexController extends Controller
[$start, $end] = [$end, $start];
}
- $path = route('transactions.index', [$transactionType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
+ $path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$startStr = $start->formatLocalized($this->monthAndDayFormat);
$endStr = $end->formatLocalized($this->monthAndDayFormat);
- $subTitle = (string)trans(sprintf('firefly.title_%s_between',$transactionType), ['start' => $startStr, 'end' => $endStr]);
-
- $periods = $this->getTransactionPeriodOverview($transactionType, $end);
+ $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
+ $periods = $this->getTransactionPeriodOverview($objectType, $end);
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -86,6 +86,42 @@ class IndexController extends Controller
$groups = $collector->getPaginatedGroups();
$groups->setPath($path);
- return view('transactions.index', compact('subTitle', 'transactionType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
+ return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
+ }
+
+ /**
+ * Index for ALL transactions.
+ *
+ * @param Request $request
+ * @param string $objectType
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @throws \Exception
+ */
+ public function indexAll(Request $request, string $objectType)
+ {
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
+
+ $subTitleIcon = config('firefly.transactionIconsByWhat.' . $objectType);
+ $types = config('firefly.transactionTypesByWhat.' . $objectType);
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
+ $path = route('transactions.index.all', [$objectType]);
+ $first = $repository->firstNull();
+ $start = null === $first ? new Carbon : $first->date;
+ $end = new Carbon;
+ $subTitle = (string)trans('firefly.all_' . $objectType);
+
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
+ $collector->setRange($start, $end)
+ ->setTypes($types)->setLimit($pageSize)->setPage($page)->withAccountInformation()
+ ->withBudgetInformation()->withCategoryInformation();
+ $groups = $collector->getPaginatedGroups();
+ $groups->setPath($path);
+
+ return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'start', 'end'));
}
}
\ No newline at end of file
diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php
index 7724e628a0..59f47f5aa0 100644
--- a/app/Http/Controllers/Transaction/SingleController.php
+++ b/app/Http/Controllers/Transaction/SingleController.php
@@ -393,11 +393,11 @@ class SingleController extends Controller
// store the journal only, flash the rest.
Log::debug(sprintf('Count of error messages is %d', $this->attachments->getErrors()->count()));
- if (\count($this->attachments->getErrors()->get('attachments')) > 0) {
+ if (count($this->attachments->getErrors()->get('attachments')) > 0) {
session()->flash('error', $this->attachments->getErrors()->get('attachments'));
}
// flash messages
- if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
+ if (count($this->attachments->getMessages()->get('attachments')) > 0) {
session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
@@ -460,10 +460,10 @@ class SingleController extends Controller
$this->attachments->saveAttachmentsForModel($journal, $files);
// @codeCoverageIgnoreStart
- if (\count($this->attachments->getErrors()->get('attachments')) > 0) {
+ if (count($this->attachments->getErrors()->get('attachments')) > 0) {
session()->flash('error', $this->attachments->getErrors()->get('attachments'));
}
- if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
+ if (count($this->attachments->getMessages()->get('attachments')) > 0) {
session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
// @codeCoverageIgnoreEnd
diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php
index 37d6fbabc6..1296058911 100644
--- a/app/Http/Controllers/Transaction/SplitController.php
+++ b/app/Http/Controllers/Transaction/SplitController.php
@@ -152,7 +152,7 @@ class SplitController extends Controller
// flash messages
// @codeCoverageIgnoreStart
- if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
+ if (count($this->attachments->getMessages()->get('attachments')) > 0) {
session()->flash('info', $this->attachments->getMessages()->get('attachments'));
}
// @codeCoverageIgnoreEnd
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 548ebb69d1..e6f9c431b2 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -25,19 +25,12 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
-use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Helpers\Collector\GroupCollectorInterface;
-use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
-use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
-use FireflyIII\Helpers\Filter\SplitIndicatorFilter;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\Http\Controllers\ModelInformation;
use FireflyIII\Support\Http\Controllers\PeriodOverview;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
-use Illuminate\Support\Collection;
use Log;
/**
@@ -72,40 +65,6 @@ class TransactionController extends Controller
);
}
- /**
- * Index for ALL transactions.
- *
- * @param Request $request
- * @param string $what
- *
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
- */
- public function indexAll(Request $request, string $what)
- {
- throw new FireflyException('Do not use me.');
- $subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
- $types = config('firefly.transactionTypesByWhat.' . $what);
- $page = (int)$request->get('page');
- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
- $path = route('transactions.index.all', [$what]);
- $first = $this->repository->firstNull();
- $start = null === $first ? new Carbon : $first->date;
- $end = new Carbon;
- $subTitle = (string)trans('firefly.all_' . $what);
-
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($start, $end)
- ->setTypes($types)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
- ->withBudgetInformation()->withCategoryInformation();
- $collector->removeFilter(InternalTransferFilter::class);
- $collector->addFilter(SplitIndicatorFilter::class);
- $collector->addFilter(CountAttachmentsFilter::class);
- $transactions = $collector->getPaginatedTransactions();
- $transactions->setPath($path);
-
- return view('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'transactions', 'start', 'end'));
- }
/**
* Do a reconciliation.
@@ -141,7 +100,7 @@ class TransactionController extends Controller
{
$ids = $request->get('items');
$date = new Carbon($request->get('date'));
- if (\count($ids) > 0) {
+ if (count($ids) > 0) {
$order = 0;
$ids = array_unique($ids);
foreach ($ids as $id) {
diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php
index e806760e4c..a63dee1f99 100644
--- a/app/Http/Requests/ReportFormRequest.php
+++ b/app/Http/Requests/ReportFormRequest.php
@@ -130,7 +130,7 @@ class ReportFormRequest extends Request
$date = new Carbon;
$range = $this->get('daterange');
$parts = explode(' - ', (string)$range);
- if (2 === \count($parts)) {
+ if (2 === count($parts)) {
try {
$date = new Carbon($parts[1]);
// @codeCoverageIgnoreStart
@@ -181,7 +181,7 @@ class ReportFormRequest extends Request
$date = new Carbon;
$range = $this->get('daterange');
$parts = explode(' - ', (string)$range);
- if (2 === \count($parts)) {
+ if (2 === count($parts)) {
try {
$date = new Carbon($parts[0]);
// @codeCoverageIgnoreStart
diff --git a/app/Import/JobConfiguration/FakeJobConfiguration.php b/app/Import/JobConfiguration/FakeJobConfiguration.php
index 6936768b78..b762b5397c 100644
--- a/app/Import/JobConfiguration/FakeJobConfiguration.php
+++ b/app/Import/JobConfiguration/FakeJobConfiguration.php
@@ -100,8 +100,8 @@ class FakeJobConfiguration implements JobConfigurationInterface
$this->repository->setConfiguration($this->importJob, $configuration);
$messages = new MessageBag();
- if (3 !== \count($configuration)) {
- $messages->add('some_key', 'Ignore this error: ' . \count($configuration));
+ if (3 !== count($configuration)) {
+ $messages->add('some_key', 'Ignore this error: ' . count($configuration));
}
return $messages;
diff --git a/app/Import/Routine/YnabRoutine.php b/app/Import/Routine/YnabRoutine.php
index 71ff3fb970..a407cbd99f 100644
--- a/app/Import/Routine/YnabRoutine.php
+++ b/app/Import/Routine/YnabRoutine.php
@@ -83,14 +83,14 @@ class YnabRoutine implements RoutineInterface
$budgets = $configuration['budgets'] ?? [];
// if more than 1 budget, select budget first.
- if (\count($budgets) > 1) {
+ if (count($budgets) > 1) {
$this->repository->setStage($this->importJob, 'select_budgets');
$this->repository->setStatus($this->importJob, 'need_job_config');
return;
}
- if (1 === \count($budgets)) {
+ if (1 === count($budgets)) {
$this->repository->setStatus($this->importJob, 'ready_to_run');
$this->repository->setStage($this->importJob, 'get_accounts');
}
diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php
index 6980105893..74d142d8d3 100644
--- a/app/Import/Specifics/IngDescription.php
+++ b/app/Import/Specifics/IngDescription.php
@@ -71,7 +71,7 @@ class IngDescription implements SpecificInterface
public function run(array $row): array
{
$this->row = array_values($row);
- if (\count($this->row) >= 8) { // check if the array is correct
+ if (count($this->row) >= 8) { // check if the array is correct
switch ($this->row[4]) { // Get value for the mutation type
case 'GT': // InternetBankieren
case 'OV': // Overschrijving
diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php
index 42b631b2ec..310e619648 100644
--- a/app/Import/Storage/ImportArrayStorage.php
+++ b/app/Import/Storage/ImportArrayStorage.php
@@ -424,7 +424,7 @@ class ImportArrayStorage
{
/** @var array $array */
$array = $this->repository->getTransactions($this->importJob);
- $count = \count($array);
+ $count = count($array);
$toStore = [];
Log::notice(sprintf('Will now store the transactions. Count of items is %d.', $count));
@@ -441,7 +441,7 @@ class ImportArrayStorage
$transaction['import_hash_v2'] = $this->getHash($transaction);
$toStore[] = $transaction;
}
- $count = \count($toStore);
+ $count = count($toStore);
if (0 === $count) {
Log::info('No transactions to store left!');
@@ -509,13 +509,13 @@ class ImportArrayStorage
return false;
}
// how many hits do we need?
- Log::debug(sprintf('Array has %d transactions.', \count($transaction['transactions'])));
- Log::debug(sprintf('System has %d existing transfers', \count($this->transfers)));
+ Log::debug(sprintf('Array has %d transactions.', count($transaction['transactions'])));
+ Log::debug(sprintf('System has %d existing transfers', count($this->transfers)));
// loop over each split:
- Log::debug(sprintf('This transfer has %d split(s)', \count($transaction['transactions'])));
+ Log::debug(sprintf('This transfer has %d split(s)', count($transaction['transactions'])));
foreach ($transaction['transactions'] as $index => $current) {
Log::debug(sprintf('Required hits for transfer comparison is %d', self::REQUIRED_HITS));
- Log::debug(sprintf('Now at transfer split %d of %d', $index + 1, \count($transaction['transactions'])));
+ Log::debug(sprintf('Now at transfer split %d of %d', $index + 1, count($transaction['transactions'])));
// get the amount:
/** @noinspection UnnecessaryCastingInspection */
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index f99ba4f8b5..70c227faa7 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -416,7 +416,7 @@ class CreateRecurringTransactions implements ShouldQueue
Log::debug(
sprintf(
'Calculated %d occurrences between %s and %s',
- \count($occurrences),
+ count($occurrences),
$recurrence->first_date->format('Y-m-d'),
$includeWeekend->format('Y-m-d')
), $this->debugArray($occurrences)
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 9c06690c1b..372ddbc37c 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -332,7 +332,7 @@ class TransactionJournal extends Model
if (!self::isJoined($query, 'transaction_types')) {
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
}
- if (\count($types) > 0) {
+ if (count($types) > 0) {
$query->whereIn('transaction_types.type', $types);
}
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 0b5a68d548..5c78e5e7fa 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -99,7 +99,7 @@ class AccountRepository implements AccountRepositoryInterface
->where('account_meta.name', 'accountNumber')
->where('account_meta.data', json_encode($number));
- if (\count($types) > 0) {
+ if (count($types) > 0) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -123,7 +123,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
- if (\count($types) > 0) {
+ if (count($types) > 0) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -149,7 +149,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts();
- if (\count($types) > 0) {
+ if (count($types) > 0) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -244,7 +244,7 @@ class AccountRepository implements AccountRepositoryInterface
{
/** @var Collection $result */
$query = $this->user->accounts();
- if (\count($types) > 0) {
+ if (count($types) > 0) {
$query->accountTypeIn($types);
}
$query->orderBy('accounts.name','ASC');
@@ -267,7 +267,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'accountRole');
}]
);
- if (\count($types) > 0) {
+ if (count($types) > 0) {
$query->accountTypeIn($types);
}
$query->where('active', 1);
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index 3ea1993058..de43d5b0aa 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
@@ -52,8 +53,8 @@ class AccountTasker implements AccountTaskerInterface
/**
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -119,8 +120,8 @@ class AccountTasker implements AccountTaskerInterface
}
/**
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
* @param Collection $accounts
*
* @return array
@@ -130,23 +131,15 @@ class AccountTasker implements AccountTaskerInterface
// get all expenses for the given accounts in the given period!
// also transfers!
// get all transactions:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setAccounts($accounts)->setRange($start, $end);
$collector->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
- ->withOpposingAccount();
- $transactions = $collector->getTransactions();
- $transactions = $transactions->filter(
- function (Transaction $transaction) {
- // return negative amounts only.
- if (bccomp($transaction->transaction_amount, '0') === -1) {
- return $transaction;
- }
-
- return false;
- }
- );
- $expenses = $this->groupByOpposing($transactions);
+ ->withAccountInformation();
+ $journals = $collector->getExtractedJournals();
+ $expenses = $this->groupByDestination($journals);
// sort the result
// Obtain a list of columns
@@ -161,62 +154,12 @@ class AccountTasker implements AccountTaskerInterface
}
/**
- * @param Carbon $start
- * @param Carbon $end
- * @param Collection $accounts
- *
- * @return array
- */
- public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts): array
- {
- // get all expenses for the given accounts in the given period!
- // also transfers!
- // get all transactions:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAccounts($accounts)->setRange($start, $end);
- $collector->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
- ->withOpposingAccount();
- $transactions = $collector->getTransactions();
- $transactions = $transactions->filter(
- function (Transaction $transaction) {
- // return positive amounts only.
- if (1 === bccomp($transaction->transaction_amount, '0')) {
- return $transaction;
- }
-
- return false;
- }
- );
- $income = $this->groupByOpposing($transactions);
-
- // sort the result
- // Obtain a list of columns
- $sum = [];
- foreach ($income as $accountId => $row) {
- $sum[$accountId] = (float)$row['sum'];
- }
-
- array_multisort($sum, SORT_DESC, $income);
-
- return $income;
- }
-
- /**
- * @param User $user
- */
- public function setUser(User $user): void
- {
- $this->user = $user;
- }
-
- /**
- * @param Collection $transactions
+ * @param array $array
*
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- private function groupByOpposing(Collection $transactions): array
+ private function groupByDestination(array $array): array
{
$defaultCurrency = app('amount')->getDefaultCurrencyByUser($this->user);
/** @var CurrencyRepositoryInterface $currencyRepos */
@@ -226,19 +169,19 @@ class AccountTasker implements AccountTaskerInterface
$countAccounts = []; // if count remains 0 use original name, not the name with the currency.
- /** @var Transaction $transaction */
- foreach ($transactions as $transaction) {
- $opposingId = (int)$transaction->opposing_account_id;
- $currencyId = (int)$transaction->transaction_currency_id;
+ /** @var array $journal */
+ foreach ($array as $journal) {
+ $opposingId = (int)$journal['destination_account_id'];
+ $currencyId = (int)$journal['currency_id'];
$key = sprintf('%s-%s', $opposingId, $currencyId);
- $name = sprintf('%s (%s)', $transaction->opposing_account_name, $transaction->transaction_currency_code);
+ $name = sprintf('%s (%s)', $journal['destination_account_name'], $journal['currency_name']);
$countAccounts[$opposingId] = isset($countAccounts[$opposingId]) ? $countAccounts[$opposingId] + 1 : 1;
if (!isset($expenses[$key])) {
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);
$expenses[$key] = [
'id' => $opposingId,
'name' => $name,
- 'original' => $transaction->opposing_account_name,
+ 'original' => $journal['destination_account_name'],
'sum' => '0',
'average' => '0',
'currencies' => [],
@@ -246,8 +189,8 @@ class AccountTasker implements AccountTaskerInterface
'count' => 0,
];
}
- $expenses[$key]['currencies'][] = (int)$transaction->transaction_currency_id;
- $expenses[$key]['sum'] = bcadd($expenses[$key]['sum'], $transaction->transaction_amount);
+ $expenses[$key]['currencies'][] = (int)$journal['currency_id'];
+ $expenses[$key]['sum'] = bcadd($expenses[$key]['sum'], $journal['amount']);
++$expenses[$key]['count'];
}
// do averages:
@@ -261,10 +204,51 @@ class AccountTasker implements AccountTaskerInterface
if ($expenses[$key]['count'] > 1) {
$expenses[$key]['average'] = bcdiv($expenses[$key]['sum'], (string)$expenses[$key]['count']);
}
- $expenses[$key]['currencies'] = \count(array_unique($expenses[$key]['currencies']));
- $expenses[$key]['all_currencies'] = \count($currencies);
+ $expenses[$key]['currencies'] = count(array_unique($expenses[$key]['currencies']));
+ $expenses[$key]['all_currencies'] = count($currencies);
}
return $expenses;
}
+
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param Collection $accounts
+ *
+ * @return array
+ */
+ public function getIncomeReport(Carbon $start, Carbon $end, Collection $accounts): array
+ {
+ // get all expenses for the given accounts in the given period!
+ // also transfers!
+ // get all transactions:
+
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
+ $collector->setAccounts($accounts)->setRange($start, $end);
+ $collector->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
+ ->withAccountInformation();
+ $income = $this->groupByDestination($collector->getExtractedJournals());
+
+ // sort the result
+ // Obtain a list of columns
+ $sum = [];
+ foreach ($income as $accountId => $row) {
+ $sum[$accountId] = (float)$row['sum'];
+ }
+
+ array_multisort($sum, SORT_DESC, $income);
+
+ return $income;
+ }
+
+ /**
+ * @param User $user
+ */
+ public function setUser(User $user): void
+ {
+ $this->user = $user;
+ }
}
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 01018b2257..c3dc206fe7 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -155,21 +155,17 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setUser($this->user);
$collector->setRange($start, $end)->setBudgets($budgets)->withBudgetInformation();
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
-
- $set = $collector->getTransactions();
+ return $collector->getSum();
- return (string)$set->sum('transaction_amount');
}
/**
@@ -719,7 +715,6 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function spentInPeriodMc(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array
{
-
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
@@ -777,30 +772,17 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function spentInPeriodWoBudget(Collection $accounts, Carbon $start, Carbon $end): string
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->withoutBudget();
+ $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])
+ ->withoutBudget();
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
-
- $set = $collector->getTransactions();
- $set = $set->filter(
- function (Transaction $transaction) {
- if (bccomp($transaction->transaction_amount, '0') === -1) {
- return $transaction;
- }
-
- return null;
- }
- );
- return (string)$set->sum('transaction_amount');
+ return $collector->getSum();
}
/**
diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php
index 723e113dd6..869ff1b61a 100644
--- a/app/Repositories/Category/CategoryRepository.php
+++ b/app/Repositories/Category/CategoryRepository.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Repositories\Category;
use Carbon\Carbon;
use FireflyIII\Factory\CategoryFactory;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Category;
use FireflyIII\Models\Transaction;
@@ -77,8 +78,8 @@ class CategoryRepository implements CategoryRepositoryInterface
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return string
*/
@@ -86,34 +87,46 @@ class CategoryRepository implements CategoryRepositoryInterface
{
$set = $this->earnedInPeriodCollection($categories, $accounts, $start, $end);
- return (string)$set->sum('transaction_amount');
+ return $this->sumJournals($set);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection
+ public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
if (0 !== $accounts->count()) {
$collector->setAccounts($accounts);
}
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
-
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setCategories($categories);
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
+ }
+
+ /**
+ * @param array $journals
+ * @return string
+ */
+ private function sumJournals(array $journals): string
+ {
+ $sum = '0';
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $amount = (string)$journal['amount'];
+ $sum = bcadd($sum, $amount);
+ }
+
+ return $sum;
}
/**
@@ -122,8 +135,8 @@ class CategoryRepository implements CategoryRepositoryInterface
* Get me the amount earned in this period, grouped per currency, where no category was set.
*
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
@@ -174,8 +187,8 @@ class CategoryRepository implements CategoryRepositoryInterface
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
@@ -234,26 +247,20 @@ class CategoryRepository implements CategoryRepositoryInterface
}
/**
- * Find a category.
- *
- * @param string $name
+ * Returns a list of all the categories belonging to a user.
*
- * @return Category|null
+ * @return Collection
*/
- public function findByName(string $name): ?Category
+ public function getCategories(): Collection
{
- $categories = $this->user->categories()->get(['categories.*']);
- foreach ($categories as $category) {
- if ($category->name === $name) {
- return $category;
- }
- }
+ /** @var Collection $set */
+ $set = $this->user->categories()->orderBy('name', 'ASC')->get();
- return null;
+ return $set;
}
/**
- * @param int|null $categoryId
+ * @param int|null $categoryId
* @param string|null $categoryName
*
* @return Category|null
@@ -279,6 +286,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result;
}
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
* Find a category or return NULL
*
@@ -291,8 +300,41 @@ class CategoryRepository implements CategoryRepositoryInterface
return $this->user->categories()->find($categoryId);
}
+ /**
+ * Find a category.
+ *
+ * @param string $name
+ *
+ * @return Category|null
+ */
+ public function findByName(string $name): ?Category
+ {
+ $categories = $this->user->categories()->get(['categories.*']);
+ foreach ($categories as $category) {
+ if ($category->name === $name) {
+ return $category;
+ }
+ }
+
+ return null;
+ }
+
/** @noinspection MoreThanThreeArgumentsInspection */
+ /**
+ * @param array $data
+ *
+ * @return Category
+ */
+ public function store(array $data): Category
+ {
+ /** @var CategoryFactory $factory */
+ $factory = app(CategoryFactory::class);
+ $factory->setUser($this->user);
+
+ return $factory->findOrCreate(null, $data['name']);
+ }
+
/**
* @param Category $category
*
@@ -322,34 +364,62 @@ class CategoryRepository implements CategoryRepositoryInterface
}
/**
- * Get all categories with ID's.
+ * @param Category $category
*
- * @param array $categoryIds
+ * @return Carbon|null
+ */
+ private function getFirstJournalDate(Category $category): ?Carbon
+ {
+ $query = $category->transactionJournals()->orderBy('date', 'ASC');
+ $result = $query->first(['transaction_journals.*']);
+
+ if (null !== $result) {
+ return $result->date;
+ }
+
+ return null;
+ }
+
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
+ /**
+ * @param Category $category
*
- * @return Collection
+ * @return Carbon|null
*/
- public function getByIds(array $categoryIds): Collection
+ private function getFirstTransactionDate(Category $category): ?Carbon
{
- return $this->user->categories()->whereIn('id', $categoryIds)->get();
+ // check transactions:
+ $query = $category->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->orderBy('transaction_journals.date', 'ASC');
+
+ $lastTransaction = $query->first(['transaction_journals.*']);
+ if (null !== $lastTransaction) {
+ return new Carbon($lastTransaction->date);
+ }
+
+ return null;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
- * Returns a list of all the categories belonging to a user.
+ * Get all categories with ID's.
+ *
+ * @param array $categoryIds
*
* @return Collection
*/
- public function getCategories(): Collection
+ public function getByIds(array $categoryIds): Collection
{
- /** @var Collection $set */
- $set = $this->user->categories()->orderBy('name', 'ASC')->get();
-
- return $set;
+ return $this->user->categories()->whereIn('id', $categoryIds)->get();
}
+ /** @noinspection MoreThanThreeArgumentsInspection */
+
/**
- * @param Category $category
+ * @param Category $category
* @param Collection $accounts
*
* @return Carbon|null
@@ -378,11 +448,61 @@ class CategoryRepository implements CategoryRepositoryInterface
return $lastJournalDate;
}
+ /**
+ * @param Category $category
+ * @param Collection $accounts
+ *
+ * @return Carbon|null
+ */
+ private function getLastJournalDate(Category $category, Collection $accounts): ?Carbon
+ {
+ $query = $category->transactionJournals()->orderBy('date', 'DESC');
+
+ if ($accounts->count() > 0) {
+ $query->leftJoin('transactions as t', 't.transaction_journal_id', '=', 'transaction_journals.id');
+ $query->whereIn('t.account_id', $accounts->pluck('id')->toArray());
+ }
+
+ $result = $query->first(['transaction_journals.*']);
+
+ if (null !== $result) {
+ return $result->date;
+ }
+
+ return null;
+ }
+
+ /**
+ * @param Category $category
+ * @param Collection $accounts
+ *
+ * @return Carbon|null
+ * @throws \Exception
+ */
+ private function getLastTransactionDate(Category $category, Collection $accounts): ?Carbon
+ {
+ // check transactions:
+ $query = $category->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->orderBy('transaction_journals.date', 'DESC');
+ if ($accounts->count() > 0) {
+ // filter journals:
+ $query->whereIn('transactions.account_id', $accounts->pluck('id')->toArray());
+ }
+
+ $lastTransaction = $query->first(['transaction_journals.*']);
+ if (null !== $lastTransaction) {
+ return new Carbon($lastTransaction->date);
+ }
+
+ return null;
+ }
+
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
@@ -423,12 +543,10 @@ class CategoryRepository implements CategoryRepositoryInterface
return $data;
}
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
@@ -463,13 +581,11 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result;
}
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
@@ -510,12 +626,10 @@ class CategoryRepository implements CategoryRepositoryInterface
return $data;
}
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
@@ -576,42 +690,38 @@ class CategoryRepository implements CategoryRepositoryInterface
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return string
*/
public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string
{
- $set = $this->spentInPeriodCollection($categories, $accounts, $start, $end);
-
+ $array = $this->spentInPeriodCollection($categories, $accounts, $start, $end);
- return (string)$set->sum('transaction_amount');
+ return $this->sumJournals($array);
}
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection
+ public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setCategories($categories);
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
@@ -620,50 +730,38 @@ class CategoryRepository implements CategoryRepositoryInterface
* Get me the amount spent in this period, grouped per currency, where no category was set.
*
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
public function spentInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->withoutCategory();
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
-
- $set = $collector->getTransactions();
- $set = $set->filter(
- function (Transaction $transaction) {
- if (bccomp($transaction->transaction_amount, '0') === -1) {
- return $transaction;
- }
-
- return null;
- }
- );
+ $set = $collector->getExtractedJournals();
$return = [];
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $currencyId = $transaction->transaction_currency_id;
+ /** @var array $journal */
+ foreach($set as $journal) {
+ $currencyId = (int)$journal['currency_id'];
if (!isset($return[$currencyId])) {
$return[$currencyId] = [
'spent' => '0',
'currency_id' => $currencyId,
- 'currency_symbol' => $transaction->transaction_currency_symbol,
- 'currency_code' => $transaction->transaction_currency_code,
- 'currency_decimal_places' => $transaction->transaction_currency_dp,
+ 'currency_symbol' => $journal['currency_symbol'],
+ 'currency_code' => $journal['currency_code'],
+ 'currency_decimal_places' => $journal['currency_decimal_places'],
];
}
- $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
+ $return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $journal['amount']);
}
return $return;
@@ -672,15 +770,15 @@ class CategoryRepository implements CategoryRepositoryInterface
/**
* @param Collection $categories
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return array
*/
public function spentInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL]);
@@ -694,20 +792,14 @@ class CategoryRepository implements CategoryRepositoryInterface
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
- if (0 === $accounts->count()) {
- $collector->setAllAssetAccounts();
- }
- $set = $collector->getTransactions();
+ $set = $collector->getExtractedJournals();
$return = [];
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $jrnlCatId = (int)$transaction->transaction_journal_category_id;
- $transCatId = (int)$transaction->transaction_category_id;
- $categoryId = max($jrnlCatId, $transCatId);
- $currencyId = (int)$transaction->transaction_currency_id;
- $name = $transaction->transaction_category_name;
- $name = '' === (string)$name ? $transaction->transaction_journal_category_name : $name;
+ /** @var array $journal */
+ foreach ($set as $journal) {
+ $categoryId = (int)$journal['category_id'];
+ $currencyId = (int)$journal['currency_id'];
+ $name = $journal['category_name'];
// make array for category:
if (!isset($return[$categoryId])) {
@@ -720,13 +812,13 @@ class CategoryRepository implements CategoryRepositoryInterface
$return[$categoryId]['spent'][$currencyId] = [
'spent' => '0',
'currency_id' => $currencyId,
- 'currency_symbol' => $transaction->transaction_currency_symbol,
- 'currency_code' => $transaction->transaction_currency_code,
- 'currency_decimal_places' => $transaction->transaction_currency_dp,
+ 'currency_symbol' => $journal['currency_symbol'],
+ 'currency_code' => $journal['currency_code'],
+ 'currency_decimal_places' => $journal['currency_decimal_places'],
];
}
$return[$categoryId]['spent'][$currencyId]['spent']
- = bcadd($return[$categoryId]['spent'][$currencyId]['spent'], $transaction->transaction_amount);
+ = bcadd($return[$categoryId]['spent'][$currencyId]['spent'], $journal['amount']);
}
return $return;
@@ -734,8 +826,8 @@ class CategoryRepository implements CategoryRepositoryInterface
/**
* @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
+ * @param Carbon $start
+ * @param Carbon $end
*
* @return string
*/
@@ -767,23 +859,9 @@ class CategoryRepository implements CategoryRepositoryInterface
return (string)$set->sum('transaction_amount');
}
- /**
- * @param array $data
- *
- * @return Category
- */
- public function store(array $data): Category
- {
- /** @var CategoryFactory $factory */
- $factory = app(CategoryFactory::class);
- $factory->setUser($this->user);
-
- return $factory->findOrCreate(null, $data['name']);
- }
-
/**
* @param Category $category
- * @param array $data
+ * @param array $data
*
* @return Category
*/
@@ -794,91 +872,4 @@ class CategoryRepository implements CategoryRepositoryInterface
return $service->update($category, $data);
}
-
- /**
- * @param Category $category
- *
- * @return Carbon|null
- */
- private function getFirstJournalDate(Category $category): ?Carbon
- {
- $query = $category->transactionJournals()->orderBy('date', 'ASC');
- $result = $query->first(['transaction_journals.*']);
-
- if (null !== $result) {
- return $result->date;
- }
-
- return null;
- }
-
- /**
- * @param Category $category
- *
- * @return Carbon|null
- */
- private function getFirstTransactionDate(Category $category): ?Carbon
- {
- // check transactions:
- $query = $category->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->orderBy('transaction_journals.date', 'ASC');
-
- $lastTransaction = $query->first(['transaction_journals.*']);
- if (null !== $lastTransaction) {
- return new Carbon($lastTransaction->date);
- }
-
- return null;
- }
-
- /**
- * @param Category $category
- * @param Collection $accounts
- *
- * @return Carbon|null
- */
- private function getLastJournalDate(Category $category, Collection $accounts): ?Carbon
- {
- $query = $category->transactionJournals()->orderBy('date', 'DESC');
-
- if ($accounts->count() > 0) {
- $query->leftJoin('transactions as t', 't.transaction_journal_id', '=', 'transaction_journals.id');
- $query->whereIn('t.account_id', $accounts->pluck('id')->toArray());
- }
-
- $result = $query->first(['transaction_journals.*']);
-
- if (null !== $result) {
- return $result->date;
- }
-
- return null;
- }
-
- /**
- * @param Category $category
- * @param Collection $accounts
- *
- * @return Carbon|null
- * @throws \Exception
- */
- private function getLastTransactionDate(Category $category, Collection $accounts): ?Carbon
- {
- // check transactions:
- $query = $category->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->orderBy('transaction_journals.date', 'DESC');
- if ($accounts->count() > 0) {
- // filter journals:
- $query->whereIn('transactions.account_id', $accounts->pluck('id')->toArray());
- }
-
- $lastTransaction = $query->first(['transaction_journals.*']);
- if (null !== $lastTransaction) {
- return new Carbon($lastTransaction->date);
- }
-
- return null;
- }
}
diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php
index d7ce278258..b30dc1704c 100644
--- a/app/Repositories/Category/CategoryRepositoryInterface.php
+++ b/app/Repositories/Category/CategoryRepositoryInterface.php
@@ -66,9 +66,9 @@ interface CategoryRepositoryInterface
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
+ public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
@@ -222,9 +222,9 @@ interface CategoryRepositoryInterface
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
+ public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/**
* A very cryptic method name that means:
diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php
index 9fcf7cc050..19bff4e24c 100644
--- a/app/Repositories/ImportJob/ImportJobRepository.php
+++ b/app/Repositories/ImportJob/ImportJobRepository.php
@@ -91,9 +91,9 @@ class ImportJobRepository implements ImportJobRepositoryInterface
Log::debug(sprintf('Now in appendTransactions(%s)', $job->key));
$existingTransactions = $this->getTransactions($job);
$new = array_merge($existingTransactions, $transactions);
- Log::debug(sprintf('Old transaction count: %d', \count($existingTransactions)));
- Log::debug(sprintf('To be added transaction count: %d', \count($transactions)));
- Log::debug(sprintf('New count: %d', \count($new)));
+ Log::debug(sprintf('Old transaction count: %d', count($existingTransactions)));
+ Log::debug(sprintf('To be added transaction count: %d', count($transactions)));
+ Log::debug(sprintf('New count: %d', count($new)));
$this->setTransactions($job, $new);
return $job;
@@ -333,7 +333,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$json = Crypt::encrypt(json_encode($transactions));
// set count for easy access
- $array = ['count' => \count($transactions)];
+ $array = ['count' => count($transactions)];
$job->transactions = $array;
$job->save();
// store file.
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index ad792d742f..3ed62a9b64 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -25,8 +25,8 @@ namespace FireflyIII\Repositories\Tag;
use Carbon\Carbon;
use DB;
use FireflyIII\Factory\TagFactory;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
@@ -76,7 +76,7 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param Tag $tag
+ * @param Tag $tag
* @param Carbon $start
* @param Carbon $end
*
@@ -94,20 +94,21 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param Tag $tag
+ * @param Tag $tag
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection
+ public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
$collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAllAssetAccounts()->setTag($tag);
+ $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setTag($tag);
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
@@ -157,20 +158,21 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param Tag $tag
+ * @param Tag $tag
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection
+ public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector =app(GroupCollectorInterface::class);
+
$collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAllAssetAccounts()->setTag($tag);
+ $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setTag($tag);
- return $collector->getTransactions();
+ return $collector->getExtractedJournals();
}
/**
@@ -234,7 +236,7 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param Tag $tag
+ * @param Tag $tag
* @param Carbon $start
* @param Carbon $end
*
@@ -266,7 +268,7 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param Tag $tag
+ * @param Tag $tag
* @param Carbon|null $start
* @param Carbon|null $end
*
@@ -275,16 +277,15 @@ class TagRepository implements TagRepositoryInterface
*/
public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
if (null !== $start && null !== $end) {
$collector->setRange($start, $end);
}
- $collector->setAllAssetAccounts()->setTag($tag)->withOpposingAccount();
- $collector->removeFilter(InternalTransferFilter::class);
- $transactions = $collector->getTransactions();
+ $collector->setTag($tag)->withAccountInformation();
+ $journals = $collector->getExtractedJournals();
$sums = [
TransactionType::WITHDRAWAL => '0',
@@ -292,9 +293,10 @@ class TagRepository implements TagRepositoryInterface
TransactionType::TRANSFER => '0',
];
- foreach ($transactions as $transaction) {
- $amount = app('steam')->positive((string)$transaction->transaction_amount);
- $type = $transaction->transaction_type_type;
+ /** @var array $journal */
+ foreach ($journals as $journal) {
+ $amount = app('steam')->positive((string)$journal['amount']);
+ $type = $journal['transaction_type_type'];
if (TransactionType::WITHDRAWAL === $type) {
$amount = bcmul($amount, '-1');
}
@@ -350,39 +352,37 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param Tag $tag
- * @param Carbon $start
- * @param Carbon $end
+ * @param int|null $year
*
* @return Collection
*/
- public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection
+ private function getTagsInYear(?int $year): Collection
{
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::TRANSFER])->setAllAssetAccounts()->setTag($tag);
+ // get all tags in the year (if present):
+ $tagQuery = $this->user->tags()
+ ->leftJoin('tag_transaction_journal', 'tag_transaction_journal.tag_id', '=', 'tags.id')
+ ->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
+ ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->where(
+ function (Builder $query) {
+ $query->where('transactions.amount', '>', 0);
+ $query->orWhereNull('transactions.amount');
+ }
+ )
+ ->groupBy(['tags.id', 'tags.tag']);
- return $collector->getTransactions();
- }
+ // add date range (or not):
+ if (null === $year) {
+ Log::debug('Get tags without a date.');
+ $tagQuery->whereNull('tags.date');
+ }
+ if (null !== $year) {
+ Log::debug(sprintf('Get tags with year %s.', $year));
+ $tagQuery->where('tags.date', '>=', $year . '-01-01 00:00:00')->where('tags.date', '<=', $year . '-12-31 23:59:59');
+ }
- /**
- * @param Tag $tag
- * @param array $data
- *
- * @return Tag
- */
- public function update(Tag $tag, array $data): Tag
- {
- $tag->tag = $data['tag'];
- $tag->date = $data['date'];
- $tag->description = $data['description'];
- $tag->latitude = $data['latitude'];
- $tag->longitude = $data['longitude'];
- $tag->zoomLevel = $data['zoom_level'];
- $tag->save();
+ return $tagQuery->get(['tags.id', 'tags.tag', DB::raw('SUM(transactions.amount) as amount_sum')]);
- return $tag;
}
/**
@@ -436,36 +436,38 @@ class TagRepository implements TagRepositoryInterface
}
/**
- * @param int|null $year
+ * @param Tag $tag
+ * @param Carbon $start
+ * @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- private function getTagsInYear(?int $year): Collection
+ public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): array
{
- // get all tags in the year (if present):
- $tagQuery = $this->user->tags()
- ->leftJoin('tag_transaction_journal', 'tag_transaction_journal.tag_id', '=', 'tags.id')
- ->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->where(
- function (Builder $query) {
- $query->where('transactions.amount', '>', 0);
- $query->orWhereNull('transactions.amount');
- }
- )
- ->groupBy(['tags.id', 'tags.tag']);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setUser($this->user);
+ $collector->setRange($start, $end)->setTypes([TransactionType::TRANSFER])->setTag($tag);
- // add date range (or not):
- if (null === $year) {
- Log::debug('Get tags without a date.');
- $tagQuery->whereNull('tags.date');
- }
- if (null !== $year) {
- Log::debug(sprintf('Get tags with year %s.', $year));
- $tagQuery->where('tags.date', '>=', $year . '-01-01 00:00:00')->where('tags.date', '<=', $year . '-12-31 23:59:59');
- }
+ return $collector->getExtractedJournals();
+ }
- return $tagQuery->get(['tags.id', 'tags.tag', DB::raw('SUM(transactions.amount) as amount_sum')]);
+ /**
+ * @param Tag $tag
+ * @param array $data
+ *
+ * @return Tag
+ */
+ public function update(Tag $tag, array $data): Tag
+ {
+ $tag->tag = $data['tag'];
+ $tag->date = $data['date'];
+ $tag->description = $data['description'];
+ $tag->latitude = $data['latitude'];
+ $tag->longitude = $data['longitude'];
+ $tag->zoomLevel = $data['zoom_level'];
+ $tag->save();
+ return $tag;
}
}
diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php
index 44f49059c9..a8411f31ee 100644
--- a/app/Repositories/Tag/TagRepositoryInterface.php
+++ b/app/Repositories/Tag/TagRepositoryInterface.php
@@ -60,9 +60,9 @@ interface TagRepositoryInterface
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection;
+ public function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): array;
/**
* @param string $tag
@@ -97,9 +97,9 @@ interface TagRepositoryInterface
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection;
+ public function incomeInPeriod(Tag $tag, Carbon $start, Carbon $end): array;
/**
* @param Tag $tag
@@ -179,9 +179,9 @@ interface TagRepositoryInterface
* @param Carbon $start
* @param Carbon $end
*
- * @return Collection
+ * @return array
*/
- public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): Collection;
+ public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): array;
/**
* Update a tag.
diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php
index d33e0ef412..5da19bdec9 100644
--- a/app/Rules/BelongsUser.php
+++ b/app/Rules/BelongsUser.php
@@ -138,10 +138,10 @@ class BelongsUser implements Rule
private function parseAttribute(string $attribute): string
{
$parts = explode('.', $attribute);
- if (1 === \count($parts)) {
+ if (1 === count($parts)) {
return $attribute;
}
- if (3 === \count($parts)) {
+ if (3 === count($parts)) {
return $parts[2];
}
diff --git a/app/Rules/ValidRecurrenceRepetitionValue.php b/app/Rules/ValidRecurrenceRepetitionValue.php
index da24867046..59db275abc 100644
--- a/app/Rules/ValidRecurrenceRepetitionValue.php
+++ b/app/Rules/ValidRecurrenceRepetitionValue.php
@@ -108,7 +108,7 @@ class ValidRecurrenceRepetitionValue implements Rule
private function validateNdom(string $value): bool
{
$parameters = explode(',', substr($value, 5));
- if (2 !== \count($parameters)) {
+ if (2 !== count($parameters)) {
return false;
}
$nthDay = (int)($parameters[0] ?? 0.0);
diff --git a/app/Services/Github/Request/UpdateRequest.php b/app/Services/Github/Request/UpdateRequest.php
index d49a982874..5a390475e8 100644
--- a/app/Services/Github/Request/UpdateRequest.php
+++ b/app/Services/Github/Request/UpdateRequest.php
@@ -67,7 +67,7 @@ class UpdateRequest implements GithubRequest
//fetch the products for each category
if (isset($releaseXml->entry)) {
- Log::debug(sprintf('Count of entries is: %d', \count($releaseXml->entry)));
+ Log::debug(sprintf('Count of entries is: %d', count($releaseXml->entry)));
foreach ($releaseXml->entry as $entry) {
$array = [
'id' => (string)$entry->id,
diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php
index 741f68a22c..4358ba8aca 100644
--- a/app/Services/Internal/Support/RecurringTransactionTrait.php
+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php
@@ -233,7 +233,7 @@ trait RecurringTransactionTrait
*/
protected function updateTags(Recurrence $recurrence, array $tags): void
{
- if (\count($tags) > 0) {
+ if (count($tags) > 0) {
/** @var RecurrenceMeta $entry */
$entry = $recurrence->recurrenceMeta()->where('name', 'tags')->first();
if (null === $entry) {
@@ -242,7 +242,7 @@ trait RecurringTransactionTrait
$entry->value = implode(',', $tags);
$entry->save();
}
- if (0 === \count($tags)) {
+ if (0 === count($tags)) {
// delete if present
$recurrence->recurrenceMeta()->where('name', 'tags')->delete();
}
diff --git a/app/Services/Spectre/Request/ListAccountsRequest.php b/app/Services/Spectre/Request/ListAccountsRequest.php
index a641819202..6147f1fc3f 100644
--- a/app/Services/Spectre/Request/ListAccountsRequest.php
+++ b/app/Services/Spectre/Request/ListAccountsRequest.php
@@ -53,7 +53,7 @@ class ListAccountsRequest extends SpectreRequest
$response = $this->sendSignedSpectreGet($uri, []);
// count entries:
- Log::debug(sprintf('Found %d entries in data-array', \count($response['data'])));
+ Log::debug(sprintf('Found %d entries in data-array', count($response['data'])));
// extract next ID
$hasNextPage = false;
diff --git a/app/Services/Spectre/Request/ListCustomersRequest.php b/app/Services/Spectre/Request/ListCustomersRequest.php
index 5b92b00ec2..fe7bbc7cf9 100644
--- a/app/Services/Spectre/Request/ListCustomersRequest.php
+++ b/app/Services/Spectre/Request/ListCustomersRequest.php
@@ -51,7 +51,7 @@ class ListCustomersRequest extends SpectreRequest
$response = $this->sendSignedSpectreGet($uri, []);
// count entries:
- Log::debug(sprintf('Found %d entries in data-array', \count($response['data'])));
+ Log::debug(sprintf('Found %d entries in data-array', count($response['data'])));
// extract next ID
$hasNextPage = false;
diff --git a/app/Services/Spectre/Request/ListLoginsRequest.php b/app/Services/Spectre/Request/ListLoginsRequest.php
index f5cda26a3b..4eafc807f2 100644
--- a/app/Services/Spectre/Request/ListLoginsRequest.php
+++ b/app/Services/Spectre/Request/ListLoginsRequest.php
@@ -55,7 +55,7 @@ class ListLoginsRequest extends SpectreRequest
$response = $this->sendSignedSpectreGet($uri, []);
// count entries:
- Log::debug(sprintf('Found %d entries in data-array', \count($response['data'])));
+ Log::debug(sprintf('Found %d entries in data-array', count($response['data'])));
// extract next ID
$hasNextPage = false;
diff --git a/app/Services/Spectre/Request/ListTransactionsRequest.php b/app/Services/Spectre/Request/ListTransactionsRequest.php
index 642562a067..df97789516 100644
--- a/app/Services/Spectre/Request/ListTransactionsRequest.php
+++ b/app/Services/Spectre/Request/ListTransactionsRequest.php
@@ -53,7 +53,7 @@ class ListTransactionsRequest extends SpectreRequest
$response = $this->sendSignedSpectreGet($uri, []);
// count entries:
- Log::debug(sprintf('Found %d entries in data-array', \count($response['data'])));
+ Log::debug(sprintf('Found %d entries in data-array', count($response['data'])));
// extract next ID
$hasNextPage = false;
diff --git a/app/Services/Ynab/Request/YnabRequest.php b/app/Services/Ynab/Request/YnabRequest.php
index 26eb6a3800..e2cd4ab26a 100644
--- a/app/Services/Ynab/Request/YnabRequest.php
+++ b/app/Services/Ynab/Request/YnabRequest.php
@@ -60,7 +60,7 @@ abstract class YnabRequest
'Authorization' => 'Bearer ' . $this->token,
],
];
- if (\count($params) > 0) {
+ if (count($params) > 0) {
$uri = $uri . '?' . http_build_query($params);
}
Log::debug(sprintf('Going to call YNAB on URI: %s', $uri), $options);
diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php
index 93921d7c53..b0ecc1431d 100644
--- a/app/Support/Binder/BudgetList.php
+++ b/app/Support/Binder/BudgetList.php
@@ -44,7 +44,7 @@ class BudgetList implements BinderInterface
{
if (auth()->check()) {
$list = array_unique(array_map('\intval', explode(',', $value)));
- if (0 === \count($list)) {
+ if (0 === count($list)) {
throw new NotFoundHttpException; // @codeCoverageIgnore
}
diff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.php
index 37e392b9ab..5d2ffedba6 100644
--- a/app/Support/Binder/CategoryList.php
+++ b/app/Support/Binder/CategoryList.php
@@ -44,7 +44,7 @@ class CategoryList implements BinderInterface
{
if (auth()->check()) {
$list = array_unique(array_map('\intval', explode(',', $value)));
- if (0 === \count($list)) {
+ if (0 === count($list)) {
throw new NotFoundHttpException; // @codeCoverageIgnore
}
diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php
index 7562d9346c..9c5b67af3f 100644
--- a/app/Support/Binder/JournalList.php
+++ b/app/Support/Binder/JournalList.php
@@ -42,7 +42,7 @@ class JournalList implements BinderInterface
{
if (auth()->check()) {
$list = array_unique(array_map('\intval', explode(',', $value)));
- if (0 === \count($list)) {
+ if (0 === count($list)) {
throw new NotFoundHttpException; // @codeCoverageIgnore
}
diff --git a/app/Support/Binder/SimpleJournalList.php b/app/Support/Binder/SimpleJournalList.php
index 35708338ed..d5a9ddc12e 100644
--- a/app/Support/Binder/SimpleJournalList.php
+++ b/app/Support/Binder/SimpleJournalList.php
@@ -49,7 +49,7 @@ class SimpleJournalList implements BinderInterface
{
if (auth()->check()) {
$list = array_unique(array_map('\intval', explode(',', $value)));
- if (0 === \count($list)) {
+ if (0 === count($list)) {
throw new NotFoundHttpException; // @codeCoverageIgnore
}
@@ -95,7 +95,7 @@ class SimpleJournalList implements BinderInterface
}
if ($final->count() > 0) {
- if (\count($messages) > 0) {
+ if (count($messages) > 0) {
session()->flash('info', $messages);
}
diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php
index b6162cf766..14af5fd647 100644
--- a/app/Support/Binder/TagList.php
+++ b/app/Support/Binder/TagList.php
@@ -46,7 +46,7 @@ class TagList implements BinderInterface
if (auth()->check()) {
$list = array_unique(array_map('\strtolower', explode(',', $value)));
Log::debug('List of tags is', $list);
- if (0 === \count($list)) {
+ if (0 === count($list)) {
Log::error('Tag list is empty.');
throw new NotFoundHttpException; // @codeCoverageIgnore
}
diff --git a/app/Support/ChartColour.php b/app/Support/ChartColour.php
index f64ea93eb5..5f0ab48904 100644
--- a/app/Support/ChartColour.php
+++ b/app/Support/ChartColour.php
@@ -58,7 +58,7 @@ class ChartColour
*/
public static function getColour(int $index): string
{
- $index %= \count(self::$colours);
+ $index %= count(self::$colours);
$row = self::$colours[$index];
return sprintf('rgba(%d, %d, %d, 0.7)', $row[0], $row[1], $row[2]);
diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php
index 788c6c2e17..80009e8376 100644
--- a/app/Support/Http/Controllers/AugumentData.php
+++ b/app/Support/Http/Controllers/AugumentData.php
@@ -24,12 +24,12 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers;
use Carbon\Carbon;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
-use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -513,7 +513,7 @@ trait AugumentData
// group by category ID:
$grouped = [];
/** @var array $journal */
- foreach($array as $journal) {
+ foreach ($array as $journal) {
$categoryId = (int)$journal['category_id'];
$grouped[$categoryId] = $grouped[$categoryId] ?? '0';
$grouped[$categoryId] = bcadd($journal['amount'], $grouped[$categoryId]);
@@ -544,29 +544,27 @@ trait AugumentData
}
-
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* Group transactions by tag.
*
- * @param Collection $set
+ * @param array $array
*
* @return array
*/
- protected function groupByTag(Collection $set): array // filter + group data
+ protected function groupByTag(array $array): array // filter + group data
{
// group by category ID:
$grouped = [];
- /** @var Transaction $transaction */
- foreach ($set as $transaction) {
- $journal = $transaction->transactionJournal;
- $journalTags = $journal->tags;
- /** @var Tag $journalTag */
- foreach ($journalTags as $journalTag) {
- $journalTagId = $journalTag->id;
- $grouped[$journalTagId] = $grouped[$journalTagId] ?? '0';
- $grouped[$journalTagId] = bcadd($transaction->transaction_amount, $grouped[$journalTagId]);
+ /** @var array $journal */
+ foreach ($array as $journal) {
+ $tags = $journal['tags'] ?? [];
+ /**
+ * @var int $id
+ * @var array $tag
+ */
+ foreach ($tags as $id => $tag) {
+ $grouped[$id] = $grouped[$id] ?? '0';
+ $grouped[$id] = bcadd($journal['amount'], $grouped[$id]);
}
}
@@ -765,17 +763,10 @@ trait AugumentData
protected function spentInPeriodWithout(Carbon $start, Carbon $end): string // get data + augment with info
{
// collector
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
$types = [TransactionType::WITHDRAWAL];
- $collector->setAllAssetAccounts()->setTypes($types)->setRange($start, $end)->withoutBudget();
- $transactions = $collector->getTransactions();
- $sum = '0';
- /** @var Transaction $entry */
- foreach ($transactions as $entry) {
- $sum = bcadd($entry->transaction_amount, $sum);
- }
-
- return $sum;
+ $collector->setTypes($types)->setRange($start, $end)->withoutBudget();
+ return $collector->getSum();
}
}
diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php
index 4d1de2ed58..9f26ca06bd 100644
--- a/app/Support/Http/Controllers/GetConfigurationData.php
+++ b/app/Support/Http/Controllers/GetConfigurationData.php
@@ -68,7 +68,7 @@ trait GetConfigurationData
$routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey));
$steps = [];
- if (\is_array($elements) && \count($elements) > 0) {
+ if (\is_array($elements) && count($elements) > 0) {
foreach ($elements as $key => $options) {
$currentStep = $options;
@@ -79,7 +79,7 @@ trait GetConfigurationData
$steps[] = $currentStep;
}
}
- Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, \count($steps)));
+ Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps)));
return $steps;
}
@@ -188,7 +188,7 @@ trait GetConfigurationData
if ('' !== $specificPage) {
$routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
- if (\is_array($elements) && \count($elements) > 0) {
+ if (\is_array($elements) && count($elements) > 0) {
foreach ($elements as $key => $options) {
$currentStep = $options;
@@ -200,7 +200,7 @@ trait GetConfigurationData
}
}
}
- Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, \count($steps)));
+ Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps)));
return $steps;
}
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index 53c11ab1e0..5b0f6fe5da 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -132,6 +132,7 @@ trait PeriodOverview
]
);
}
+
//$cache->store($entries);
return $entries;
@@ -175,7 +176,6 @@ trait PeriodOverview
*/
protected function getCategoryPeriodOverview(Category $category, Carbon $date): Collection
{
- throw new FireflyException('Is using collector.');
/** @var JournalRepositoryInterface $journalRepository */
$journalRepository = app(JournalRepositoryInterface::class);
$range = app('preferences')->get('viewRange', '1M')->data;
@@ -211,12 +211,12 @@ trait PeriodOverview
$earned = $this->groupByCurrency($earned);
// amount transferred
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($currentDate['start'], $currentDate['end'])->setCategory($category)
- ->withOpposingAccount()->setTypes([TransactionType::TRANSFER]);
- $collector->removeFilter(InternalTransferFilter::class);
- $transferred = $this->groupByCurrency($collector->getTransactions());
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+
+ $collector->setRange($currentDate['start'], $currentDate['end'])->setCategory($category)
+ ->setTypes([TransactionType::TRANSFER]);
+ $transferred = $this->groupByCurrency($collector->getExtractedJournals());
$title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
$entries->push(
@@ -246,7 +246,6 @@ trait PeriodOverview
*/
protected function getNoBudgetPeriodOverview(Carbon $date): Collection
{
- throw new FireflyException('Is using collector.');
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$first = $repository->firstNull();
@@ -271,15 +270,15 @@ trait PeriodOverview
$dates = app('navigation')->blockPeriods($start, $end, $range);
$entries = new Collection;
foreach ($dates as $currentDate) {
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($currentDate['start'], $currentDate['end'])->withoutBudget()->withOpposingAccount()->setTypes(
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($currentDate['start'], $currentDate['end'])->withoutBudget()->withAccountInformation()->setTypes(
[TransactionType::WITHDRAWAL]
);
- $set = $collector->getTransactions();
- $count = $set->count();
- $spent = $this->groupByCurrency($set);
- $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
+ $journals = $collector->getExtractedJournals();
+ $count = count($journals);
+ $spent = $this->groupByCurrency($journals);
+ $title = app('navigation')->periodShow($currentDate['end'], $currentDate['period']);
$entries->push(
[
'transactions' => $count,
@@ -308,7 +307,6 @@ trait PeriodOverview
*/
protected function getNoCategoryPeriodOverview(Carbon $theDate): Collection // period overview method.
{
- throw new FireflyException('Is using collector.');
Log::debug(sprintf('Now in getNoCategoryPeriodOverview(%s)', $theDate->format('Y-m-d')));
$range = app('preferences')->get('viewRange', '1M')->data;
$first = $this->journalRepos->firstNull();
@@ -334,36 +332,34 @@ trait PeriodOverview
foreach ($dates as $date) {
// count journals without category in this period:
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($date['start'], $date['end'])->withoutCategory()
- ->withOpposingAccount()->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
- $collector->removeFilter(InternalTransferFilter::class);
- $count = $collector->getTransactions()->count();
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($date['start'], $date['end'])->withoutCategory()
+ ->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
+ $count = count($collector->getExtractedJournals());
// amount transferred
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($date['start'], $date['end'])->withoutCategory()
- ->withOpposingAccount()->setTypes([TransactionType::TRANSFER]);
- $collector->removeFilter(InternalTransferFilter::class);
- $transferred = app('steam')->positive((string)$collector->getTransactions()->sum('transaction_amount'));
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($date['start'], $date['end'])->withoutCategory()
+ ->setTypes([TransactionType::TRANSFER]);
+ $transferred = app('steam')->positive((string)$collector->getSum());
// amount spent
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($date['start'], $date['end'])->withoutCategory()->withOpposingAccount()->setTypes(
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($date['start'], $date['end'])->withoutCategory()->setTypes(
[TransactionType::WITHDRAWAL]
);
- $spent = $collector->getTransactions()->sum('transaction_amount');
+ $spent = $collector->getSum();
// amount earned
- /** @var TransactionCollectorInterface $collector */
- $collector = app(TransactionCollectorInterface::class);
- $collector->setAllAssetAccounts()->setRange($date['start'], $date['end'])->withoutCategory()->withOpposingAccount()->setTypes(
+ /** @var GroupCollectorInterface $collector */
+ $collector = app(GroupCollectorInterface::class);
+ $collector->setRange($date['start'], $date['end'])->withoutCategory()->setTypes(
[TransactionType::DEPOSIT]
);
- $earned = $collector->getTransactions()->sum('transaction_amount');
+ $earned = $collector->getSum();
/** @noinspection PhpUndefinedMethodInspection */
$dateStr = $date['end']->format('Y-m-d');
$dateName = app('navigation')->periodShow($date['end'], $date['period']);
@@ -397,7 +393,6 @@ trait PeriodOverview
*/
protected function getTagPeriodOverview(Tag $tag, Carbon $date): Collection // period overview for tags.
{
- throw new FireflyException('Is using collector.');
/** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class);
$range = app('preferences')->get('viewRange', '1M')->data;
@@ -437,7 +432,7 @@ trait PeriodOverview
$entries->push(
[
- 'transactions' => $spentSet->count() + $earnedSet->count() + $transferredSet->count(),
+ 'transactions' => count($spentSet) + count($earnedSet) + count($transferredSet),
'title' => $title,
'spent' => $spent,
'earned' => $earned,
@@ -457,7 +452,6 @@ trait PeriodOverview
* @param Carbon $endDate
*
* @return Collection
- * @throws \Exception
*/
protected function getTransactionPeriodOverview(string $transactionType, Carbon $endDate): Collection
{
diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php
index e4bec9f9aa..44665043db 100644
--- a/app/Support/Http/Controllers/RenderPartialViews.php
+++ b/app/Support/Http/Controllers/RenderPartialViews.php
@@ -350,7 +350,6 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
-
$account = $accountRepository->findNull((int)$attributes['accountId']);
if (null === $account) {
diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php
index 65268bccf6..76f6c864cd 100644
--- a/app/Support/Http/Controllers/RequestInformation.php
+++ b/app/Support/Http/Controllers/RequestInformation.php
@@ -139,7 +139,7 @@ trait RequestInformation
$res = $transformer->transform($transaction);
}
- if (\count($res) > 0) {
+ if (count($res) > 0) {
$res['amount'] = app('steam')->positive((string)$res['amount']);
$res['foreign_amount'] = app('steam')->positive((string)$res['foreign_amount']);
$transactions[] = $res;
@@ -162,7 +162,7 @@ trait RequestInformation
*/
protected function updateWithPrevious($array, $old): array // update object with new info
{
- if (0 === \count($old) || !isset($old['transactions'])) {
+ if (0 === count($old) || !isset($old['transactions'])) {
return $array;
}
$old = $old['transactions'];
@@ -318,7 +318,7 @@ trait RequestInformation
$shownDemo = true;
// both must be array and either must be > 0
- if (count($intro) > 0 || \count($specialIntro) > 0) {
+ if (count($intro) > 0 || count($specialIntro) > 0) {
$shownDemo = app('preferences')->get($key, false)->data;
Log::debug(sprintf('Check if user has already seen intro with key "%s". Result is %d', $key, $shownDemo));
}
diff --git a/app/Support/Import/Information/GetSpectreCustomerTrait.php b/app/Support/Import/Information/GetSpectreCustomerTrait.php
index e638d7ce53..2da8a1227e 100644
--- a/app/Support/Import/Information/GetSpectreCustomerTrait.php
+++ b/app/Support/Import/Information/GetSpectreCustomerTrait.php
@@ -88,7 +88,7 @@ trait GetSpectreCustomerTrait
$request->call();
$customers = $request->getCustomers();
- Log::debug(sprintf('Found %d customer(s)', \count($customers)));
+ Log::debug(sprintf('Found %d customer(s)', count($customers)));
/** @var Customer $current */
foreach ($customers as $current) {
if ('default_ff3_customer' === $current->getIdentifier()) {
diff --git a/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php
index fe81936b11..b792f7b145 100644
--- a/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php
+++ b/app/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandler.php
@@ -58,7 +58,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
{
$config = $this->repository->getConfiguration($this->importJob);
$mapping = $config['mapping'] ?? [];
- $complete = \count($mapping) > 0;
+ $complete = count($mapping) > 0;
if (true === $complete) {
// move job to correct stage to download transactions
$this->repository->setStage($this->importJob, 'go-for-import');
@@ -94,10 +94,10 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
*/
$ibanToAsset = [];
Log::debug('Going to map IBANs for easy mapping later on.');
- if (0 === \count($accounts)) {
+ if (0 === count($accounts)) {
throw new FireflyException('No bunq accounts found. Import cannot continue.'); // @codeCoverageIgnore
}
- if (0 === \count($mapping)) {
+ if (0 === count($mapping)) {
$messages = new MessageBag;
$messages->add('nomap', (string)trans('import.bunq_no_mapping'));
@@ -144,7 +144,7 @@ class ChooseAccountsHandler implements BunqJobConfigurationInterface
{
$config = $this->repository->getConfiguration($this->importJob);
$accounts = $config['accounts'] ?? [];
- if (0 === \count($accounts)) {
+ if (0 === count($accounts)) {
throw new FireflyException('No bunq accounts found. Import cannot continue.'); // @codeCoverageIgnore
}
// list the users accounts:
diff --git a/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php
index e8803b31b0..f8defe6ef9 100644
--- a/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php
+++ b/app/Support/Import/JobConfiguration/File/ConfigureMappingHandler.php
@@ -311,7 +311,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
$columnConfig[$columnIndex]['values'] = array_unique($columnConfig[$columnIndex]['values']);
asort($columnConfig[$columnIndex]['values']);
// if the count of this array is zero, there is nothing to map.
- if (0 === \count($columnConfig[$columnIndex]['values'])) {
+ if (0 === count($columnConfig[$columnIndex]['values'])) {
unset($columnConfig[$columnIndex]);
}
}
diff --git a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php
index c7e0fa14e0..ce8b8ffcbb 100644
--- a/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php
+++ b/app/Support/Import/JobConfiguration/File/ConfigureRolesHandler.php
@@ -194,7 +194,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
foreach ($records as $line) {
$line = array_values($line);
$line = $this->processSpecifics($config, $line);
- $count = \count($line);
+ $count = count($line);
$this->totalColumns = $count > $this->totalColumns ? $count : $this->totalColumns;
$this->getExampleFromLine($line);
}
diff --git a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php
index a781e1fb4d..268c789c36 100644
--- a/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php
+++ b/app/Support/Import/JobConfiguration/Spectre/ChooseAccountsHandler.php
@@ -63,7 +63,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
Log::debug('Now in ChooseAccountsHandler::configurationComplete()');
$config = $this->importJob->configuration;
$importAccounts = $config['account_mapping'] ?? [];
- $complete = \count($importAccounts) > 0 && $importAccounts !== [0 => 0];
+ $complete = count($importAccounts) > 0 && $importAccounts !== [0 => 0];
if ($complete) {
Log::debug('Looks like user has mapped import accounts to Firefly III accounts', $importAccounts);
$this->repository->setStage($this->importJob, 'go-for-import');
@@ -98,7 +98,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
$config['account_mapping'] = $final;
$config['apply-rules'] = $applyRules;
$this->repository->setConfiguration($this->importJob, $config);
- if ($final === [0 => 0] || 0 === \count($final)) {
+ if ($final === [0 => 0] || 0 === count($final)) {
$messages->add('count', (string)trans('import.spectre_no_mapping'));
}
@@ -117,7 +117,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
Log::debug('Now in ChooseAccountsHandler::getnextData()');
$config = $this->importJob->configuration;
$accounts = $config['accounts'] ?? [];
- if (0 === \count($accounts)) {
+ if (0 === count($accounts)) {
throw new FireflyException('It seems you have no accounts with this bank. The import cannot continue.'); // @codeCoverageIgnore
}
$converted = [];
@@ -129,7 +129,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
$login = null;
$logins = $config['all-logins'] ?? [];
$selected = $config['selected-login'] ?? 0;
- if (0 === \count($logins)) {
+ if (0 === count($logins)) {
throw new FireflyException('It seems you have no configured logins in this import job. The import cannot continue.'); // @codeCoverageIgnore
}
Log::debug(sprintf('Selected login to use is %d', $selected));
diff --git a/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php b/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php
index 39b6e5b565..e0ed2b6bf0 100644
--- a/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php
+++ b/app/Support/Import/JobConfiguration/Spectre/ChooseLoginHandler.php
@@ -112,7 +112,7 @@ class ChooseLoginHandler implements SpectreJobConfigurationInterface
$config = $this->importJob->configuration;
$data = ['logins' => []];
$logins = $config['all-logins'] ?? [];
- Log::debug(sprintf('Count of logins in configuration is %d.', \count($logins)));
+ Log::debug(sprintf('Count of logins in configuration is %d.', count($logins)));
foreach ($logins as $login) {
$data['logins'][] = new Login($login);
}
diff --git a/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php b/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php
index 87dc940a14..1602a4de96 100644
--- a/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php
+++ b/app/Support/Import/JobConfiguration/Ynab/SelectAccountsHandler.php
@@ -59,7 +59,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
Log::debug('Now in SelectAccountsHandler::configurationComplete()');
$config = $this->importJob->configuration;
$mapping = $config['mapping'] ?? [];
- if (\count($mapping) > 0) {
+ if (count($mapping) > 0) {
// mapping is complete.
Log::debug('Looks like user has mapped YNAB accounts to Firefly III accounts', $mapping);
$this->repository->setStage($this->importJob, 'go-for-import');
@@ -97,7 +97,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
$config['mapping'] = $final;
$config['apply-rules'] = $applyRules;
$this->repository->setConfiguration($this->importJob, $config);
- if ($final === ['' => 0] || 0 === \count($final)) {
+ if ($final === ['' => 0] || 0 === count($final)) {
$messages->add('count', (string)trans('import.ynab_no_mapping'));
}
@@ -117,7 +117,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
$config = $this->importJob->configuration;
$ynabAccounts = $config['accounts'] ?? [];
$budget = $this->getSelectedBudget();
- if (0 === \count($ynabAccounts)) {
+ if (0 === count($ynabAccounts)) {
throw new FireflyException('It seems you have no accounts with this budget. The import cannot continue.'); // @codeCoverageIgnore
}
// list the users accounts:
diff --git a/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php b/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php
index 4a3ebadba7..e04ea1b84c 100644
--- a/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php
+++ b/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php
@@ -104,7 +104,7 @@ class SelectBudgetHandler implements YnabJobConfigurationInterface
$budgets = $configuration['budgets'] ?? [];
$available = [];
$notAvailable = [];
- $total = \count($budgets);
+ $total = count($budgets);
foreach ($budgets as $budget) {
if ($this->haveAssetWithCurrency($budget['currency_code'])) {
Log::debug('Add budget to available list.');
diff --git a/app/Support/Import/Routine/Bunq/StageImportDataHandler.php b/app/Support/Import/Routine/Bunq/StageImportDataHandler.php
index 76ba7d42ab..5581066fd6 100644
--- a/app/Support/Import/Routine/Bunq/StageImportDataHandler.php
+++ b/app/Support/Import/Routine/Bunq/StageImportDataHandler.php
@@ -325,7 +325,7 @@ class StageImportDataHandler
/*
* After the loop, check if Firefly III must loop again.
*/
- Log::debug(sprintf('Count of result is now %d', \count($return)));
+ Log::debug(sprintf('Count of result is now %d', count($return)));
$count++;
if (null === $olderId) {
Log::debug('Older ID is NULL, so stop looping cause we are done!');
@@ -351,7 +351,7 @@ class StageImportDataHandler
// store newest and oldest tranasction ID to be used later:
\Preferences::setForUser($this->importJob->user, sprintf('bunq-oldest-transaction-%d', $bunqAccountId), $oldestTransaction);
\Preferences::setForUser($this->importJob->user, sprintf('bunq-newest-transaction-%d', $bunqAccountId), $newestTransaction);
- Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', \count($return)));
+ Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', count($return)));
return $return;
}
@@ -428,7 +428,7 @@ class StageImportDataHandler
/*
* After the loop, check if Firefly III must loop again.
*/
- Log::debug(sprintf('Count of result is now %d', \count($return)));
+ Log::debug(sprintf('Count of result is now %d', count($return)));
$count++;
if (null === $newerId) {
Log::debug('Newer ID is NULL, so stop looping cause we are done!');
@@ -446,7 +446,7 @@ class StageImportDataHandler
// store newest tranasction ID to be used later:
\Preferences::setForUser($this->importJob->user, sprintf('bunq-newest-transaction-%d', $bunqAccountId), $newestTransaction);
- Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', \count($return)));
+ Log::info(sprintf('Downloaded and parsed %d transactions from bunq.', count($return)));
return $return;
}
diff --git a/app/Support/Import/Routine/Bunq/StageNewHandler.php b/app/Support/Import/Routine/Bunq/StageNewHandler.php
index 30933bea73..0b7b3dd8a9 100644
--- a/app/Support/Import/Routine/Bunq/StageNewHandler.php
+++ b/app/Support/Import/Routine/Bunq/StageNewHandler.php
@@ -145,7 +145,7 @@ class StageNewHandler
}
}
}
- Log::info(sprintf('Found %d account(s) at bunq', \count($accounts)), $accounts);
+ Log::info(sprintf('Found %d account(s) at bunq', count($accounts)), $accounts);
return $accounts;
}
@@ -224,7 +224,7 @@ class StageNewHandler
Log::debug('Setting is not null.');
}
if (null !== $maj->getAlias()) {
- Log::debug(sprintf('Alias is not NULL. Count is %d', \count($maj->getAlias())));
+ Log::debug(sprintf('Alias is not NULL. Count is %d', count($maj->getAlias())));
/** @var Pointer $alias */
foreach ($maj->getAlias() as $alias) {
$return['aliases'][] = [
@@ -239,7 +239,7 @@ class StageNewHandler
}
}
$coOwners = $maj->getAllCoOwner() ?? [];
- Log::debug(sprintf('Count of getAllCoOwner is %d', \count($coOwners)));
+ Log::debug(sprintf('Count of getAllCoOwner is %d', count($coOwners)));
/** @var CoOwner $coOwner */
foreach ($coOwners as $coOwner) {
$alias = $coOwner->getAlias();
diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.php
index afcdd29c2d..8059345d34 100644
--- a/app/Support/Import/Routine/File/ImportableConverter.php
+++ b/app/Support/Import/Routine/File/ImportableConverter.php
@@ -69,7 +69,7 @@ class ImportableConverter
*/
public function convert(array $importables): array
{
- $total = \count($importables);
+ $total = count($importables);
Log::debug(sprintf('Going to convert %d import transactions', $total));
$result = [];
/** @var ImportTransaction $importable */
diff --git a/app/Support/Import/Routine/File/MappedValuesValidator.php b/app/Support/Import/Routine/File/MappedValuesValidator.php
index af3d35249d..c0bc90c704 100644
--- a/app/Support/Import/Routine/File/MappedValuesValidator.php
+++ b/app/Support/Import/Routine/File/MappedValuesValidator.php
@@ -90,7 +90,7 @@ class MappedValuesValidator
foreach ($mappings as $role => $values) {
Log::debug(sprintf('Now at role "%s"', $role));
$values = array_unique($values);
- if (\count($values) > 0) {
+ if (count($values) > 0) {
switch ($role) {
default:
throw new FireflyException(sprintf('Cannot validate mapped values for role "%s"', $role)); // @codeCoverageIgnore
diff --git a/app/Support/Import/Routine/File/MappingConverger.php b/app/Support/Import/Routine/File/MappingConverger.php
index c16afd9e2d..41bb5eae54 100644
--- a/app/Support/Import/Routine/File/MappingConverger.php
+++ b/app/Support/Import/Routine/File/MappingConverger.php
@@ -69,7 +69,7 @@ class MappingConverger
{
Log::debug('Start converging process.');
$collection = [];
- $total = \count($lines);
+ $total = count($lines);
/** @var array $line */
foreach ($lines as $lineIndex => $line) {
Log::debug(sprintf('Now converging line %d out of %d.', $lineIndex + 1, $total));
diff --git a/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php b/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php
index c4b08e7af1..3e5af0dbee 100644
--- a/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php
+++ b/app/Support/Import/Routine/Spectre/StageAuthenticatedHandler.php
@@ -56,8 +56,8 @@ class StageAuthenticatedHandler
// grab a list of logins.
$config = $this->importJob->configuration;
$logins = $config['all-logins'] ?? [];
- Log::debug(sprintf('%d logins in config', \count($logins)));
- if (0 === \count($logins)) {
+ Log::debug(sprintf('%d logins in config', count($logins)));
+ if (0 === count($logins)) {
// get logins from Spectre.
$logins = $this->getLogins();
$config['all-logins'] = $logins;
@@ -115,7 +115,7 @@ class StageAuthenticatedHandler
$request->setLogin($login);
$request->call();
$accounts = $request->getAccounts();
- Log::debug(sprintf('Found %d accounts using login', \count($accounts)));
+ Log::debug(sprintf('Found %d accounts using login', count($accounts)));
return $accounts;
}
@@ -137,7 +137,7 @@ class StageAuthenticatedHandler
$logins = $request->getLogins();
$return = [];
- Log::debug(sprintf('Found %d logins in users Spectre account.', \count($logins)));
+ Log::debug(sprintf('Found %d logins in users Spectre account.', count($logins)));
/** @var Login $login */
foreach ($logins as $login) {
diff --git a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
index f92da203ed..129e54278a 100644
--- a/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
+++ b/app/Support/Import/Routine/Spectre/StageImportDataHandler.php
@@ -59,8 +59,8 @@ class StageImportDataHandler
Log::debug('Now in StageImportDataHandler::run()');
$config = $this->importJob->configuration;
$accounts = $config['accounts'] ?? [];
- Log::debug(sprintf('Count of accounts in array is %d', \count($accounts)));
- if (0 === \count($accounts)) {
+ Log::debug(sprintf('Count of accounts in array is %d', count($accounts)));
+ if (0 === count($accounts)) {
throw new FireflyException('There are no accounts in this import job. Cannot continue.'); // @codeCoverageIgnore
}
$toImport = $config['account_mapping'] ?? [];
@@ -73,14 +73,14 @@ class StageImportDataHandler
$merge = $this->getTransactions($spectreAccount, $localAccount);
$totalSet[] = $merge;
Log::debug(
- sprintf('Found %d transactions in account "%s" (%s)', \count($merge), $spectreAccount->getName(), $spectreAccount->getCurrencyCode())
+ sprintf('Found %d transactions in account "%s" (%s)', count($merge), $spectreAccount->getName(), $spectreAccount->getCurrencyCode())
);
continue;
}
Log::debug(sprintf('Local account is = zero, will not import from Spectr account with ID #%d', $spectreId));
}
$totalSet = array_merge(...$totalSet);
- Log::debug(sprintf('Found %d transactions in total.', \count($totalSet)));
+ Log::debug(sprintf('Found %d transactions in total.', count($totalSet)));
$this->repository->setTransactions($this->importJob, $totalSet);
}
@@ -112,8 +112,8 @@ class StageImportDataHandler
private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array
{
$array = [];
- $total = \count($transactions);
- Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', \count($transactions)));
+ $total = count($transactions);
+ Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', count($transactions)));
/** @var SpectreTransaction $transaction */
foreach ($transactions as $index => $transaction) {
Log::debug(sprintf('Now creating array for transaction %d of %d', $index + 1, $total));
@@ -216,7 +216,7 @@ class StageImportDataHandler
];
$array[] = $entry;
}
- Log::debug(sprintf('Return %d entries', \count($array)));
+ Log::debug(sprintf('Return %d entries', count($array)));
return $array;
}
diff --git a/app/Support/Import/Routine/Spectre/StageNewHandler.php b/app/Support/Import/Routine/Spectre/StageNewHandler.php
index 74a789dc0f..7cb0d4795f 100644
--- a/app/Support/Import/Routine/Spectre/StageNewHandler.php
+++ b/app/Support/Import/Routine/Spectre/StageNewHandler.php
@@ -80,7 +80,7 @@ class StageNewHandler
$list = $request->getLogins();
// count is zero?
- $this->countLogins = \count($list);
+ $this->countLogins = count($list);
Log::debug(sprintf('Number of logins is %d', $this->countLogins));
if ($this->countLogins > 0) {
$store = [];
diff --git a/app/Support/Import/Routine/Ynab/GetAccountsHandler.php b/app/Support/Import/Routine/Ynab/GetAccountsHandler.php
index 75632769d5..998f6354ce 100644
--- a/app/Support/Import/Routine/Ynab/GetAccountsHandler.php
+++ b/app/Support/Import/Routine/Ynab/GetAccountsHandler.php
@@ -63,7 +63,7 @@ class GetAccountsHandler
$request->call();
$config['accounts'] = $request->accounts;
$this->repository->setConfiguration($this->importJob, $config);
- if (0 === \count($config['accounts'])) {
+ if (0 === count($config['accounts'])) {
throw new FireflyException('This budget contains zero accounts.');
}
}
diff --git a/app/Support/Import/Routine/Ynab/ImportDataHandler.php b/app/Support/Import/Routine/Ynab/ImportDataHandler.php
index 1468b0e356..50fc1d5116 100644
--- a/app/Support/Import/Routine/Ynab/ImportDataHandler.php
+++ b/app/Support/Import/Routine/Ynab/ImportDataHandler.php
@@ -78,7 +78,7 @@ class ImportDataHandler
}
$totalSet = array_merge(...$total);
- Log::debug(sprintf('Found %d transactions in total.', \count($totalSet)));
+ Log::debug(sprintf('Found %d transactions in total.', count($totalSet)));
$this->repository->setTransactions($this->importJob, $totalSet);
// assuming this works, store today's date as a preference
@@ -114,9 +114,9 @@ class ImportDataHandler
{
$config = $this->repository->getConfiguration($this->importJob);
$array = [];
- $total = \count($transactions);
+ $total = count($transactions);
$budget = $this->getSelectedBudget();
- Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', \count($transactions)));
+ Log::debug(sprintf('Now in StageImportDataHandler::convertToArray() with count %d', count($transactions)));
/** @var array $transaction */
foreach ($transactions as $index => $transaction) {
$description = $transaction['memo'] ?? '(empty)';
diff --git a/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php b/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php
index bd0d6e2d6b..70142c5083 100644
--- a/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php
+++ b/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php
@@ -57,8 +57,8 @@ class StageGetBudgetsHandler
// store budgets in users preferences.
$configuration['budgets'] = $request->budgets;
$this->repository->setConfiguration($this->importJob, $configuration);
- Log::debug(sprintf('Found %d budgets', \count($request->budgets)));
- if (0 === \count($request->budgets)) {
+ Log::debug(sprintf('Found %d budgets', count($request->budgets)));
+ if (0 === count($request->budgets)) {
throw new FireflyException('It seems this user has zero budgets or an error prevented Firefly III from reading them.');
}
}
diff --git a/app/Support/Repositories/Recurring/FiltersWeekends.php b/app/Support/Repositories/Recurring/FiltersWeekends.php
index b46daf1105..3c91f1947f 100644
--- a/app/Support/Repositories/Recurring/FiltersWeekends.php
+++ b/app/Support/Repositories/Recurring/FiltersWeekends.php
@@ -87,12 +87,12 @@ trait FiltersWeekends
}
// filter unique dates
- Log::debug(sprintf('Count before filtering: %d', \count($dates)));
+ Log::debug(sprintf('Count before filtering: %d', count($dates)));
$collection = new Collection($return);
$filtered = $collection->unique();
$return = $filtered->toArray();
- Log::debug(sprintf('Count after filtering: %d', \count($return)));
+ Log::debug(sprintf('Count after filtering: %d', count($return)));
return $return;
}
diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php
index b0c8ed1909..ea3c06d324 100644
--- a/app/Support/Search/Search.php
+++ b/app/Support/Search/Search.php
@@ -290,7 +290,7 @@ class Search implements SearchInterface
private function extractModifier(string $string): void
{
$parts = explode(':', $string);
- if (2 === \count($parts) && '' !== trim((string)$parts[1]) && '' !== trim((string)$parts[0])) {
+ if (2 === count($parts) && '' !== trim((string)$parts[1]) && '' !== trim((string)$parts[0])) {
$type = trim((string)$parts[0]);
$value = trim((string)$parts[1]);
if (\in_array($type, $this->validModifiers, true)) {
diff --git a/app/TransactionRules/Factory/ActionFactory.php b/app/TransactionRules/Factory/ActionFactory.php
index 7d3cf1001e..f9864c0e5d 100644
--- a/app/TransactionRules/Factory/ActionFactory.php
+++ b/app/TransactionRules/Factory/ActionFactory.php
@@ -92,7 +92,7 @@ class ActionFactory
*/
protected static function getActionTypes(): array
{
- if (0 === \count(self::$actionTypes)) {
+ if (0 === count(self::$actionTypes)) {
self::$actionTypes = Domain::getRuleActions();
}
diff --git a/app/TransactionRules/Factory/TriggerFactory.php b/app/TransactionRules/Factory/TriggerFactory.php
index 3bced52e35..cb6c7b0887 100644
--- a/app/TransactionRules/Factory/TriggerFactory.php
+++ b/app/TransactionRules/Factory/TriggerFactory.php
@@ -101,7 +101,7 @@ class TriggerFactory
*/
protected static function getTriggerTypes(): array
{
- if (0 === \count(self::$triggerTypes)) {
+ if (0 === count(self::$triggerTypes)) {
self::$triggerTypes = Domain::getRuleTriggers();
}
diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.php
index b4b568879b..b589214b0f 100644
--- a/app/TransactionRules/TransactionMatcher.php
+++ b/app/TransactionRules/TransactionMatcher.php
@@ -84,7 +84,7 @@ class TransactionMatcher
public function findTransactionsByRule(): Collection
{
Log::debug('Now in findTransactionsByRule()');
- if (0 === \count($this->rule->ruleTriggers)) {
+ if (0 === count($this->rule->ruleTriggers)) {
Log::error('Rule has no triggers!');
return new Collection;
@@ -113,7 +113,7 @@ class TransactionMatcher
*/
public function findTransactionsByTriggers(): Collection
{
- if (0 === \count($this->triggers)) {
+ if (0 === count($this->triggers)) {
return new Collection;
}
@@ -328,7 +328,7 @@ class TransactionMatcher
// Update counters
++$page;
- $processed += \count($set);
+ $processed += count($set);
Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed));
diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php
index 91e4cc47de..88ae0c3e7c 100644
--- a/app/Validation/RecurrenceValidation.php
+++ b/app/Validation/RecurrenceValidation.php
@@ -47,7 +47,7 @@ trait RecurrenceValidation
$data = $validator->getData();
$repetitions = $data['repetitions'] ?? [];
// need at least one transaction
- if (0 === \count($repetitions)) {
+ if (0 === count($repetitions)) {
$validator->errors()->add('description', (string)trans('validation.at_least_one_repetition'));
}
}
@@ -145,7 +145,7 @@ trait RecurrenceValidation
protected function validateNdom(Validator $validator, int $index, string $moment): void
{
$parameters = explode(',', $moment);
- if (2 !== \count($parameters)) {
+ if (2 !== count($parameters)) {
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
return;
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index ec6dc1e137..c973571cff 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -135,7 +135,7 @@ trait TransactionValidation
$data = $validator->getData();
$transactions = $data['transactions'] ?? [];
$groupTitle = $data['group_title'] ?? '';
- if ('' === $groupTitle && \count($transactions) > 1) {
+ if ('' === $groupTitle && count($transactions) > 1) {
$validator->errors()->add('group_title', (string)trans('validation.group_title_mandatory'));
}
}
@@ -150,7 +150,7 @@ trait TransactionValidation
$data = $validator->getData();
$transactions = $data['transactions'] ?? [];
// need at least one transaction
- if (0 === \count($transactions)) {
+ if (0 === count($transactions)) {
$validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));
}
}
diff --git a/public/v1/css/firefly.css b/public/v1/css/firefly.css
index 560f8d8e58..03eb004b8a 100644
--- a/public/v1/css/firefly.css
+++ b/public/v1/css/firefly.css
@@ -76,7 +76,7 @@ input.ti-new-tag-input {
.general-chart-error {
height: 30px;
- background: url('/images/error.png') no-repeat center center;
+ background: url('/v1/images/error.png') no-repeat center center;
}
p.tagcloud .label {
diff --git a/resources/views/v1/budgets/no-budget.twig b/resources/views/v1/budgets/no-budget.twig
index 3769567a47..c60025dbe6 100644
--- a/resources/views/v1/budgets/no-budget.twig
+++ b/resources/views/v1/budgets/no-budget.twig
@@ -24,13 +24,13 @@
<div class="box-body ">
{% if periods.count > 0 %}
- {% include 'list.transactions' %}
+ {% include 'list.groups' %}
<p>
<i class="fa fa-calendar"></i>
<a href="{{ route('budgets.no-budget-all') }}">{{ 'show_all_no_filter'|_ }}</a>
</p>
{% else %}
- {% include 'list.transactions' with {showCategories:true, showBill:true} %}
+ {% include 'list.groups' %}
<p>
<i class="fa fa-calendar"></i>
<a href="{{ route('budgets.no-budget') }}">{{ 'show_the_current_period_and_overview'|_ }}</a>
diff --git a/resources/views/v1/budgets/show.twig b/resources/views/v1/budgets/show.twig
index 145e69fcb5..9fa223fd6d 100644
--- a/resources/views/v1/budgets/show.twig
+++ b/resources/views/v1/budgets/show.twig
@@ -90,9 +90,9 @@
</div>
<div class="box-body">
{% if budgetLimit %}
- {% include 'list.transactions' %}
+ {% include 'list.groups' %}
{% else %}
- {% include 'list.transactions' with {showCategories: true} %}
+ {% include 'list.groups' %}
{% endif %}
{% if budgetLimit %}
<p>
diff --git a/resources/views/v1/categories/no-category.twig b/resources/views/v1/categories/no-category.twig
index e1f069343e..62527a6ec1 100644
--- a/resources/views/v1/categories/no-category.twig
+++ b/resources/views/v1/categories/no-category.twig
@@ -24,13 +24,13 @@
<div class="box-body ">
{% if periods.count > 0 %}
- {% include 'list.transactions' %}
+ {% include 'list.groups' %}
<p>
<i class="fa fa-calendar"></i>
<a href="{{ route('categories.no-category.all') }}">{{ 'show_all_no_filter'|_ }}</a>
</p>
{% else %}
- {% include 'list.transactions' with {showBudgets:true, showBill:true} %}
+ {% include 'list.groups' %}
<p>
<i class="fa fa-calendar"></i>
<a href="{{ route('categories.no-category') }}">{{ 'show_the_current_period_and_overview'|_ }}</a>
diff --git a/resources/views/v1/categories/show.twig b/resources/views/v1/categories/show.twig
index 8523aafa1c..ac1b637cc4 100644
--- a/resources/views/v1/categories/show.twig
+++ b/resources/views/v1/categories/show.twig
@@ -66,7 +66,7 @@
</div>
<div class="box-body">
{% if periods.count > 0 %}
- {% include 'list.transactions' %}
+ {% include 'list.groups' %}
<p>
<i class="fa fa-calendar"></i>
<a href="{{ route('categories.show.all', [category.id]) }}">
@@ -74,7 +74,7 @@
</a>
</p>
{% else %}
- {% include 'list.transactions' with {showBudgets:true, showBill:true} %}
+ {% include 'list.groups' %}
<p>
<i class="fa fa-calendar"></i>
<a href="{{ route('categories.show', [category.id]) }}">
diff --git a/resources/views/v1/list/groups.twig b/resources/views/v1/list/groups.twig
index 1c6b950eb0..0b2bfda10a 100644
--- a/resources/views/v1/list/groups.twig
+++ b/resources/views/v1/list/groups.twig
@@ -67,7 +67,7 @@ TODO: hide and show columns
</td>
<td {{ style|raw }}>
- <a href="{{ route('transactions.edit', [group.id]) }}" title="{{ transaction.description }}">{{ transaction.description }}</a>
+ <a href="{{ route('transactions.show', [group.id]) }}" title="{{ transaction.description }}">{{ transaction.description }}</a>
</td>
<td {{ style|raw }}>
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}
diff --git a/resources/views/v1/popup/list/journals.twig b/resources/views/v1/popup/list/journals.twig
index 9d68015a09..47fd87c385 100644
--- a/resources/views/v1/popup/list/journals.twig
+++ b/resources/views/v1/popup/list/journals.twig
@@ -1,4 +1,127 @@
-{#
-TODO REPLACE ME
-#}
-<h1 style="color:red;">REPLACE ME</h1>
\ No newline at end of file
+<table class="table table-hover table-condensed">
+ <thead>
+ <tr>
+ <th>&nbsp;</th>
+ <th>{{ trans('list.description') }}</th>
+ <th>{{ trans('list.amount') }}</th>
+ <th class="hidden-sm hidden-xs">{{ trans('list.date') }}</th>
+ {% if not hideSource %}
+ <th class="hidden-xs">{{ trans('list.from') }}</th>
+ {% endif %}
+ {% if not hideDestination %}
+ <th class="hidden-xs">{{ trans('list.to') }}</th>
+ {% endif %}
+ {# Hide budgets? #}
+ {% if not hideBudget %}
+ <th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
+ {% endif %}
+
+ {# Hide categories? #}
+ {% if not hideCategory %}
+ <th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
+ {% endif %}
+ </tr>
+ </thead>
+ <tbody>
+ {# Make sum: #}
+ {% set sum = 0 %}
+ {% for transaction in journals %}
+ {# add to sum #}
+
+ <tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
+ <td class="hidden-xs">
+ {% if transaction.transaction_type_type == 'Withdrawal' %}
+ <i class="fa fa-long-arrow-left fa-fw" title="{{ trans('firefly.Withdrawal') }}"></i>
+ {% endif %}
+
+ {% if transaction.transaction_type_type == 'Deposit' %}
+ <i class="fa fa-long-arrow-right fa-fw" title="{{ trans('firefly.Deposit') }}"></i>
+ {% endif %}
+
+ {% if transaction.transaction_type_type == 'Transfer' %}
+ <i class="fa fa-exchange fa-fw" title="{{ trans('firefly.Deposit') }}"></i>
+ {% endif %}
+
+ {% if transaction.transaction_type_type == 'Reconciliation' %}
+ XX
+ {% endif %}
+
+ {% if transaction.transaction_type_type == 'Opening balance' %}
+ XX
+ {% endif %}
+ </td>
+
+ <td>
+ <a href="{{ route('transactions.show',transaction.transaction_journal_id) }}">
+ {% if transaction.group_title|length > 0 %}
+ {{ transaction.group_title }} ({{ transaction.description }})
+ {% else %}
+ {{ transaction.description }}
+ {% endif %}
+ </a>
+ </td>
+
+ <td>
+ {% if transaction.transaction_type_type == 'Deposit' %}
+ {{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}
+ {% set sum = (sum + (transaction.amount*-1)) %}
+ {% else %}
+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_symbol_decimal_places) }}
+ {% set sum = (sum + transaction.amount) %}
+ {% endif %}
+ </td>
+
+ <td class="hidden-sm hidden-xs">
+ {{ transaction.date.formatLocalized(monthAndDayFormat) }}
+ </td>
+
+ {% if not hideSource %}
+ <td class="hidden-xs">
+ <a href="{{ route('accounts.show', transaction.source_account_id) }}">
+ {{ transaction.source_account_name }}
+ </a>
+ </td>
+ {% endif %}
+
+ {% if not hideDestination %}
+ <td class="hidden-xs">
+ <a href="{{ route('accounts.show', transaction.destination_account_id) }}">
+ {{ transaction.destination_account_name }}
+ </a>
+ </td>
+ {% endif %}
+
+ <!-- Do NOT hide the budget? -->
+ {% if not hideBudget %}
+ <td class="hidden-xs">
+ {% if transaction.budget_id %}
+ <a href="{{ route('budgets.show', [transaction.budget_id]) }}">
+ {{ transaction.budget_name }}
+ </a>
+ {% endif %}
+ </td>
+ {% endif %}
+
+ <!-- Do NOT hide the category? -->
+ {% if not hideCategory %}
+ <td class="hidden-xs">
+ {% if transaction.category_id %}
+ <a href="{{ route('categories.show', [transaction.category_id]) }}">
+ {{ transaction.category_name }}
+ </a>
+ {% endif %}
+ </td>
+ {% endif %}
+ </tr>
+ {% endfor %}
+ </tbody>
+ <tfoot>
+ <tr>
+ <td colspan="2" style="text-align: right;"><em>{{ 'sum'|_ }}:</em></td>
+ <td>
+ {# TODO avoid using formatAmount #}
+ {{ sum|formatAmount }}
+ </td>
+ </tr>
+ </tfoot>
+</table>
diff --git a/resources/views/v1/popup/report/expense-entry.twig b/resources/views/v1/popup/report/expense-entry.twig
index 205613cffc..7f831804b6 100644
--- a/resources/views/v1/popup/report/expense-entry.twig
+++ b/resources/views/v1/popup/report/expense-entry.twig
@@ -7,7 +7,6 @@
</div>
<div class="modal-body">
{% set hideDestination = true %}
- {% set inverseAmount = true %}
{% include 'popup/list/journals' %}
</div>
<div class="modal-footer">
diff --git a/resources/views/v1/reports/tag/month.twig b/resources/views/v1/reports/tag/month.twig
index b58e3a001f..5d8fb2f095 100644
--- a/resources/views/v1/reports/tag/month.twig
+++ b/resources/views/v1/reports/tag/month.twig
@@ -354,10 +354,10 @@
<a href="{{ route('accounts.show', row.id) }}">{{ row.name }}</a>
</td>
<td data-value="{{ row.average }}" style="text-align:right;">
- {{ row.average|formatAmount }}
+ {{ (row.average*-1)|formatAmount }}
</td>
<td data-value="{{ row.sum }}" style="text-align:right;">
- {{ row.sum|formatAmount }}
+ {{ (row.sum*-1)|formatAmount }}
</td>
<td data-value="{{ row.count }}">
{{ row.count }}
@@ -368,7 +368,7 @@
<td colspan="2">
{{ 'sum'|_ }}
</td>
- <td style="text-align:right">{{ totalSum|formatAmount }}</td>
+ <td style="text-align:right">{{ (totalSum*-1)|formatAmount }}</td>
<td>{{ totalCount }}</td>
</tr>
</tbody>
@@ -378,7 +378,7 @@
</div>
{% endif %}
<div class="col-lg-6">
- {% if topIncome.count > 0 %}
+ {% if topIncome|length > 0 %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'income'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>
@@ -403,7 +403,7 @@
<tr>
{% endif %}
<td>
- <a href="{{ route('transactions.show', row.journal_id) }}">
+ <a href="{{ route('transactions.show', row.transaction_journal_id) }}">
{% if row.transaction_description|length > 0 %}
{{ row.transaction_description }} ({{ row.description }})
{% else %}
@@ -414,14 +414,15 @@
<td data-value="{{ row.date.format('Y-m-d H-i-s') }}">
{{ row.date.formatLocalized(monthAndDayFormat) }}
</td>
- <td data-value="{{ row.opposing_account_name }}">
- <a href="{{ route('accounts.show', row.opposing_account_id) }}">
- {{ row.opposing_account_name }}
+ <td data-value="{{ row.source_account_name }}">
+ <a href="{{ route('accounts.show', row.source_account_id) }}">
+ {{ row.source_account_name }}
</a>
</td>
- <td data-value="{{ row.transaction_amount }}" style="text-align:right;">
- {{ row.transaction_amount|formatAmount }}
+ <td data-value="{{ row.transaction_amount*-1 }}" style="text-align:right;">
+ {{ (row.transaction_amount*-1)|formatAmount }}
</td>
+
</tr>
{% endfor %}
</tbody>
@@ -437,7 +438,7 @@
<td colspan="3">
{{ 'sum'|_ }}
</td>
- <td style="text-align:right">{{ totalSum|formatAmount }}</td>
+ <td style="text-align:right">{{ (totalSum*-1)|formatAmount }}</td>
</tr>
</tfoot>
</table>
diff --git a/resources/views/v1/tags/show.twig b/resources/views/v1/tags/show.twig
index 0a59fbd91b..b39ccca8d9 100644
--- a/resources/views/v1/tags/show.twig
+++ b/resources/views/v1/tags/show.twig
@@ -132,7 +132,7 @@
</div>
</div>
<div class="box-body">
- {% include 'list/journals' %}
+ {% include 'list/groups' %}
{% if periods.count > 0 %}
<p>
diff --git a/resources/views/v1/transactions/index.twig b/resources/views/v1/transactions/index.twig
index 0171415ff9..921f16da60 100644
--- a/resources/views/v1/transactions/index.twig
+++ b/resources/views/v1/transactions/index.twig
@@ -1,7 +1,7 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
- {{ Breadcrumbs.render(Route.getCurrentRoute.getName, transactionType, start, end) }}
+ {{ Breadcrumbs.render(Route.getCurrentRoute.getName, objectType, start, end) }}
{% endblock %}
{% block content %}
diff --git a/routes/web.php b/routes/web.php
index 5995a3977b..d5c79fa74e 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -880,6 +880,9 @@ Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'transactions', 'as' => 'transactions.'], function () {
// show groups:
+ // TODO improve these routes
+ Route::get('{what}/all', ['uses' => 'Transaction\IndexController@indexAll', 'as' => 'index.all'])->where(['what' => 'withdrawal|deposit|transfers|transfer']);
+
Route::get('{what}/{start_date?}/{end_date?}', ['uses' => 'Transaction\IndexController@index', 'as' => 'index'])->where(
['what' => 'withdrawal|deposit|transfers|transfer']
);
@@ -890,10 +893,6 @@ Route::group(
-
- // TODO improve these routes
- Route::get('{what}/all', ['uses' => 'TransactionController@indexAll', 'as' => 'index.all'])->where(['what' => 'withdrawal|deposit|transfers|transfer']);
-
Route::get('debug/{tj}', ['uses' => 'Transaction\SingleController@debugShow', 'as' => 'debug']);
Route::get('debug/{tj}', ['uses' => 'Transaction\SingleController@debugShow', 'as' => 'debug']);