mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Various code clean up. [skip ci]
This commit is contained in:
@@ -36,6 +36,7 @@ class BillName extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Bill;
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ class BillName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($bill->id)) {
|
||||
Log::debug('Found bill by ID', ['id' => $bill->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $bill;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +59,7 @@ class BillName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($bill->id)) {
|
||||
Log::debug('Found bill by name ', ['id' => $bill->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $bill;
|
||||
}
|
||||
|
||||
@@ -66,7 +69,7 @@ class BillName extends BasicConverter implements ConverterInterface
|
||||
'name' => $value,
|
||||
'match' => $value,
|
||||
'amount_min' => 1,
|
||||
'user' => $this->user->id,
|
||||
'user' => $this->user->id,
|
||||
'amount_max' => 10,
|
||||
'date' => date('Ymd'),
|
||||
'repeat_freq' => 'monthly',
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Log;
|
||||
@@ -36,6 +35,7 @@ class BudgetId extends BasicConverter implements ConverterInterface
|
||||
|
||||
if ($value === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Budget;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ class BudgetId extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($budget->id)) {
|
||||
Log::debug('Found budget by ID ', ['id' => $budget->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $budget;
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Log;
|
||||
@@ -36,6 +35,7 @@ class BudgetName extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Budget;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class BudgetName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($budget->id)) {
|
||||
Log::debug('Found budget by ID', ['id' => $budget->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $budget;
|
||||
}
|
||||
}
|
||||
@@ -57,14 +58,15 @@ class BudgetName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($budget->id)) {
|
||||
Log::debug('Found budget by name ', ['id' => $budget->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $budget;
|
||||
}
|
||||
|
||||
// create new budget. Use a lot of made up values.
|
||||
$budget = $repository->store(
|
||||
[
|
||||
'name' => $value,
|
||||
'user' => $this->user->id,
|
||||
'name' => $value,
|
||||
'user' => $this->user->id,
|
||||
]
|
||||
);
|
||||
$this->setCertainty(100);
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Log;
|
||||
@@ -36,6 +35,7 @@ class CategoryId extends BasicConverter implements ConverterInterface
|
||||
|
||||
if ($value === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Category;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class CategoryId extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($category->id)) {
|
||||
Log::debug('Found category by ID', ['id' => $category->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +58,7 @@ class CategoryId extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($category->id)) {
|
||||
Log::debug('Found category by ID ', ['id' => $category->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Log;
|
||||
@@ -36,6 +35,7 @@ class CategoryName extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Category;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class CategoryName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($category->id)) {
|
||||
Log::debug('Found category by ID', ['id' => $category->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
@@ -57,13 +58,14 @@ class CategoryName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($category->id)) {
|
||||
Log::debug('Found category by name ', ['id' => $category->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
// create new category. Use a lot of made up values.
|
||||
$category = $repository->store(
|
||||
[
|
||||
'name' => $value,
|
||||
'name' => $value,
|
||||
'user' => $this->user->id,
|
||||
]
|
||||
);
|
||||
|
@@ -26,16 +26,16 @@ interface ConverterInterface
|
||||
*/
|
||||
public function convert($value);
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
*/
|
||||
public function setConfig(array $config);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCertainty(): int;
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
*/
|
||||
public function setConfig(array $config);
|
||||
|
||||
/**
|
||||
* @param bool $doMap
|
||||
*/
|
||||
|
@@ -41,6 +41,7 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by ID', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
@@ -50,6 +51,7 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by code', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
$currency = $repository->store(
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Log;
|
||||
@@ -36,6 +35,7 @@ class CurrencyId extends BasicConverter implements ConverterInterface
|
||||
|
||||
if ($value === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class CurrencyId extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by ID', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +58,7 @@ class CurrencyId extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by ID ', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
$this->setCertainty(0);
|
||||
|
@@ -35,6 +35,7 @@ class CurrencyName extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -47,6 +48,7 @@ class CurrencyName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by ID', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +58,7 @@ class CurrencyName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by name ', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,7 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new TransactionCurrency;
|
||||
}
|
||||
|
||||
@@ -47,6 +48,7 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by ID', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +58,7 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($currency->id)) {
|
||||
Log::debug('Found currency by symbol ', ['id' => $currency->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $currency;
|
||||
}
|
||||
|
||||
|
@@ -40,10 +40,12 @@ class Date extends BasicConverter implements ConverterInterface
|
||||
Log::info($e->getMessage());
|
||||
Log::info('Cannot convert this string using the given format.', ['value' => $value, 'format' => $this->config['date-format']]);
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Carbon;
|
||||
}
|
||||
Log::debug('Converted date', ['converted' => $date->toAtomString()]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -34,11 +33,13 @@ class INGDebetCredit extends BasicConverter implements ConverterInterface
|
||||
if ($value === 'Af') {
|
||||
Log::debug('Return -1');
|
||||
$this->setCertainty(100);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->setCertainty(100);
|
||||
Log::debug('Return 1');
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by ID', ['id' => $account->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Import\Converter;
|
||||
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use Log;
|
||||
@@ -37,6 +36,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by ID', ['id' => $account->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +60,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by number', ['id' => $account->id]);
|
||||
$this->setCertainty(50);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
@@ -79,6 +81,7 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
|
||||
'virtualBalance' => 0, 'accountNumber' => $value, 'active' => true]
|
||||
);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $account;
|
||||
|
||||
}
|
||||
|
@@ -77,4 +77,4 @@ class ImportProcedure
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -330,8 +330,8 @@ class ImportStorage
|
||||
{
|
||||
if ($entry->valid === false) {
|
||||
Log::warning(sprintf('Cannot import row %d, because the entry is not valid.', $index));
|
||||
$errors = join(', ', $entry->errors->all());
|
||||
$errorText = sprintf('Row #%d: ' . $errors, $index);
|
||||
$errors = join(', ', $entry->errors->all());
|
||||
$errorText = sprintf('Row #%d: ' . $errors, $index);
|
||||
$extendedStatus = $this->job->extended_status;
|
||||
$extendedStatus['errors'][] = $errorText;
|
||||
$this->job->extended_status = $extendedStatus;
|
||||
@@ -342,7 +342,7 @@ class ImportStorage
|
||||
$alreadyImported = $this->alreadyImported($entry->hash);
|
||||
if (!is_null($alreadyImported->id)) {
|
||||
Log::warning(sprintf('Cannot import row %d, because it has already been imported (journal #%d).', $index, $alreadyImported->id));
|
||||
$errorText = trans(
|
||||
$errorText = trans(
|
||||
'firefly.import_double',
|
||||
['row' => $index, 'link' => route('transactions.show', [$alreadyImported->id]), 'description' => $alreadyImported->description]
|
||||
);
|
||||
|
@@ -29,6 +29,8 @@ use Log;
|
||||
*/
|
||||
class ImportValidator
|
||||
{
|
||||
/** @var ImportJob */
|
||||
public $job;
|
||||
/** @var Account */
|
||||
protected $defaultImportAccount;
|
||||
/** @var Collection */
|
||||
@@ -36,19 +38,6 @@ class ImportValidator
|
||||
/** @var User */
|
||||
protected $user;
|
||||
|
||||
/** @var ImportJob */
|
||||
public $job;
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function setJob(ImportJob $job)
|
||||
{
|
||||
$this->job = $job;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ImportValidator constructor.
|
||||
*
|
||||
@@ -100,6 +89,14 @@ class ImportValidator
|
||||
$this->defaultImportAccount = $defaultImportAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ImportJob $job
|
||||
*/
|
||||
public function setJob(ImportJob $job)
|
||||
{
|
||||
$this->job = $job;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
|
@@ -10,6 +10,7 @@
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Importer;
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
@@ -29,13 +29,14 @@ class OpposingAccountIbans implements MapperInterface
|
||||
public function getMap(): array
|
||||
{
|
||||
/** @var AccountCrudInterface $crud */
|
||||
$crud = app(AccountCrudInterface::class);
|
||||
$set = $crud->getAccountsByType(
|
||||
$crud = app(AccountCrudInterface::class);
|
||||
$set = $crud->getAccountsByType(
|
||||
[
|
||||
AccountType::DEFAULT, AccountType::ASSET,
|
||||
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
||||
AccountType::REVENUE
|
||||
]);
|
||||
AccountType::REVENUE,
|
||||
]
|
||||
);
|
||||
$topList = [];
|
||||
$list = [];
|
||||
|
||||
|
@@ -34,8 +34,9 @@ class OpposingAccounts implements MapperInterface
|
||||
[
|
||||
AccountType::DEFAULT, AccountType::ASSET,
|
||||
AccountType::EXPENSE, AccountType::BENEFICIARY,
|
||||
AccountType::REVENUE
|
||||
]);
|
||||
AccountType::REVENUE,
|
||||
]
|
||||
);
|
||||
$list = [];
|
||||
|
||||
/** @var Account $account */
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Import\Setup;
|
||||
|
||||
use FireflyIII\Import\Role\Map;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\FileBag;
|
||||
@@ -46,14 +45,6 @@ interface SetupInterface
|
||||
*/
|
||||
public function getDataForSettings(): array;
|
||||
|
||||
/**
|
||||
* Store the settings filled in by the user, if applicable.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
*/
|
||||
public function storeSettings(Request $request);
|
||||
|
||||
/**
|
||||
* This method returns the name of the view that will be shown to the user to further configure
|
||||
* the import job.
|
||||
@@ -82,4 +73,12 @@ interface SetupInterface
|
||||
*
|
||||
*/
|
||||
public function setJob(ImportJob $job);
|
||||
|
||||
/**
|
||||
* Store the settings filled in by the user, if applicable.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
*/
|
||||
public function storeSettings(Request $request);
|
||||
}
|
||||
|
@@ -133,7 +133,7 @@ class AbnAmroDescription implements SpecificInterface
|
||||
break;
|
||||
case 'NAAM':
|
||||
$this->row[8] = $value;
|
||||
$name = $value;
|
||||
$name = $value;
|
||||
break;
|
||||
case 'KENMERK':
|
||||
$reference = $value;
|
||||
|
@@ -21,12 +21,12 @@ interface SpecificInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getName(): string;
|
||||
public static function getDescription(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription(): string;
|
||||
public static function getName(): string;
|
||||
|
||||
/**
|
||||
* @param array $row
|
||||
|
Reference in New Issue
Block a user