mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 20:55:31 +00:00
Moved find() method to new class.
This commit is contained in:
@@ -13,8 +13,8 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -39,8 +39,9 @@ class AccountId extends BasicConverter implements ConverterInterface
|
||||
|
||||
return new Account;
|
||||
}
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
Log::debug('Found account in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]);
|
||||
$account = $repository->find(intval($this->mapping[$value]));
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace FireflyIII\Import\Converter;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -42,8 +43,11 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
@@ -58,7 +62,7 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->findByIban($value, [AccountType::ASSET]);
|
||||
$account = $crud->findByIban($value, [AccountType::ASSET]);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by IBAN', ['id' => $account->id]);
|
||||
$this->setCertainty(50);
|
||||
@@ -67,7 +71,7 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
|
||||
$account = $repository->store(
|
||||
$account = $crud->store(
|
||||
['name' => 'Asset account with IBAN ' . $value, 'iban' => $value, 'user' => $this->user->id, 'accountType' => 'asset', 'virtualBalance' => 0,
|
||||
'active' => true, 'openingBalance' => 0]
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace FireflyIII\Import\Converter;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -42,8 +43,11 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
@@ -58,7 +62,7 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->findByName($value, [AccountType::ASSET]);
|
||||
$account = $crud->findByName($value, [AccountType::ASSET]);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found asset account by name', ['value' => $value, 'id' => $account->id]);
|
||||
|
||||
@@ -66,7 +70,7 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
|
||||
$account = $repository->store(
|
||||
$account = $crud->store(
|
||||
['name' => $value, 'iban' => null, 'openingBalance' => 0, 'user' => $this->user->id, 'accountType' => 'asset', 'virtualBalance' => 0,
|
||||
'active' => true]
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace FireflyIII\Import\Converter;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -40,8 +41,11 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
@@ -55,7 +59,7 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->findByAccountNumber($value, [AccountType::ASSET]);
|
||||
$account = $crud->findByAccountNumber($value, [AccountType::ASSET]);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by name', ['id' => $account->id]);
|
||||
$this->setCertainty(50);
|
||||
@@ -65,7 +69,7 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
|
||||
// try to find by the name we would give it:
|
||||
$accountName = 'Asset account with number ' . e($value);
|
||||
$account = $repository->findByName($accountName, [AccountType::ASSET]);
|
||||
$account = $crud->findByName($accountName, [AccountType::ASSET]);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by name', ['id' => $account->id]);
|
||||
$this->setCertainty(50);
|
||||
@@ -74,7 +78,7 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
|
||||
$account = $repository->store(
|
||||
$account = $crud->store(
|
||||
['name' => $accountName, 'openingBalance' => 0, 'iban' => null, 'user' => $this->user->id,
|
||||
'accountType' => 'asset',
|
||||
'virtualBalance' => 0, 'accountNumber' => $value, 'active' => true]
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -41,8 +42,11 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
@@ -57,7 +61,7 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->findByIban($value, []);
|
||||
$account = $crud->findByIban($value, []);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by IBAN', ['id' => $account->id]);
|
||||
Log::info(
|
||||
@@ -69,7 +73,7 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
return $account;
|
||||
}
|
||||
|
||||
$account = $repository->store(
|
||||
$account = $crud->store(
|
||||
['name' => $value, 'iban' => $value, 'user' => $this->user->id, 'accountType' => 'import', 'virtualBalance' => 0, 'active' => true,
|
||||
'openingBalance' => 0]
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -41,8 +42,11 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
@@ -57,7 +61,7 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->findByName($value, []);
|
||||
$account = $crud->findByName($value, []);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found opposing account by name', ['id' => $account->id]);
|
||||
Log::info(
|
||||
@@ -69,7 +73,7 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
return $account;
|
||||
}
|
||||
|
||||
$account = $repository->store(
|
||||
$account = $crud->store(
|
||||
['name' => $value, 'iban' => null, 'user' => $this->user->id, 'accountType' => 'import', 'virtualBalance' => 0, 'active' => true,
|
||||
'openingBalance' => 0,
|
||||
]
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace FireflyIII\Import\Converter;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -42,8 +43,11 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/** @var AccountCrudInterface $repository */
|
||||
$repository = app(AccountCrudInterface::class, [$this->user]);
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class, [$this->user]);
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class, [$this->user]);
|
||||
|
||||
|
||||
if (isset($this->mapping[$value])) {
|
||||
@@ -58,7 +62,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// not mapped? Still try to find it first:
|
||||
$account = $repository->findByAccountNumber($value, []);
|
||||
$account = $crud->findByAccountNumber($value, []);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by number', ['id' => $account->id]);
|
||||
$this->setCertainty(50);
|
||||
@@ -68,7 +72,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
|
||||
// try to find by the name we would give it:
|
||||
$accountName = 'Import account with number ' . e($value);
|
||||
$account = $repository->findByName($accountName, [AccountType::IMPORT]);
|
||||
$account = $crud->findByName($accountName, [AccountType::IMPORT]);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by name', ['id' => $account->id]);
|
||||
$this->setCertainty(50);
|
||||
@@ -77,7 +81,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
|
||||
$account = $repository->store(
|
||||
$account = $crud->store(
|
||||
['name' => $accountName, 'openingBalance' => 0, 'iban' => null, 'user' => $this->user->id,
|
||||
'accountType' => 'import',
|
||||
'virtualBalance' => 0, 'accountNumber' => $value, 'active' => true]
|
||||
|
||||
Reference in New Issue
Block a user