From 67ea825d4a8edf1a3ff465b47923ac6b84f5219b Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 22 Jul 2018 21:09:57 +0200 Subject: [PATCH] Remove unused methods. --- .../Transaction/SingleController.php | 9 +- app/Http/Requests/RuleFormRequest.php | 2 +- app/Http/Requests/RuleGroupFormRequest.php | 2 +- app/Providers/FireflyServiceProvider.php | 3 - app/Repositories/Budget/BudgetRepository.php | 65 ----- .../Budget/BudgetRepositoryInterface.php | 29 --- .../Category/CategoryRepository.php | 18 -- .../Category/CategoryRepositoryInterface.php | 10 - .../Currency/CurrencyRepository.php | 76 ------ .../Currency/CurrencyRepositoryInterface.php | 43 ---- .../ImportJob/ImportJobRepository.php | 232 ------------------ .../ImportJobRepositoryInterface.php | 89 ------- .../Journal/JournalRepository.php | 66 ----- .../Journal/JournalRepositoryInterface.php | 35 --- .../LinkType/LinkTypeRepository.php | 16 -- .../LinkType/LinkTypeRepositoryInterface.php | 8 - .../PiggyBank/PiggyBankRepository.php | 34 --- .../PiggyBankRepositoryInterface.php | 15 -- app/Repositories/Rule/RuleRepository.php | 6 +- .../Rule/RuleRepositoryInterface.php | 4 +- .../RuleGroup/RuleGroupRepository.php | 6 +- .../RuleGroupRepositoryInterface.php | 4 +- app/Repositories/Tag/TagRepository.php | 57 ----- .../Tag/TagRepositoryInterface.php | 26 -- .../TransactionTypeRepository.php | 44 ---- .../TransactionTypeRepositoryInterface.php | 43 ---- 26 files changed, 13 insertions(+), 929 deletions(-) delete mode 100644 app/Repositories/TransactionType/TransactionTypeRepository.php delete mode 100644 app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 00c6dd78cf..67ca017160 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -28,7 +28,6 @@ use FireflyIII\Events\UpdatedTransactionJournal; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\JournalFormRequest; -use FireflyIII\Models\Note; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; @@ -124,15 +123,9 @@ class SingleController extends Controller 'payment_date' => $this->repository->getMetaField($journal, 'payment_date'), 'invoice_date' => $this->repository->getMetaField($journal, 'invoice_date'), 'internal_reference' => $this->repository->getMetaField($journal, 'internal_reference'), - 'notes' => '', + 'notes' => $this->repository->getNoteText($journal), ]; - /** @var Note $note */ - $note = $this->repository->getNote($journal); - if (null !== $note) { - $preFilled['notes'] = $note->text; - } - session()->flash('preFilled', $preFilled); return redirect(route('transactions.create', [strtolower($journal->transactionType->type)])); diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php index 24390eb024..84a6e3fe30 100644 --- a/app/Http/Requests/RuleFormRequest.php +++ b/app/Http/Requests/RuleFormRequest.php @@ -108,7 +108,7 @@ class RuleFormRequest extends Request $contextActions = implode(',', config('firefly.rule-actions-text')); $titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title'; - if (null !== $repository->find((int)$this->get('id'))->id) { + if (null !== $repository->find((int)$this->get('id'))) { $titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title,' . (int)$this->get('id'); } $rules = [ diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php index 8b99c1f957..e1c29c6ba4 100644 --- a/app/Http/Requests/RuleGroupFormRequest.php +++ b/app/Http/Requests/RuleGroupFormRequest.php @@ -64,7 +64,7 @@ class RuleGroupFormRequest extends Request /** @var RuleGroupRepositoryInterface $repository */ $repository = app(RuleGroupRepositoryInterface::class); $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title'; - if (null !== $repository->find((int)$this->get('id'))->id) { + if (null !== $repository->find((int)$this->get('id'))) { $titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . (int)$this->get('id'); } diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 554badb4f4..4cef20c2bf 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -42,8 +42,6 @@ use FireflyIII\Helpers\Report\PopupReport; use FireflyIII\Helpers\Report\PopupReportInterface; use FireflyIII\Helpers\Report\ReportHelper; use FireflyIII\Helpers\Report\ReportHelperInterface; -use FireflyIII\Repositories\TransactionType\TransactionTypeRepository; -use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface; use FireflyIII\Repositories\User\UserRepository; use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Services\Currency\ExchangeRateInterface; @@ -174,7 +172,6 @@ class FireflyServiceProvider extends ServiceProvider // export: $this->app->bind(ProcessorInterface::class, ExpandedProcessor::class); $this->app->bind(UserRepositoryInterface::class, UserRepository::class); - $this->app->bind(TransactionTypeRepositoryInterface::class, TransactionTypeRepository::class); $this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class); // more generators: diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 0f6f8b83e8..b48bb98157 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -161,20 +161,6 @@ class BudgetRepository implements BudgetRepositoryInterface return $return; } - /** - * Deletes a budget limit. - * - * @param BudgetLimit $budgetLimit - */ - public function deleteBudgetLimit(BudgetLimit $budgetLimit): void - { - try { - $budgetLimit->delete(); - } catch (Exception $e) { - Log::error(sprintf('Could not delete budget limit: %s', $e->getMessage())); - } - } - /** * @param Budget $budget * @@ -217,57 +203,6 @@ class BudgetRepository implements BudgetRepositoryInterface } } - /** - * Filters entries from the result set generated by getBudgetPeriodReport. - * - * @param Collection $set - * @param int $budgetId - * @param array $periods - * - * @return array - */ - public function filterAmounts(Collection $set, int $budgetId, array $periods): array - { - $arr = []; - $keys = array_keys($periods); - foreach ($keys as $period) { - /** @var stdClass $object */ - $result = $set->filter( - function (TransactionJournal $object) use ($budgetId, $period) { - $result = (string)$object->period_marker === (string)$period && $budgetId === (int)$object->budget_id; - - return $result; - } - ); - $amount = '0'; - if (null !== $result->first()) { - $amount = $result->first()->sum_of_period; - } - - $arr[$period] = $amount; - } - - return $arr; - } - - /** - * Find a budget. - * - * @param int $budgetId - * - * @return Budget - * @deprecated - */ - public function find(int $budgetId): Budget - { - $budget = $this->user->budgets()->find($budgetId); - if (null === $budget) { - $budget = new Budget; - } - - return $budget; - } - /** * Find a budget. * diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 0ed8ee63c8..56a3ca82a6 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -62,13 +62,6 @@ interface BudgetRepositoryInterface */ public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array; - /** - * Deletes a budget limit. - * - * @param BudgetLimit $budgetLimit - */ - public function deleteBudgetLimit(BudgetLimit $budgetLimit): void; - /** * @param Budget $budget * @@ -88,28 +81,6 @@ interface BudgetRepositoryInterface */ public function destroyBudgetLimit(BudgetLimit $budgetLimit): void; - /** - * Filters entries from the result set generated by getBudgetPeriodReport. - * - * @param Collection $set - * @param int $budgetId - * @param array $periods - * - * @return array - */ - public function filterAmounts(Collection $set, int $budgetId, array $periods): array; - - /** - * Find a budget. - * - * @param int $budgetId - * - * @deprecated - * - * @return Budget - */ - public function find(int $budgetId): Budget; - /** * Find a budget. * diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index bde679c87c..b134f74fef 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -79,24 +79,6 @@ class CategoryRepository implements CategoryRepositoryInterface return (string)$set->sum('transaction_amount'); } - /** - * Find a category. - * - * @param int $categoryId - * - * @return Category - * @deprecated - */ - public function find(int $categoryId): Category - { - $category = $this->user->categories()->find($categoryId); - if (null === $category) { - $category = new Category; - } - - return $category; - } - /** * Find a category. * diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php index 321186a2a3..0ec74ea07a 100644 --- a/app/Repositories/Category/CategoryRepositoryInterface.php +++ b/app/Repositories/Category/CategoryRepositoryInterface.php @@ -51,16 +51,6 @@ interface CategoryRepositoryInterface */ public function earnedInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string; - /** - * Find a category. - * - * @param int $categoryId - * - * @deprecated - * @return Category - */ - public function find(int $categoryId): Category; - /** * Find a category. * diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index d97daf9c45..8698ae74a8 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -107,44 +107,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface return true; } - /** - * Find by ID. - * - * @param int $currencyId - * - * @deprecated - * - * @return TransactionCurrency - */ - public function find(int $currencyId): TransactionCurrency - { - $currency = TransactionCurrency::find($currencyId); - if (null === $currency) { - $currency = new TransactionCurrency; - } - - return $currency; - } - - /** - * Find by currency code. - * - * @deprecated - * - * @param string $currencyCode - * - * @return TransactionCurrency - */ - public function findByCode(string $currencyCode): TransactionCurrency - { - $currency = TransactionCurrency::where('code', $currencyCode)->first(); - if (null === $currency) { - $currency = new TransactionCurrency; - } - - return $currency; - } - /** * Find by currency code, return NULL if unfound. * Used in Import Currency! @@ -158,25 +120,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface return TransactionCurrency::where('code', $currencyCode)->first(); } - /** - * Find by currency name. - * - * @param string $currencyName - * - * @deprecated - * - * @return TransactionCurrency - */ - public function findByName(string $currencyName): TransactionCurrency - { - $preferred = TransactionCurrency::whereName($currencyName)->first(); - if (null === $preferred) { - $preferred = new TransactionCurrency; - } - - return $preferred; - } - /** * Find by currency name or return null. * Used in Import Currency! @@ -190,25 +133,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface return TransactionCurrency::whereName($currencyName)->first(); } - /** - * Find by currency symbol. - * - * @deprecated - * - * @param string $currencySymbol - * - * @return TransactionCurrency - */ - public function findBySymbol(string $currencySymbol): TransactionCurrency - { - $currency = TransactionCurrency::whereSymbol($currencySymbol)->first(); - if (null === $currency) { - $currency = new TransactionCurrency; - } - - return $currency; - } - /** * Find by currency symbol or return NULL * Used in Import Currency! diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.php index 72f12a0188..72c4d9de29 100644 --- a/app/Repositories/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php @@ -55,27 +55,6 @@ interface CurrencyRepositoryInterface */ public function destroy(TransactionCurrency $currency): bool; - /** - * Find by ID. - * - * @param int $currencyId - * - * @deprecated - * @return TransactionCurrency - */ - public function find(int $currencyId): TransactionCurrency; - - /** - * Find by currency code. - * - * @deprecated - * - * @param string $currencyCode - * - * @return TransactionCurrency - */ - public function findByCode(string $currencyCode): TransactionCurrency; - /** * Find by currency code, return NULL if unfound. * @@ -85,17 +64,6 @@ interface CurrencyRepositoryInterface */ public function findByCodeNull(string $currencyCode): ?TransactionCurrency; - /** - * Find by currency name. - * - * @deprecated - * - * @param string $currencyName - * - * @return TransactionCurrency - */ - public function findByName(string $currencyName): TransactionCurrency; - /** * Find by currency name. * @@ -105,17 +73,6 @@ interface CurrencyRepositoryInterface */ public function findByNameNull(string $currencyName): ?TransactionCurrency; - /** - * Find by currency symbol. - * - * @deprecated - * - * @param string $currencySymbol - * - * @return TransactionCurrency - */ - public function findBySymbol(string $currencySymbol): TransactionCurrency; - /** * Find by currency symbol. * diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php index 0ffe312230..ca5f59ff8b 100644 --- a/app/Repositories/ImportJob/ImportJobRepository.php +++ b/app/Repositories/ImportJob/ImportJobRepository.php @@ -56,21 +56,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface $this->uploadDisk = Storage::disk('upload'); } - /** - * @param ImportJob $job - * @param int $index - * @param string $error - * - * @return ImportJob - */ - public function addError(ImportJob $job, int $index, string $error): ImportJob - { - $extended = $this->getExtendedStatus($job); - $extended['errors'][$index][] = $error; - - return $this->setExtendedStatus($job, $extended); - } - /** * Add message to job. * @@ -89,58 +74,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface return $job; } - /** - * @param ImportJob $job - * @param int $steps - * - * @return ImportJob - */ - public function addStepsDone(ImportJob $job, int $steps = null): ImportJob - { - $steps = $steps ?? 1; - $status = $this->getExtendedStatus($job); - $status['done'] += $steps; - Log::debug(sprintf('Add %d to steps done for job "%s" making steps done %d', $steps, $job->key, $status['done'])); - - return $this->setExtendedStatus($job, $status); - } - - /** - * @param ImportJob $job - * @param int $steps - * - * @return ImportJob - */ - public function addTotalSteps(ImportJob $job, int $steps = null): ImportJob - { - $steps = $steps ?? 1; - $extended = $this->getExtendedStatus($job); - $total = (int)($extended['steps'] ?? 0); - $total += $steps; - $extended['steps'] = $total; - - return $this->setExtendedStatus($job, $extended); - - } - - /** - * Return number of imported rows with this hash value. - * - * @param string $hash - * - * @return int - */ - public function countByHash(string $hash): int - { - $json = json_encode($hash); - $count = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') - ->where('data', $json) - ->where('name', 'importHash') - ->count(); - - return $count; - } - /** * @param string $importProvider * @@ -243,111 +176,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface return []; } - /** - * @param ImportJob $job - * - * @return string - */ - public function getStatus(ImportJob $job): string - { - return $job->status; - } - - /** - * @param ImportJob $job - * @param UploadedFile $file - * - * @return bool - */ - public function processConfiguration(ImportJob $job, UploadedFile $file): bool - { - /** @var UserRepositoryInterface $repository */ - $repository = app(UserRepositoryInterface::class); - // demo user's configuration upload is ignored completely. - if (!$repository->hasRole($this->user, 'demo')) { - Log::debug( - 'Uploaded configuration file', - ['name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'mime' => $file->getClientMimeType()] - ); - - $configFileObject = new SplFileObject($file->getRealPath()); - $configRaw = $configFileObject->fread($configFileObject->getSize()); - $configuration = json_decode($configRaw, true); - Log::debug(sprintf('Raw configuration is %s', $configRaw)); - if (null !== $configuration && \is_array($configuration)) { - Log::debug('Found configuration', $configuration); - $this->setConfiguration($job, $configuration); - } - if (null === $configuration) { - Log::error('Uploaded configuration is NULL'); - } - if (false === $configuration) { - Log::error('Uploaded configuration is FALSE'); - } - } - - return true; - } - - /** - * @param ImportJob $job - * @param null|UploadedFile $file - * - * @return bool - * - * @throws \Illuminate\Contracts\Encryption\EncryptException - * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException - */ - public function processFile(ImportJob $job, ?UploadedFile $file): bool - { - if (null === $file) { - return false; - } - /** @var UserRepositoryInterface $repository */ - $repository = app(UserRepositoryInterface::class); - $newName = sprintf('%s.upload', $job->key); - $uploaded = new SplFileObject($file->getRealPath()); - $content = trim($uploaded->fread($uploaded->getSize())); - - // verify content: - $result = mb_detect_encoding($content, 'UTF-8', true); - if (false === $result) { - Log::error(sprintf('Cannot detect encoding for uploaded import file "%s".', $file->getClientOriginalName())); - - return false; - } - if ('ASCII' !== $result && 'UTF-8' !== $result) { - Log::error(sprintf('Uploaded import file is %s instead of UTF8!', var_export($result, true))); - - return false; - } - - $contentEncrypted = Crypt::encrypt($content); - $disk = Storage::disk('upload'); - - // user is demo user, replace upload with prepared file. - if ($repository->hasRole($this->user, 'demo')) { - $stubsDisk = Storage::disk('stubs'); - $content = $stubsDisk->get('demo-import.csv'); - $contentEncrypted = Crypt::encrypt($content); - $disk->put($newName, $contentEncrypted); - Log::debug('Replaced upload with demo file.'); - - // also set up prepared configuration. - $configuration = json_decode($stubsDisk->get('demo-configuration.json'), true); - $this->setConfiguration($job, $configuration); - Log::debug('Set configuration for demo user', $configuration); - } - - if (!$repository->hasRole($this->user, 'demo')) { - // user is not demo, process original upload: - $disk->put($newName, $contentEncrypted); - Log::debug('Uploaded file', ['name' => $file->getClientOriginalName(), 'size' => $file->getSize(), 'mime' => $file->getClientMimeType()]); - } - - return true; - } - /** * @param ImportJob $job * @param array $configuration @@ -368,22 +196,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface return $job; } - /** - * @param ImportJob $job - * @param array $array - * - * @return ImportJob - */ - public function setExtendedStatus(ImportJob $job, array $array): ImportJob - { - $currentStatus = $job->extended_status; - $newStatus = array_merge($currentStatus, $array); - $job->extended_status = $newStatus; - $job->save(); - - return $job; - } - /** * @param ImportJob $job * @param string $stage @@ -413,21 +225,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface return $job; } - /** - * @param ImportJob $job - * @param int $steps - * - * @return ImportJob - */ - public function setStepsDone(ImportJob $job, int $steps): ImportJob - { - $status = $this->getExtendedStatus($job); - $status['done'] = $steps; - Log::debug(sprintf('Set steps done for job "%s" to %d', $job->key, $steps)); - - return $this->setExtendedStatus($job, $status); - } - /** * @param ImportJob $job * @param Tag $tag @@ -442,21 +239,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface return $job; } - /** - * @param ImportJob $job - * @param int $count - * - * @return ImportJob - */ - public function setTotalSteps(ImportJob $job, int $count): ImportJob - { - $status = $this->getExtendedStatus($job); - $status['steps'] = $count; - Log::debug(sprintf('Set total steps for job "%s" to %d', $job->key, $count)); - - return $this->setExtendedStatus($job, $status); - } - /** * @param ImportJob $job * @param array $transactions @@ -599,20 +381,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface return $job; } - /** - * Return import file content. - * - * @deprecated - * - * @param ImportJob $job - * - * @return string - */ - public function uploadFileContents(ImportJob $job): string - { - return $job->uploadFileContents(); - } - /** * @codeCoverageIgnore * diff --git a/app/Repositories/ImportJob/ImportJobRepositoryInterface.php b/app/Repositories/ImportJob/ImportJobRepositoryInterface.php index e10d79be85..3e8e6a7de9 100644 --- a/app/Repositories/ImportJob/ImportJobRepositoryInterface.php +++ b/app/Repositories/ImportJob/ImportJobRepositoryInterface.php @@ -35,15 +35,6 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; */ interface ImportJobRepositoryInterface { - /** - * @param ImportJob $job - * @param int $index - * @param string $error - * - * @return ImportJob - */ - public function addError(ImportJob $job, int $index, string $error): ImportJob; - /** * Add message to job. * @@ -54,31 +45,6 @@ interface ImportJobRepositoryInterface */ public function addErrorMessage(ImportJob $job, string $error): ImportJob; - /** - * @param ImportJob $job - * @param int $steps - * - * @return ImportJob - */ - public function addStepsDone(ImportJob $job, int $steps = null): ImportJob; - - /** - * @param ImportJob $job - * @param int $steps - * - * @return ImportJob - */ - public function addTotalSteps(ImportJob $job, int $steps = null): ImportJob; - - /** - * Return number of imported rows with this hash value. - * - * @param string $hash - * - * @return int - */ - public function countByHash(string $hash): int; - /** * @param string $importProvider * @@ -120,29 +86,6 @@ interface ImportJobRepositoryInterface */ public function getExtendedStatus(ImportJob $job): array; - /** - * @param ImportJob $job - * - * @return string - */ - public function getStatus(ImportJob $job): string; - - /** - * @param ImportJob $job - * @param UploadedFile $file - * - * @return bool - */ - public function processConfiguration(ImportJob $job, UploadedFile $file): bool; - - /** - * @param ImportJob $job - * @param null|UploadedFile $file - * - * @return bool - */ - public function processFile(ImportJob $job, ?UploadedFile $file): bool; - /** * @param ImportJob $job * @param array $configuration @@ -151,14 +94,6 @@ interface ImportJobRepositoryInterface */ public function setConfiguration(ImportJob $job, array $configuration): ImportJob; - /** - * @param ImportJob $job - * @param array $array - * - * @return ImportJob - */ - public function setExtendedStatus(ImportJob $job, array $array): ImportJob; - /** * @param ImportJob $job * @param string $stage @@ -175,14 +110,6 @@ interface ImportJobRepositoryInterface */ public function setStatus(ImportJob $job, string $status): ImportJob; - /** - * @param ImportJob $job - * @param int $steps - * - * @return ImportJob - */ - public function setStepsDone(ImportJob $job, int $steps): ImportJob; - /** * @param ImportJob $job * @param Tag $tag @@ -191,14 +118,6 @@ interface ImportJobRepositoryInterface */ public function setTag(ImportJob $job, Tag $tag): ImportJob; - /** - * @param ImportJob $job - * @param int $count - * - * @return ImportJob - */ - public function setTotalSteps(ImportJob $job, int $count): ImportJob; - /** * @param ImportJob $job * @param array $transactions @@ -243,12 +162,4 @@ interface ImportJobRepositoryInterface */ public function updateStatus(ImportJob $job, string $status): ImportJob; - /** - * Return import file content. - * - * @param ImportJob $job - * - * @return string - */ - public function uploadFileContents(ImportJob $job): string; } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 5c6a104a56..30882e0234 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -138,23 +138,6 @@ class JournalRepository implements JournalRepositoryInterface return true; } - /** - * @param int $journalId - * - * @return TransactionJournal - * @deprecated - */ - public function find(int $journalId): TransactionJournal - { - /** @var TransactionJournal $journal */ - $journal = $this->user->transactionJournals()->where('id', $journalId)->first(); - if (null === $journal) { - return new TransactionJournal; - } - - return $journal; - } - /** * Find a journal by its hash. * @@ -225,24 +208,6 @@ class JournalRepository implements JournalRepositoryInterface return $transaction; } - /** - * Get users first transaction journal. - * - * @deprecated - * @return TransactionJournal - */ - public function first(): TransactionJournal - { - /** @var TransactionJournal $entry */ - $entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); - - if (null === $entry) { - return new TransactionJournal; - } - - return $entry; - } - /** * Get users first transaction journal or NULL. * @@ -522,16 +487,6 @@ class JournalRepository implements JournalRepositoryInterface return $return; } - /** - * @param TransactionJournal $journal - * - * @return Note|null - */ - public function getNote(TransactionJournal $journal): ?Note - { - return $journal->notes()->first(); - } - /** * Return text of a note attached to journal, or NULL * @@ -698,27 +653,6 @@ class JournalRepository implements JournalRepositoryInterface } - /** - * Set meta field for journal that contains string. - * - * @param TransactionJournal $journal - * @param string $name - * @param string $value - */ - public function setMetaString(TransactionJournal $journal, string $name, string $value): void - { - /** @var TransactionJournalMetaFactory $factory */ - $factory = app(TransactionJournalMetaFactory::class); - $factory->updateOrCreate( - [ - 'data' => $value, - 'journal' => $journal, - 'name' => $name, - ] - ); - - } - /** * @param TransactionJournal $journal * @param int $order diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index 603685307b..4f2eccf58b 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -66,17 +66,6 @@ interface JournalRepositoryInterface */ public function destroy(TransactionJournal $journal): bool; - /** - * Find a specific journal. - * - * @param int $journalId - * - * @deprecated - * - * @return TransactionJournal - */ - public function find(int $journalId): TransactionJournal; - /** * Find a journal by its hash. * @@ -109,14 +98,6 @@ interface JournalRepositoryInterface */ public function findTransaction(int $transactionid): ?Transaction; - /** - * Get users very first transaction journal. - * - * @deprecated - * @return TransactionJournal - */ - public function first(): TransactionJournal; - /** * Get users very first transaction journal. * @@ -216,13 +197,6 @@ interface JournalRepositoryInterface */ public function getMetaField(TransactionJournal $journal, string $field): ?string; - /** - * @param TransactionJournal $journal - * - * @return Note|null - */ - public function getNote(TransactionJournal $journal): ?Note; - /** * Return text of a note attached to journal, or NULL * @@ -303,15 +277,6 @@ interface JournalRepositoryInterface */ public function setMetaDate(TransactionJournal $journal, string $name, Carbon $date): void; - /** - * Set meta field for journal that contains string. - * - * @param TransactionJournal $journal - * @param string $name - * @param string $value - */ - public function setMetaString(TransactionJournal $journal, string $name, string $value): void; - /** * @param TransactionJournal $journal * @param int $order diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index 0fa01718de..d0588e8b40 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -80,22 +80,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface return true; } - /** - * @param int $id - * - * @return LinkType - * @deprecated - */ - public function find(int $id): LinkType - { - $linkType = LinkType::find($id); - if (null === $linkType) { - return new LinkType; - } - - return $linkType; - } - /** * @param string|null $name * diff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php index a43ddaaefd..5d4a250614 100644 --- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php +++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php @@ -55,14 +55,6 @@ interface LinkTypeRepositoryInterface */ public function destroyLink(TransactionJournalLink $link): bool; - /** - * @param int $id - * - * @deprecated - * @return LinkType - */ - public function find(int $id): LinkType; - /** * Find link type by name. * diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 4ca0715831..a87f30a3b6 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -175,22 +175,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface return true; } - /** - * @param int $piggyBankid - * - * @deprecated - * @return PiggyBank - */ - public function find(int $piggyBankid): PiggyBank - { - $piggyBank = $this->user->piggyBanks()->where('piggy_banks.id', $piggyBankid)->first(['piggy_banks.*']); - if (null !== $piggyBank) { - return $piggyBank; - } - - return new PiggyBank(); - } - /** * Find by name or return NULL. * @@ -425,24 +409,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface return true; } - /** - * Set all piggy banks to order 0. - * - * @return bool - */ - public function reset(): bool - { - // split query to make it work in sqlite: - $set = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.id') - ->where('accounts.user_id', $this->user->id)->get(['piggy_banks.*']); - foreach ($set as $e) { - $e->order = 0; - $e->save(); - } - - return true; - } - /** * set id of piggy bank. * diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php index 4b4d7d062e..dd606c48ba 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php +++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php @@ -100,14 +100,6 @@ interface PiggyBankRepositoryInterface */ public function destroy(PiggyBank $piggyBank): bool; - /** - * @param int $piggyBankid - * - * @deprecated - * @return PiggyBank - */ - public function find(int $piggyBankid): PiggyBank; - /** * Find by name or return NULL. * @@ -208,13 +200,6 @@ interface PiggyBankRepositoryInterface */ public function removeAmount(PiggyBank $piggyBank, string $amount): bool; - /** - * Set all piggy banks to order 0. - * - * @return bool - */ - public function reset(): bool; - /** * Set specific piggy bank to specific order. * diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index fad8c7d9ea..02f79607aa 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -68,13 +68,13 @@ class RuleRepository implements RuleRepositoryInterface /** * @param int $ruleId * - * @return Rule + * @return Rule|null */ - public function find(int $ruleId): Rule + public function find(int $ruleId): ?Rule { $rule = $this->user->rules()->find($ruleId); if (null === $rule) { - return new Rule; + return null; } return $rule; diff --git a/app/Repositories/Rule/RuleRepositoryInterface.php b/app/Repositories/Rule/RuleRepositoryInterface.php index cefbf46a95..25a7ac7df4 100644 --- a/app/Repositories/Rule/RuleRepositoryInterface.php +++ b/app/Repositories/Rule/RuleRepositoryInterface.php @@ -50,9 +50,9 @@ interface RuleRepositoryInterface /** * @param int $ruleId * - * @return Rule + * @return Rule|null */ - public function find(int $ruleId): Rule; + public function find(int $ruleId): ?Rule; /** * Get all the users rules. diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index aeedeab01c..54cbf8ef31 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -77,13 +77,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface /** * @param int $ruleGroupId * - * @return RuleGroup + * @return RuleGroup|null */ - public function find(int $ruleGroupId): RuleGroup + public function find(int $ruleGroupId): ?RuleGroup { $group = $this->user->ruleGroups()->find($ruleGroupId); if (null === $group) { - return new RuleGroup; + return null; } return $group; diff --git a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php index 2082a78012..8bd103ed1a 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php +++ b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php @@ -47,9 +47,9 @@ interface RuleGroupRepositoryInterface /** * @param int $ruleGroupId * - * @return RuleGroup + * @return RuleGroup|null */ - public function find(int $ruleGroupId): RuleGroup; + public function find(int $ruleGroupId): ?RuleGroup; /** * Get all rule groups. diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index b494755695..d029ca559c 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -42,27 +42,6 @@ class TagRepository implements TagRepositoryInterface /** @var User */ private $user; - /** - * @param TransactionJournal $journal - * @param Tag $tag - * - * @return bool - */ - public function connect(TransactionJournal $journal, Tag $tag): bool - { - // Already connected: - if ($journal->tags()->find($tag->id)) { - Log::info(sprintf('Tag #%d is already connected to journal #%d.', $tag->id, $journal->id)); - - return false; - } - Log::debug(sprintf('Tag #%d connected', $tag->id)); - $journal->tags()->save($tag); - $journal->save(); - - return true; - } - /** * @return int */ @@ -177,16 +156,6 @@ class TagRepository implements TagRepositoryInterface return $tags; } - /** - * @param string $type - * - * @return Collection - */ - public function getByType(string $type): Collection - { - return $this->user->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get(); - } - /** * @param Tag $tag * @@ -267,32 +236,6 @@ class TagRepository implements TagRepositoryInterface return $tag; } - /** - * @param Tag $tag - * @param Carbon|null $start - * @param Carbon|null $end - * - * @return string - */ - public function sumOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string - { - /** @var JournalCollectorInterface $collector */ - $collector = app(JournalCollectorInterface::class); - - if (null !== $start && null !== $end) { - $collector->setRange($start, $end); - } - - $collector->setAllAssetAccounts()->setTag($tag); - $journals = $collector->getJournals(); - $sum = '0'; - foreach ($journals as $journal) { - $sum = bcadd($sum, app('steam')->positive((string)$journal->transaction_amount)); - } - - return $sum; - } - /** * @param Tag $tag * @param Carbon|null $start diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php index 3b6b7cd19a..07fd40f2e8 100644 --- a/app/Repositories/Tag/TagRepositoryInterface.php +++ b/app/Repositories/Tag/TagRepositoryInterface.php @@ -33,16 +33,6 @@ use Illuminate\Support\Collection; */ interface TagRepositoryInterface { - /** - * This method will connect a journal with a tag. - * - * @param TransactionJournal $journal - * @param Tag $tag - * - * @return bool - */ - public function connect(TransactionJournal $journal, Tag $tag): bool; - /** * @return int */ @@ -102,13 +92,6 @@ interface TagRepositoryInterface */ public function get(): Collection; - /** - * @param string $type - * - * @return Collection - */ - public function getByType(string $type): Collection; - /** * @param Tag $tag * @@ -153,15 +136,6 @@ interface TagRepositoryInterface */ public function store(array $data): Tag; - /** - * @param Tag $tag - * @param Carbon|null $start - * @param Carbon|null $end - * - * @return string - */ - public function sumOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): string; - /** * Calculates various amounts in tag. * diff --git a/app/Repositories/TransactionType/TransactionTypeRepository.php b/app/Repositories/TransactionType/TransactionTypeRepository.php deleted file mode 100644 index c01cc5dfd3..0000000000 --- a/app/Repositories/TransactionType/TransactionTypeRepository.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -declare(strict_types=1); - -namespace FireflyIII\Repositories\TransactionType; - -use FireflyIII\Models\TransactionType; - -/** - * Class TransactionTypeRepository - */ -class TransactionTypeRepository implements TransactionTypeRepositoryInterface -{ - /** - * Find a transaction type or return NULL. - * - * @param string $type - * - * @return TransactionType|null - */ - public function findByType(string $type): ?TransactionType - { - return TransactionType::where('type', ucfirst($type))->first(); - } -} diff --git a/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php b/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php deleted file mode 100644 index 0e84c6dbff..0000000000 --- a/app/Repositories/TransactionType/TransactionTypeRepositoryInterface.php +++ /dev/null @@ -1,43 +0,0 @@ -. - */ - -declare(strict_types=1); - -namespace FireflyIII\Repositories\TransactionType; - -use FireflyIII\Models\TransactionType; - -/** - * Interface TransactionTypeRepositoryInterface - * - */ -interface TransactionTypeRepositoryInterface -{ - /** - * Find a transaction type or return NULL. - * - * @param string $type - * - * @return TransactionType|null - */ - public function findByType(string $type): ?TransactionType; - -}