mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-14 01:13:37 -06:00
Add interface for journal collector.
This commit is contained in:
parent
49cc8a97a3
commit
a08dfe1e3c
@ -27,7 +27,7 @@ use Log;
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collector
|
||||
*/
|
||||
class JournalCollector
|
||||
class JournalCollector implements JournalCollectorInterface
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
@ -152,9 +152,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): JournalCollector
|
||||
public function setAccounts(Collection $accounts): JournalCollectorInterface
|
||||
{
|
||||
if ($accounts->count() > 0) {
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
@ -169,9 +169,9 @@ class JournalCollector
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAllAssetAccounts(): JournalCollector
|
||||
public function setAllAssetAccounts(): JournalCollectorInterface
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
@ -191,9 +191,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param Collection $bills
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBills(Collection $bills): JournalCollector
|
||||
public function setBills(Collection $bills): JournalCollectorInterface
|
||||
{
|
||||
if ($bills->count() > 0) {
|
||||
$billIds = $bills->pluck('id')->toArray();
|
||||
@ -207,9 +207,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBudget(Budget $budget): JournalCollector
|
||||
public function setBudget(Budget $budget): JournalCollectorInterface
|
||||
{
|
||||
$this->joinBudgetTables();
|
||||
|
||||
@ -226,9 +226,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setCategory(Category $category): JournalCollector
|
||||
public function setCategory(Category $category): JournalCollectorInterface
|
||||
{
|
||||
$this->joinCategoryTables();
|
||||
|
||||
@ -245,9 +245,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setLimit(int $limit): JournalCollector
|
||||
public function setLimit(int $limit): JournalCollectorInterface
|
||||
{
|
||||
$this->limit = $limit;
|
||||
$this->query->limit($limit);
|
||||
@ -259,9 +259,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param int $offset
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setOffset(int $offset): JournalCollector
|
||||
public function setOffset(int $offset): JournalCollectorInterface
|
||||
{
|
||||
$this->offset = $offset;
|
||||
|
||||
@ -271,9 +271,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param int $page
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setPage(int $page): JournalCollector
|
||||
public function setPage(int $page): JournalCollectorInterface
|
||||
{
|
||||
$this->page = $page;
|
||||
|
||||
@ -299,9 +299,9 @@ class JournalCollector
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setRange(Carbon $start, Carbon $end): JournalCollector
|
||||
public function setRange(Carbon $start, Carbon $end): JournalCollectorInterface
|
||||
{
|
||||
if ($start <= $end) {
|
||||
$this->query->where('transaction_journals.date', '>=', $start->format('Y-m-d'));
|
||||
@ -314,9 +314,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTag(Tag $tag): JournalCollector
|
||||
public function setTag(Tag $tag): JournalCollectorInterface
|
||||
{
|
||||
$this->joinTagTables();
|
||||
$this->query->where('tag_transaction_journal.tag_id', $tag->id);
|
||||
@ -327,9 +327,9 @@ class JournalCollector
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTypes(array $types): JournalCollector
|
||||
public function setTypes(array $types): JournalCollectorInterface
|
||||
{
|
||||
if (count($types) > 0) {
|
||||
$this->query->whereIn('transaction_types.type', $types);
|
||||
@ -339,9 +339,9 @@ class JournalCollector
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withoutBudget(): JournalCollector
|
||||
public function withoutBudget(): JournalCollectorInterface
|
||||
{
|
||||
$this->joinBudgetTables();
|
||||
|
||||
@ -356,9 +356,9 @@ class JournalCollector
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JournalCollector
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withoutCategory(): JournalCollector
|
||||
public function withoutCategory(): JournalCollectorInterface
|
||||
{
|
||||
$this->joinCategoryTables();
|
||||
|
||||
|
130
app/Helpers/Collector/JournalCollectorInterface.php
Normal file
130
app/Helpers/Collector/JournalCollectorInterface.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* JournalCollectorInterface.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collector;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface JournalCollectorInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collector
|
||||
*/
|
||||
interface JournalCollectorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournals(): Collection;
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getPaginatedJournals():LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAllAssetAccounts(): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Collection $bills
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBills(Collection $bills): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBudget(Budget $budget): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setCategory(Category $category): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setLimit(int $limit): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setOffset(int $offset): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setPage(int $page): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setRange(Carbon $start, Carbon $end): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTag(Tag $tag): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTypes(array $types): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withoutBudget(): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withoutCategory(): JournalCollectorInterface;
|
||||
}
|
Loading…
Reference in New Issue
Block a user