Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Remove references to bill scanning.
James Cole926c03986cf0
diff --git a/app/Handlers/Events/StoredJournalEventHandler.php b/app/Handlers/Events/StoredJournalEventHandler.phpindex 6cfb5ad600..43ca29745b 100644--- a/app/Handlers/Events/StoredJournalEventHandler.php+++ b/app/Handlers/Events/StoredJournalEventHandler.php@@ -28,7 +28,6 @@ use FireflyIII\Models\RuleGroup;use FireflyIII\Repositories\Journal\JournalRepositoryInterface as JRI;use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface as PRI;use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface as RGRI;-use FireflyIII\Support\Events\BillScanner;use FireflyIII\TransactionRules\Processor;/**@@ -91,18 +90,4 @@ class StoredJournalEventHandlerreturn true;}- /**- * This method calls a special bill scanner that will check if the stored journal is part of a bill.- *- * @param StoredTransactionJournal $storedJournalEvent- *- * @return bool- */- public function scanBills(StoredTransactionJournal $storedJournalEvent): bool- {- $journal = $storedJournalEvent->journal;- BillScanner::scan($journal);-- return true;- }}diff --git a/app/Handlers/Events/UpdatedJournalEventHandler.php b/app/Handlers/Events/UpdatedJournalEventHandler.phpindex 4b1ee5b3ff..ac06e95908 100644--- a/app/Handlers/Events/UpdatedJournalEventHandler.php+++ b/app/Handlers/Events/UpdatedJournalEventHandler.php@@ -26,7 +26,6 @@ use FireflyIII\Events\UpdatedTransactionJournal;use FireflyIII\Models\Rule;use FireflyIII\Models\RuleGroup;use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;-use FireflyIII\Support\Events\BillScanner;use FireflyIII\TransactionRules\Processor;/**@@ -80,18 +79,4 @@ class UpdatedJournalEventHandlerreturn true;}- /**- * This method calls a special bill scanner that will check if the updated journal is part of a bill.- *- * @param UpdatedTransactionJournal $updatedJournalEvent- *- * @return bool- */- public function scanBills(UpdatedTransactionJournal $updatedJournalEvent): bool- {- $journal = $updatedJournalEvent->journal;- BillScanner::scan($journal);-- return true;- }}diff --git a/app/Import/Configuration/BunqConfigurator.php b/app/Import/Configuration/BunqConfigurator.phpindex f1bb96fe60..6dad1ea2ad 100644--- a/app/Import/Configuration/BunqConfigurator.php+++ b/app/Import/Configuration/BunqConfigurator.php@@ -185,7 +185,6 @@ class BunqConfigurator implements ConfiguratorInterface'stage' => 'initial','auto-start' => true,'apply-rules' => true,- 'match-bills' => false,];$currentConfig = $this->repository->getConfiguration($job);$finalConfig = array_merge($defaultConfig, $currentConfig);diff --git a/app/Import/Configuration/FileConfigurator.php b/app/Import/Configuration/FileConfigurator.phpindex 0eae8d7d07..2151e0091c 100644--- a/app/Import/Configuration/FileConfigurator.php+++ b/app/Import/Configuration/FileConfigurator.php@@ -53,7 +53,6 @@ class FileConfigurator implements ConfiguratorInterface'file-type' => 'csv', // assume'has-config-file' => true,'apply-rules' => true,- 'match-bills' => false,'auto-start' => false,];/** @var ImportJob */diff --git a/app/Import/Configuration/SpectreConfigurator.php b/app/Import/Configuration/SpectreConfigurator.phpindex e09f7d17fb..a0b5a41915 100644--- a/app/Import/Configuration/SpectreConfigurator.php+++ b/app/Import/Configuration/SpectreConfigurator.php@@ -206,7 +206,6 @@ class SpectreConfigurator implements ConfiguratorInterface'accounts-mapped' => '','auto-start' => true,'apply-rules' => true,- 'match-bills' => false,];$currentConfig = $this->repository->getConfiguration($job);$finalConfig = array_merge($defaultConfig, $currentConfig);diff --git a/app/Import/Storage/ImportStorage.php b/app/Import/Storage/ImportStorage.phpindex aee0bdbc6a..0e75e0fce1 100644--- a/app/Import/Storage/ImportStorage.php+++ b/app/Import/Storage/ImportStorage.php@@ -28,7 +28,6 @@ use FireflyIII\Factory\TransactionJournalFactory;use FireflyIII\Import\Object\ImportJournal;use FireflyIII\Models\ImportJob;use FireflyIII\Models\TransactionType;-use FireflyIII\Repositories\Bill\BillRepositoryInterface;use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use Illuminate\Support\Collection;@@ -56,10 +55,6 @@ class ImportStoragepublic $errors;/** @var Collection */public $journals;- /** @var BillRepositoryInterface */- protected $billRepository;- /** @var Collection */- protected $bills;/** @var int */protected $defaultCurrencyId = 1;/** @var ImportJob */@@ -76,8 +71,6 @@ class ImportStorageprivate $dateFormat = 'Ymd';/** @var TransactionJournalFactory */private $factory;- /** @var bool */- private $matchBills = false;/** @var Collection */private $objects;/** @var int */@@ -122,20 +115,13 @@ class ImportStorage$this->job = $job;$this->transfers = $this->getTransfers();$this->applyRules = $config['apply-rules'] ?? false;- $this->matchBills = $config['match-bills'] ?? false;if (true === $this->applyRules) {Log::debug('applyRules seems to be true, get the rules.');$this->rules = $this->getRules();}- if (true === $this->matchBills) {- Log::debug('matchBills seems to be true, get the bills');- $this->bills = $this->getBills();- $this->billRepository = app(BillRepositoryInterface::class);- $this->billRepository->setUser($job->user);- }+Log::debug(sprintf('Value of apply rules is %s', var_export($this->applyRules, true)));- Log::debug(sprintf('Value of match bills is %s', var_export($this->matchBills, true)));}/**@@ -301,16 +287,6 @@ class ImportStorageLog::info('Will NOT apply rules to this journal.');}$this->addStep();-- // match bills if config calls for it.- if (true === $this->matchBills) {- Log::info('Will match bills.');- $this->matchBills($factoryJournal);- }-- if (!(true === $this->matchBills)) {- Log::info('Cannot match bills (yet), but do not have to.');- }$this->addStep();Log::info(diff --git a/app/Import/Storage/ImportSupport.php b/app/Import/Storage/ImportSupport.phpindex ddcb5fa1f6..f7544b516e 100644--- a/app/Import/Storage/ImportSupport.php+++ b/app/Import/Storage/ImportSupport.php@@ -33,7 +33,6 @@ use FireflyIII\Models\Rule;use FireflyIII\Models\TransactionJournal;use FireflyIII\Models\TransactionJournalMeta;use FireflyIII\Models\TransactionType;-use FireflyIII\Repositories\Bill\BillRepositoryInterface;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\TransactionRules\Processor;use Illuminate\Database\Query\JoinClause;@@ -45,10 +44,6 @@ use Log;*/trait ImportSupport{- /** @var BillRepositoryInterface */- protected $billRepository;- /** @var Collection */- protected $bills;/** @var int */protected $defaultCurrencyId = 1;/** @var ImportJob */@@ -84,41 +79,6 @@ trait ImportSupportreturn true;}- /**- * @param TransactionJournal $journal- *- * @return bool- */- protected function matchBills(TransactionJournal $journal): bool- {- if (null !== $journal->bill_id) {- Log::debug('Journal is already linked to a bill, will not scan.');-- return true;- }- if ($this->bills->count() > 0) {- $this->bills->each(- function (Bill $bill) use ($journal) {- Log::debug(sprintf('Going to match bill #%d to journal %d.', $bill->id, $journal->id));- $this->billRepository->scan($bill, $journal);- }- );- }-- return true;- }-- /**- * @return Collection- */- private function getBills(): Collection- {- $set = Bill::where('user_id', $this->job->user->id)->where('active', 1)->where('automatch', 1)->get(['bills.*']);- Log::debug(sprintf('Found %d user bills.', $set->count()));-- return $set;- }-/*** This method finds out what the import journal's currency should be. The account itself* is favoured (and usually it stops there). If no preference is found, the journal has a saydiff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex 14a2965912..75b5dc0921 100644--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -76,12 +76,10 @@ class EventServiceProvider extends ServiceProvider],// is a Transaction Journal related event.StoredTransactionJournal::class => [- 'FireflyIII\Handlers\Events\StoredJournalEventHandler@scanBills','FireflyIII\Handlers\Events\StoredJournalEventHandler@processRules',],// is a Transaction Journal related event.UpdatedTransactionJournal::class => [- 'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@scanBills','FireflyIII\Handlers\Events\UpdatedJournalEventHandler@processRules',],];diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 6401d05819..ddc7e0b358 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -541,52 +541,6 @@ class BillRepository implements BillRepositoryInterfacereturn $start;}- /**- * @param Bill $bill- * @param TransactionJournal $journal- *- * @deprecated- * @return bool- */- public function scan(Bill $bill, TransactionJournal $journal): bool- {- // Can only support withdrawals.- if (false === $journal->isWithdrawal()) {- return false;- }-- /** @var JournalRepositoryInterface $repos */- $repos = app(JournalRepositoryInterface::class);- $repos->setUser($this->user);-- $destinationAccounts = $repos->getJournalDestinationAccounts($journal);- $sourceAccounts = $repos->getJournalDestinationAccounts($journal);- $matches = explode(',', $bill->match);- $description = strtolower($journal->description) . ' ';- $description .= strtolower(implode(' ', $destinationAccounts->pluck('name')->toArray()));- $description .= strtolower(implode(' ', $sourceAccounts->pluck('name')->toArray()));-- $wordMatch = $this->doWordMatch($matches, $description);- $amountMatch = $this->doAmountMatch($repos->getJournalTotal($journal), $bill->amount_min, $bill->amount_max);-- // when both, update!- if ($wordMatch && $amountMatch) {- $journal->bill()->associate($bill);- $journal->save();-- return true;- }- if ($bill->id === $journal->bill_id) {- // if no match, but bill used to match, remove it:- $journal->bill_id = null;- $journal->save();-- return true;- }-- return false;- }-/*** @param User $user*/diff --git a/app/Repositories/Bill/BillRepositoryInterface.php b/app/Repositories/Bill/BillRepositoryInterface.phpindex d6cea63eea..bdf1f6f29a 100644--- a/app/Repositories/Bill/BillRepositoryInterface.php+++ b/app/Repositories/Bill/BillRepositoryInterface.php@@ -196,14 +196,6 @@ interface BillRepositoryInterface*/public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon;- /**- * @param Bill $bill- * @param TransactionJournal $journal- *- * @return bool- */- public function scan(Bill $bill, TransactionJournal $journal): bool;-/*** @param User $user*/diff --git a/app/Support/Events/BillScanner.php b/app/Support/Events/BillScanner.phpdeleted file mode 100644index f07d5d71b6..0000000000--- a/app/Support/Events/BillScanner.php+++ /dev/null@@ -1,47 +0,0 @@-<?php-/**- * BillScanner.php- * Copyright (c) 2017 [email protected]- *- * 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\Support\Events;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Bill\BillRepositoryInterface;--/**- * Class BillScanner.- */-class BillScanner-{- /**- * @param TransactionJournal $journal- */- public static function scan(TransactionJournal $journal)- {- /** @var BillRepositoryInterface $repository */- $repository = app(BillRepositoryInterface::class);- $list = $journal->user->bills()->where('active', 1)->where('automatch', 1)->get();-- /** @var \FireflyIII\Models\Bill $bill */- foreach ($list as $bill) {- $repository->scan($bill, $journal);- }- }-}diff --git a/app/Support/Import/Configuration/File/UploadConfig.php b/app/Support/Import/Configuration/File/UploadConfig.phpindex 8a0d6dbc07..750e7603d8 100644--- a/app/Support/Import/Configuration/File/UploadConfig.php+++ b/app/Support/Import/Configuration/File/UploadConfig.php@@ -123,7 +123,6 @@ class UploadConfig implements ConfigurationInterface$config['date-format'] = (string)$data['date_format'];$config['delimiter'] = 'tab' === $delimiter ? "\t" : $delimiter;$config['apply-rules'] = (int)($data['apply_rules'] ?? 0.0) === 1;- $config['match-bills'] = (int)($data['match_bills'] ?? 0.0) === 1;Log::debug('Entered import account.', ['id' => $importId]);diff --git a/resources/views/import/file/upload-config.twig b/resources/views/import/file/upload-config.twigindex 68f21d5872..c7bf64435d 100644--- a/resources/views/import/file/upload-config.twig+++ b/resources/views/import/file/upload-config.twig@@ -55,21 +55,6 @@</div></div></div>- <div class="form-group">- <label for="match_bills_label" class="col-sm-4 control-label">- {{ trans('import.file_match_bills_title') }}- </label>-- <div class="col-sm-8">- <div class="checkbox"><label>- {{ Form.checkbox('match_bills', '1',- job.configuration['match-bills'] == true, {'id': 'match_bills_label'}) }}- {{ trans('import.file_match_bills_description') }}- </label>- </div>- </div>- </div>-{% for type, specific in data.specifics %}<div class="form-group"><label for="{{ type }}_label" class="col-sm-4 control-label">