Various code cleanup.

This commit is contained in:
James Cole
2018-03-11 16:24:07 +01:00
parent 5a7b1ba292
commit b12872e5de
40 changed files with 114 additions and 229 deletions

View File

@@ -171,7 +171,9 @@ class TransactionController extends Controller
} }
/** /**
* @param TransactionRequest $request * @param TransactionRequest $request
*
* @param JournalRepositoryInterface $repository
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */

View File

@@ -244,12 +244,12 @@ class ReconcileController extends Controller
/** /**
* @param ReconciliationStoreRequest $request * @param ReconciliationStoreRequest $request
* @param JournalRepositoryInterface $repository
* @param Account $account * @param Account $account
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws FireflyException
*/ */
public function submit(ReconciliationStoreRequest $request, JournalRepositoryInterface $repository, Account $account, Carbon $start, Carbon $end) public function submit(ReconciliationStoreRequest $request, JournalRepositoryInterface $repository, Account $account, Carbon $start, Carbon $end)
{ {

View File

@@ -128,9 +128,8 @@ class AccountController extends Controller
} }
/** /**
* @param Request $request * @param Request $request
* @param AccountRepositoryInterface $repository * @param Account $account
* @param Account $account
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
@@ -152,15 +151,16 @@ class AccountController extends Controller
/** /**
* Edit an account. * Edit an account.
* *
* @param Request $request * @param Request $request
* @param Account $account * @param Account $account
*
* @param AccountRepositoryInterface $repository
*
* @return View
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
* @return View
*
* @throws FireflyException
*/ */
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository) public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{ {
@@ -277,16 +277,16 @@ class AccountController extends Controller
/** /**
* Show an account. * Show an account.
* *
* @param Request $request * @param Request $request
* @param Account $account * @param Account $account
* @param string $moment * @param Carbon|null $start
* * @param Carbon|null $end
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* *
* @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so. * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
* @throws FireflyException
*/ */
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
{ {
@@ -365,9 +365,8 @@ class AccountController extends Controller
} }
/** /**
* @param AccountFormRequest $request * @param AccountFormRequest $request
* @param AccountRepositoryInterface $repository * @param Account $account
* @param Account $account
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
@@ -410,8 +409,9 @@ class AccountController extends Controller
* and for each period, the amount of money spent and earned. This is a complex operation which is cached for * and for each period, the amount of money spent and earned. This is a complex operation which is cached for
* performance reasons. * performance reasons.
* *
* @param Account $account the account involved * @param Account $account the account involved
* *
* @param Carbon|null $date
* @return Collection * @return Collection
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)

View File

@@ -167,6 +167,7 @@ class BudgetController extends Controller
} }
/** /**
* @param Request $request
* @param string|null $moment * @param string|null $moment
* *
* @return View * @return View
@@ -545,8 +546,9 @@ class BudgetController extends Controller
} }
/** /**
* @param Carbon $start * @param Request $request
* @param Carbon $end * @param Carbon $start
* @param Carbon $end
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/ */

View File

@@ -424,6 +424,8 @@ class CategoryController extends Controller
/** /**
* @param Category $category * @param Category $category
* *
* @param Carbon $date
*
* @return Collection * @return Collection
*/ */
private function getPeriodOverview(Category $category, Carbon $date): Collection private function getPeriodOverview(Category $category, Carbon $date): Collection

View File

@@ -299,6 +299,8 @@ class AccountController extends Controller
* @param Account $account * @param Account $account
* @param Carbon $start * @param Carbon $start
* *
* @param Carbon $end
*
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function period(Account $account, Carbon $start, Carbon $end) public function period(Account $account, Carbon $start, Carbon $end)

View File

@@ -198,7 +198,9 @@ class BoxController extends Controller
} }
/** /**
* @param AccountRepositoryInterface $repository * @param AccountRepositoryInterface $repository
*
* @param CurrencyRepositoryInterface $currencyRepos
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */

View File

@@ -59,7 +59,9 @@ class PiggyBankController extends Controller
/** /**
* Add money to piggy bank. * Add money to piggy bank.
* *
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
*
* @param PiggyBankRepositoryInterface $repository
* *
* @return View * @return View
*/ */
@@ -78,8 +80,9 @@ class PiggyBankController extends Controller
/** /**
* Add money to piggy bank (for mobile devices). * Add money to piggy bank (for mobile devices).
* *
* @param PiggyBank $piggyBank * @param PiggyBank $piggyBank
* *
* @param PiggyBankRepositoryInterface $repository
* @return View * @return View
*/ */
public function addMobile(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository) public function addMobile(PiggyBank $piggyBank, PiggyBankRepositoryInterface $repository)
@@ -180,6 +183,7 @@ class PiggyBankController extends Controller
} }
/** /**
* @param Request $request
* @param PiggyBankRepositoryInterface $piggyRepository * @param PiggyBankRepositoryInterface $piggyRepository
* *
* @return View * @return View

View File

@@ -170,6 +170,8 @@ class ProfileController extends Controller
} }
/** /**
* @param UserRepositoryInterface $repository
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
public function enable2FA(UserRepositoryInterface $repository) public function enable2FA(UserRepositoryInterface $repository)

View File

@@ -66,6 +66,7 @@ class BulkController extends Controller
} }
/** /**
* @param Request $request
* @param Collection $journals * @param Collection $journals
* *
* @return View * @return View

View File

@@ -238,7 +238,9 @@ class SingleController extends Controller
} }
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
*
* @param JournalRepositoryInterface $repository
* *
* @return mixed * @return mixed
*/ */

View File

@@ -37,7 +37,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use FireflyIII\Transformers\TransactionTransformer; use FireflyIII\Transformers\TransactionTransformer;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -65,8 +64,6 @@ class SplitController extends Controller
private $currencies; private $currencies;
/** @var JournalRepositoryInterface */ /** @var JournalRepositoryInterface */
private $repository; private $repository;
/** @var JournalTaskerInterface */
private $tasker;
/** /**
* *
@@ -80,7 +77,6 @@ class SplitController extends Controller
function ($request, $next) { function ($request, $next) {
$this->accounts = app(AccountRepositoryInterface::class); $this->accounts = app(AccountRepositoryInterface::class);
$this->budgets = app(BudgetRepositoryInterface::class); $this->budgets = app(BudgetRepositoryInterface::class);
$this->tasker = app(JournalTaskerInterface::class);
$this->attachments = app(AttachmentHelperInterface::class); $this->attachments = app(AttachmentHelperInterface::class);
$this->currencies = app(CurrencyRepositoryInterface::class); $this->currencies = app(CurrencyRepositoryInterface::class);
$this->repository = app(JournalRepositoryInterface::class); $this->repository = app(JournalRepositoryInterface::class);

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface; use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use FireflyIII\Transformers\TransactionTransformer; use FireflyIII\Transformers\TransactionTransformer;
@@ -71,7 +70,6 @@ class TransactionController extends Controller
* *
* @return View * @return View
* *
* @throws FireflyException
*/ */
public function index(Request $request, JournalRepositoryInterface $repository, string $what, string $moment = '') public function index(Request $request, JournalRepositoryInterface $repository, string $what, string $moment = '')
{ {
@@ -176,13 +174,13 @@ class TransactionController extends Controller
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param JournalTaskerInterface $tasker * @param JournalRepositoryInterface $repository
* @param LinkTypeRepositoryInterface $linkTypeRepository * @param LinkTypeRepositoryInterface $linkTypeRepository
* *
* @throws FireflyException
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws FireflyException
*/ */
public function show(TransactionJournal $journal, JournalTaskerInterface $tasker, LinkTypeRepositoryInterface $linkTypeRepository) public function show(TransactionJournal $journal, JournalRepositoryInterface $repository, LinkTypeRepositoryInterface $linkTypeRepository)
{ {
if ($this->isOpeningBalance($journal)) { if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal); return $this->redirectToAccount($journal);
@@ -208,7 +206,7 @@ class TransactionController extends Controller
$transactions[] = $transformer->transform($transaction); $transactions[] = $transformer->transform($transaction);
} }
$events = $tasker->getPiggyBankEvents($journal); $events = $repository->getPiggyBankEvents($journal);
$what = strtolower($transactionType); $what = strtolower($transactionType);
$subTitle = trans('firefly.' . $what) . ' "' . $journal->description . '"'; $subTitle = trans('firefly.' . $what) . ' "' . $journal->description . '"';

View File

@@ -74,8 +74,7 @@ class Authenticate
* *
* @param array $guards * @param array $guards
* *
* @return void * @return mixed
*
* @throws \Illuminate\Auth\AuthenticationException * @throws \Illuminate\Auth\AuthenticationException
*/ */
protected function authenticate(array $guards) protected function authenticate(array $guards)

View File

@@ -63,7 +63,6 @@ class Binder
* *
* @return mixed * @return mixed
* *
* @throws \Illuminate\Auth\AuthenticationException
*/ */
public function handle($request, Closure $next, ...$guards) public function handle($request, Closure $next, ...$guards)
{ {

View File

@@ -146,7 +146,7 @@ class SplitJournalFormRequest extends Request
} }
/** /**
* * @param Validator $validator
*/ */
protected function sameAccounts(Validator $validator): void protected function sameAccounts(Validator $validator): void
{ {

View File

@@ -78,9 +78,8 @@ class CsvProcessor implements FileProcessorInterface
* *
* @return bool * @return bool
* *
* @throws \League\Csv\Exception
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
* @throws FireflyException * @throws FireflyException
* @throws \League\Csv\Exception
*/ */
public function run(): bool public function run(): bool
{ {

View File

@@ -117,8 +117,10 @@ class SpectreRoutine implements RoutineInterface
* have-account-mapping: start downloading transactions? * have-account-mapping: start downloading transactions?
* *
* *
* @throws \FireflyIII\Exceptions\FireflyException * @return bool
* @throws \FireflyIII\Services\Spectre\Exception\SpectreException * @throws FireflyException
* @throws SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
public function run(): bool public function run(): bool
{ {
@@ -166,6 +168,7 @@ class SpectreRoutine implements RoutineInterface
* @return Customer * @return Customer
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Services\Spectre\Exception\SpectreException * @throws \FireflyIII\Services\Spectre\Exception\SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
protected function createCustomer(): Customer protected function createCustomer(): Customer
{ {
@@ -201,7 +204,8 @@ class SpectreRoutine implements RoutineInterface
/** /**
* @return Customer * @return Customer
* @throws FireflyException * @throws FireflyException
* @throws \FireflyIII\Services\Spectre\Exception\SpectreException * @throws SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
protected function getCustomer(): Customer protected function getCustomer(): Customer
{ {
@@ -230,6 +234,7 @@ class SpectreRoutine implements RoutineInterface
* @return Token * @return Token
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Services\Spectre\Exception\SpectreException * @throws \FireflyIII\Services\Spectre\Exception\SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
protected function getToken(Customer $customer, string $returnUri): Token protected function getToken(Customer $customer, string $returnUri): Token
{ {
@@ -246,6 +251,7 @@ class SpectreRoutine implements RoutineInterface
/** /**
* @throws FireflyException * @throws FireflyException
* @throws SpectreException * @throws SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
protected function runStageInitial(): void protected function runStageInitial(): void
{ {
@@ -280,6 +286,7 @@ class SpectreRoutine implements RoutineInterface
/** /**
* @throws FireflyException * @throws FireflyException
* @throws SpectreException * @throws SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
protected function runStageLoggedIn(): void protected function runStageLoggedIn(): void
{ {
@@ -521,6 +528,7 @@ class SpectreRoutine implements RoutineInterface
/** /**
* @throws FireflyException * @throws FireflyException
* @throws SpectreException * @throws SpectreException
* @throws \Illuminate\Container\EntryNotFoundException
*/ */
private function runStageHaveMapping() private function runStageHaveMapping()
{ {

View File

@@ -26,8 +26,6 @@ use FireflyIII\Helpers\Collector\JournalCollector;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Repositories\Journal\JournalRepository; use FireflyIII\Repositories\Journal\JournalRepository;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalTasker;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
@@ -50,7 +48,6 @@ class JournalServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->registerRepository(); $this->registerRepository();
$this->registerTasker();
$this->registerCollector(); $this->registerCollector();
} }
@@ -91,24 +88,4 @@ class JournalServiceProvider extends ServiceProvider
} }
); );
} }
/**
* Register the tasker.
*/
private function registerTasker()
{
$this->app->bind(
JournalTaskerInterface::class,
function (Application $app) {
/** @var JournalTaskerInterface $tasker */
$tasker = app(JournalTasker::class);
if ($app->auth->check()) {
$tasker->setUser(auth()->user());
}
return $tasker;
}
);
}
} }

View File

@@ -228,8 +228,6 @@ class AccountRepository implements AccountRepositoryInterface
* @param array $data * @param array $data
* *
* @return Account * @return Account
* @throws FireflyException
* @throws Exception
*/ */
public function store(array $data): Account public function store(array $data): Account
{ {
@@ -245,8 +243,6 @@ class AccountRepository implements AccountRepositoryInterface
* @param Account $account * @param Account $account
* @param array $data * @param array $data
* *
* @throws FireflyException
* @throws Exception
* @return Account * @return Account
*/ */
public function update(Account $account, array $data): Account public function update(Account $account, array $data): Account
@@ -263,8 +259,6 @@ class AccountRepository implements AccountRepositoryInterface
* @param array $data * @param array $data
* *
* @return TransactionJournal * @return TransactionJournal
* @throws FireflyException
* @throws Exception
*/ */
public function updateReconciliation(TransactionJournal $journal, array $data): TransactionJournal public function updateReconciliation(TransactionJournal $journal, array $data): TransactionJournal
{ {

View File

@@ -216,8 +216,6 @@ trait FindAccountsTrait
/** /**
* @return Account * @return Account
* *
* @throws FireflyException
* @throws \Exception
*/ */
public function getCashAccount(): Account public function getCashAccount(): Account
{ {

View File

@@ -306,7 +306,6 @@ class BillRepository implements BillRepositoryInterface
* @param Carbon $end * @param Carbon $end
* *
* @return Collection * @return Collection
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection
{ {

View File

@@ -28,6 +28,7 @@ use FireflyIII\Factory\TransactionJournalFactory;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Note; use FireflyIII\Models\Note;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
@@ -470,6 +471,24 @@ class JournalRepository implements JournalRepositoryInterface
return $note->text; return $note->text;
} }
/**
* @param TransactionJournal $journal
*
* @return Collection
*/
public function getPiggyBankEvents(TransactionJournal $journal): Collection
{
/** @var Collection $set */
$events = $journal->piggyBankEvents()->get();
$events->each(
function (PiggyBankEvent $event) {
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
}
);
return $events;
}
/** /**
* Return all tags as strings in an array. * Return all tags as strings in an array.
* *
@@ -623,7 +642,6 @@ class JournalRepository implements JournalRepositoryInterface
* *
* @return TransactionJournal * @return TransactionJournal
* *
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function update(TransactionJournal $journal, array $data): TransactionJournal public function update(TransactionJournal $journal, array $data): TransactionJournal
{ {

View File

@@ -37,6 +37,7 @@ use Illuminate\Support\MessageBag;
*/ */
interface JournalRepositoryInterface interface JournalRepositoryInterface
{ {
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* @param TransactionType $type * @param TransactionType $type
@@ -201,6 +202,13 @@ interface JournalRepositoryInterface
*/ */
public function getNoteText(TransactionJournal $journal): string; public function getNoteText(TransactionJournal $journal): string;
/**
* @param TransactionJournal $journal
*
* @return Collection
*/
public function getPiggyBankEvents(TransactionJournal $journal): Collection;
/** /**
* Return all tags as strings in an array. * Return all tags as strings in an array.
* *

View File

@@ -1,71 +0,0 @@
<?php
/**
* JournalTasker.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use DB;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Steam;
/**
* Class JournalTasker.
*/
class JournalTasker implements JournalTaskerInterface
{
/** @var User */
private $user;
/**
* @deprecated
*
* @param TransactionJournal $journal
*
* @return Collection
*/
public function getPiggyBankEvents(TransactionJournal $journal): Collection
{
/** @var Collection $set */
$events = $journal->piggyBankEvents()->get();
$events->each(
function (PiggyBankEvent $event) {
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
}
);
return $events;
}
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
}
}

View File

@@ -1,46 +0,0 @@
<?php
/**
* JournalTaskerInterface.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Support\Collection;
/**
* Interface JournalTaskerInterface.
*/
interface JournalTaskerInterface
{
/**
* @param TransactionJournal $journal
*
* @deprecated
* @return Collection
*/
public function getPiggyBankEvents(TransactionJournal $journal): Collection;
/**
* @param User $user
*/
public function setUser(User $user);
}

View File

@@ -38,7 +38,7 @@ class UniqueIban implements Rule
/** /**
* Create a new rule instance. * Create a new rule instance.
* *
* @return void * @param Account|null $account
*/ */
public function __construct(?Account $account) public function __construct(?Account $account)
{ {

View File

@@ -127,6 +127,7 @@ trait AccountServiceTrait
* @param array $data * @param array $data
* *
* @return TransactionJournal|null * @return TransactionJournal|null
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function storeIBJournal(Account $account, array $data): ?TransactionJournal public function storeIBJournal(Account $account, array $data): ?TransactionJournal
{ {

View File

@@ -258,7 +258,6 @@ abstract class SpectreRequest
* @param Requests_Response $response * @param Requests_Response $response
* *
* @throws FireflyException * @throws FireflyException
* @throws SpectreException
*/ */
private function detectError(Requests_Response $response): void private function detectError(Requests_Response $response): void
{ {

View File

@@ -46,6 +46,7 @@ class ExpandedForm
* *
* @return string * @return string
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @throws \Throwable
*/ */
public function amount(string $name, $value = null, array $options = []): string public function amount(string $name, $value = null, array $options = []): string
{ {
@@ -53,12 +54,13 @@ class ExpandedForm
} }
/** /**
* @param $name * @param string $name
* @param null $value * @param null $value
* @param array $options * @param array $options
* *
* @return string * @return string
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @throws \Throwable
*/ */
public function amountSmall(string $name, $value = null, array $options = []): string public function amountSmall(string $name, $value = null, array $options = []): string
{ {
@@ -118,13 +120,13 @@ class ExpandedForm
} }
/** /**
* @param $name * @param string $name
* @param null $value * @param null $value
* @param array $options * @param array $options
* *
* @return string * @return string
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* * @throws \Throwable
*/ */
public function balance(string $name, $value = null, array $options = []): string public function balance(string $name, $value = null, array $options = []): string
{ {
@@ -653,6 +655,7 @@ class ExpandedForm
* @return string * @return string
* *
* @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Exceptions\FireflyException
* @throws \Throwable
*/ */
private function currencyField(string $name, string $view, $value = null, array $options = []): string private function currencyField(string $name, string $view, $value = null, array $options = []): string
{ {

View File

@@ -52,7 +52,6 @@ class Map implements ConfigurationInterface
* *
* @throws FireflyException * @throws FireflyException
* @throws \League\Csv\Exception * @throws \League\Csv\Exception
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/ */
public function getData(): array public function getData(): array
{ {

View File

@@ -52,7 +52,6 @@ class Roles implements ConfigurationInterface
* @return array * @return array
* *
* @throws \League\Csv\Exception * @throws \League\Csv\Exception
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/ */
public function getData(): array public function getData(): array
{ {

View File

@@ -261,7 +261,6 @@ class Search implements SearchInterface
* *
* @return bool * @return bool
* *
* @throws FireflyException
*/ */
private function matchModifiers(Transaction $transaction): bool private function matchModifiers(Transaction $transaction): bool
{ {

View File

@@ -67,6 +67,7 @@ final class Processor
* @param bool $includeActions * @param bool $includeActions
* *
* @return Processor * @return Processor
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public static function make(Rule $rule, $includeActions = true) public static function make(Rule $rule, $includeActions = true)
{ {
@@ -229,6 +230,7 @@ final class Processor
* Run the actions * Run the actions
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
private function actions() private function actions()
{ {

View File

@@ -26,7 +26,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Rule; use FireflyIII\Models\Rule;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
@@ -42,29 +41,18 @@ class TransactionMatcher
private $range = 200; private $range = 200;
/** @var Rule The rule to apply */ /** @var Rule The rule to apply */
private $rule; private $rule;
/** @var JournalTaskerInterface Tasker for some related tasks */
private $tasker;
/** @var array Types that can be matched using this matcher */ /** @var array Types that can be matched using this matcher */
private $transactionTypes = [TransactionType::DEPOSIT, TransactionType::WITHDRAWAL, TransactionType::TRANSFER]; private $transactionTypes = [TransactionType::DEPOSIT, TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
/** @var array List of triggers to match */ /** @var array List of triggers to match */
private $triggers = []; private $triggers = [];
/**
* TransactionMatcher constructor. Typehint the repository.
*
* @param JournalTaskerInterface $tasker
*/
public function __construct(JournalTaskerInterface $tasker)
{
$this->tasker = $tasker;
}
/** /**
* This method will search the user's transaction journal (with an upper limit of $range) for * This method will search the user's transaction journal (with an upper limit of $range) for
* transaction journals matching the given rule. This is accomplished by trying to fire these * transaction journals matching the given rule. This is accomplished by trying to fire these
* triggers onto each transaction journal until enough matches are found ($limit). * triggers onto each transaction journal until enough matches are found ($limit).
* *
* @return Collection * @return Collection
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function findTransactionsByRule() public function findTransactionsByRule()
{ {
@@ -89,6 +77,7 @@ class TransactionMatcher
* triggers onto each transaction journal until enough matches are found ($limit). * triggers onto each transaction journal until enough matches are found ($limit).
* *
* @return Collection * @return Collection
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function findTransactionsByTriggers(): Collection public function findTransactionsByTriggers(): Collection
{ {

View File

@@ -29,7 +29,7 @@ use FireflyIII\Models\TransactionJournal;
* This class will be magical! * This class will be magical!
* *
* Class AbstractTrigger * Class AbstractTrigger
* @method triggered * @method bool triggered($object)
*/ */
class AbstractTrigger class AbstractTrigger
{ {

View File

@@ -33,9 +33,6 @@ declare(strict_types=1);
| |
*/ */
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
bcscale(12); bcscale(12);

View File

@@ -219,7 +219,7 @@
{# description #} {# description #}
<div class="col-lg-3 col-md-5 col-sm-12 col-xs-12"> <div class="col-lg-3 col-md-5 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][description]" <input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][transaction_description]"
value="{{ transaction.transaction_description }}" value="{{ transaction.transaction_description }}"
class="form-control"/> class="form-control"/>
</div> </div>
@@ -227,7 +227,7 @@
{# destination for withdrawals: #} {# destination for withdrawals: #}
{% if preFilled.what == 'withdrawal' %} {% if preFilled.what == 'withdrawal' %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12"> <div class="col-lg-2 col-md-5 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][destination_account_name]" <input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][destination_name]"
value="{{ transaction.destination_name }}" class="form-control"/> value="{{ transaction.destination_name }}" class="form-control"/>
</div> </div>
{% endif %} {% endif %}
@@ -235,7 +235,7 @@
{# source for deposits #} {# source for deposits #}
{% if preFilled.what == 'deposit' %} {% if preFilled.what == 'deposit' %}
<div class="col-lg-2 col-md-5 col-sm-12 col-xs-12"> <div class="col-lg-2 col-md-5 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][source_account_name]" <input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][source_name]"
value="{{ transaction.source_name }}" class="form-control"/> value="{{ transaction.source_name }}" class="form-control"/>
</div> </div>
{% endif %} {% endif %}
@@ -285,7 +285,7 @@
{# category #} {# category #}
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12"> <div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
<input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][category]" <input autocomplete="off" type="text" name="transactions[{{ loop.index0 }}][category_name]"
value="{{ transaction.category_name}}" value="{{ transaction.category_name}}"
class="form-control"/> class="form-control"/>
</div> </div>

View File

@@ -309,6 +309,8 @@ class BudgetControllerTest extends TestCase
/** /**
* @covers \FireflyIII\Http\Controllers\BudgetController::infoIncome * @covers \FireflyIII\Http\Controllers\BudgetController::infoIncome
* @dataProvider dateRangeProvider * @dataProvider dateRangeProvider
*
* @param string $range
*/ */
public function testInfoIncomeExpanded(string $range) public function testInfoIncomeExpanded(string $range)
{ {

View File

@@ -27,9 +27,9 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use Google2FA;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences;
use Tests\TestCase; use Tests\TestCase;
/** /**