mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Remove references to bill scanning.
This commit is contained in:
@@ -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 ImportStorage
|
||||
public $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 ImportStorage
|
||||
private $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 ImportStorage
|
||||
Log::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(
|
||||
|
@@ -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 ImportSupport
|
||||
return 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 say
|
||||
|
Reference in New Issue
Block a user