Code cleanup that (hopefully) matches style CI

This commit is contained in:
James Cole 2020-03-17 15:03:08 +01:00
parent 24129ab69c
commit 91c067ac9f
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
48 changed files with 182 additions and 131 deletions

View File

@ -26,6 +26,7 @@ use Log;
/**
* Class Amount.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -46,7 +47,7 @@ class Amount implements ConverterInterface
}
Log::debug(sprintf('Start with amount "%s"', $value));
$original = $value;
$value = $this->stripAmount((string)$value);
$value = $this->stripAmount((string) $value);
$decimal = null;
if ($this->decimalIsDot($value)) {
@ -219,7 +220,7 @@ class Amount implements ConverterInterface
$value = substr($value, 2);
}
// have to strip the € because apparantly the Postbank (DE) thinks "1.000,00 €" is a normal way to format a number.
$value = trim((string)str_replace(['€'], '', $value));
$value = trim((string) str_replace(['€'], '', $value));
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
$len = strlen($str);
if ('(' === $str[0] && ')' === $str[$len - 1]) {

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/**
* Class AmountCredit
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/**
* Class AmountDebit
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/**
* Class AmountNegated
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -29,6 +29,7 @@ use Log;
/**
*
* Class BankDebitCredit
*
* @deprecated
* @codeCoverageIgnore
*/
@ -38,9 +39,10 @@ class BankDebitCredit implements ConverterInterface
/**
* Convert a value.
*
* @param $value
*
* @return mixed
*
* @param $value
*/
public function convert($value): int
{

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/**
* Interface ConverterInterface.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -32,9 +33,10 @@ interface ConverterInterface
/**
* Convert a value.
*
* @param $value
*
* @return mixed
*
* @param $value
*/
public function convert($value);
}

View File

@ -34,6 +34,7 @@ use Log;
/**
* Class BunqJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@ -107,8 +108,8 @@ class BunqJobConfiguration implements JobConfigurationInterface
/**
* Get correct handler.
*
* @return BunqJobConfigurationInterface
* @throws FireflyException
* @return BunqJobConfigurationInterface
*/
private function getHandler(): BunqJobConfigurationInterface
{

View File

@ -29,6 +29,7 @@ use Illuminate\Support\MessageBag;
/**
* Class FakeJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@ -78,7 +79,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
$artist = strtolower($data['artist'] ?? '');
$song = strtolower($data['song'] ?? '');
$album = strtolower($data['album'] ?? '');
$applyRules = isset($data['apply_rules']) ? 1 === (int)$data['apply_rules'] : null;
$applyRules = isset($data['apply_rules']) ? 1 === (int) $data['apply_rules'] : null;
$configuration = $this->importJob->configuration;
if ('david bowie' === $artist) {
// store artist
@ -118,8 +119,8 @@ class FakeJobConfiguration implements JobConfigurationInterface
{
return [
'rulesOptions' => [
1 => (string)trans('firefly.yes'),
0 => (string)trans('firefly.no'),
1 => (string) trans('firefly.yes'),
0 => (string) trans('firefly.no'),
],
];
}

View File

@ -37,6 +37,7 @@ use Illuminate\Support\MessageBag;
/**
* Class FileJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@ -63,8 +64,8 @@ class FileJobConfiguration implements JobConfigurationInterface
*
* @param array $data
*
* @return MessageBag
* @throws FireflyException
* @return MessageBag
*/
public function configureJob(array $data): MessageBag
{
@ -91,9 +92,9 @@ class FileJobConfiguration implements JobConfigurationInterface
/**
* Returns the view of the next step in the job configuration.
*
* @throws FireflyException
* @return string
*
*@throws FireflyException
*/
public function getNextView(): string
{
@ -130,9 +131,9 @@ class FileJobConfiguration implements JobConfigurationInterface
/**
* Get the configuration handler for this specific stage.
*
* @return FileConfigurationInterface
* @throws FireflyException
*
* @return FileConfigurationInterface
*/
private function getConfigurationObject(): FileConfigurationInterface
{

View File

@ -26,6 +26,7 @@ namespace FireflyIII\Import\JobConfiguration;
/**
*
* Class FinTSConfigurationSteps
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -32,6 +32,7 @@ use Illuminate\Support\MessageBag;
/**
*
* Class FinTSJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@ -56,8 +57,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
*
* @param array $data
*
* @return MessageBag
* @throws FireflyException
* @return MessageBag
*/
public function configureJob(array $data): MessageBag
{
@ -67,8 +68,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
/**
* Return the data required for the next step in the job configuration.
*
* @return array
* @throws FireflyException
* @return array
*/
public function getNextData(): array
{
@ -78,8 +79,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
/**
* Returns the view of the next step in the job configuration.
*
* @return string
* @throws FireflyException
* @return string
*/
public function getNextView(): string
{
@ -108,8 +109,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
/**
* Get the configuration handler for this specific stage.
*
* @return FinTSConfigurationInterface
* @throws FireflyException
* @return FinTSConfigurationInterface
*/
private function getConfigurationObject(): FinTSConfigurationInterface
{

View File

@ -27,6 +27,7 @@ use Illuminate\Support\MessageBag;
/**
* Interface JobConfigurationInterface.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -37,6 +37,7 @@ use Log;
/**
* Class SpectreJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@ -110,9 +111,9 @@ class SpectreJobConfiguration implements JobConfigurationInterface
/**
* Get correct handler.
*
* @return SpectreJobConfigurationInterface
* @throws FireflyException
*
* @return SpectreJobConfigurationInterface
*/
private function getHandler(): SpectreJobConfigurationInterface
{

View File

@ -35,6 +35,7 @@ use Log;
/**
* Class YnabJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@ -108,9 +109,9 @@ class YnabJobConfiguration implements JobConfigurationInterface
/**
* Get correct handler.
*
* @return YnabJobConfigurationInterface
* @throws FireflyException
*
* @return YnabJobConfigurationInterface
*/
private function getHandler(): YnabJobConfigurationInterface
{

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AssetAccounts.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -54,7 +55,7 @@ class AssetAccountIbans implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
$iban = $account->iban ?? '';
$accountId = (int)$account->id;
$accountId = (int) $account->id;
if ('' !== $iban) {
$name = $account->iban . ' (' . $account->name . ')';
@ -77,7 +78,7 @@ class AssetAccountIbans implements MapperInterface
/** @noinspection AdditionOperationOnArraysInspection */
$list = $topList + $list;
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AssetAccounts.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -49,7 +50,7 @@ class AssetAccounts implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
$accountId = (int)$account->id;
$accountId = (int) $account->id;
$name = $account->name;
$iban = $account->iban ?? '';
if ('' !== $iban) {
@ -64,7 +65,7 @@ class AssetAccounts implements MapperInterface
$list[$accountId] = $name;
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
/**
* Class Bills.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -46,11 +47,11 @@ class Bills implements MapperInterface
/** @var Bill $bill */
foreach ($result as $bill) {
$billId = (int)$bill->id;
$billId = (int) $bill->id;
$list[$billId] = $bill->name;
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
/**
* Class Budgets.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -46,11 +47,11 @@ class Budgets implements MapperInterface
/** @var Budget $budget */
foreach ($result as $budget) {
$budgetId = (int)$budget->id;
$budgetId = (int) $budget->id;
$list[$budgetId] = $budget->name;
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
/**
* Class Categories.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -46,11 +47,11 @@ class Categories implements MapperInterface
/** @var Category $category */
foreach ($result as $category) {
$categoryId = (int)$category->id;
$categoryId = (int) $category->id;
$list[$categoryId] = $category->name;
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Mapper;
/**
* Interface MapperInterface.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccounts.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -56,7 +57,7 @@ class OpposingAccountIbans implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
$iban = $account->iban ?? '';
$accountId = (int)$account->id;
$accountId = (int) $account->id;
if ('' !== $iban) {
$name = $account->iban . ' (' . $account->name . ')';
@ -80,7 +81,7 @@ class OpposingAccountIbans implements MapperInterface
/** @noinspection AdditionOperationOnArraysInspection */
$list = $topList + $list;
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccounts.
*
* @deprecated
* @codeCoverageIgnore
*
@ -55,7 +56,7 @@ class OpposingAccounts implements MapperInterface
/** @var Account $account */
foreach ($set as $account) {
$accountId = (int)$account->id;
$accountId = (int) $account->id;
$name = $account->name;
$iban = $account->iban ?? '';
if ('' !== $iban) {
@ -68,7 +69,7 @@ class OpposingAccounts implements MapperInterface
$list[$accountId] = $name;
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
/**
* Class Tags.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -46,11 +47,11 @@ class Tags implements MapperInterface
/** @var Tag $tag */
foreach ($result as $tag) {
$tagId = (int)$tag->id;
$tagId = (int) $tag->id;
$list[$tagId] = $tag->tag;
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -26,6 +26,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/**
* Class TransactionCurrencies.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -43,12 +44,12 @@ class TransactionCurrencies implements MapperInterface
$currencies = $repository->get();
$list = [];
foreach ($currencies as $currency) {
$currencyId = (int)$currency->id;
$currencyId = (int) $currency->id;
$list[$currencyId] = $currency->name . ' (' . $currency->code . ')';
}
asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list;
$list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list;
}

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\MapperPreProcess;
/**
* Interface PreProcessorInterface.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\MapperPreProcess;
/**
* Class TagsComma.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\MapperPreProcess;
/**
* Class TagsSpace.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -33,6 +33,7 @@ use Log;
/**
* This class contains all the routines necessary to connect to Bunq.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -82,7 +83,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (!$this->hasExternalIP()) {
/** @var IPRetrievalInterface $service */
$service = app(IPRetrievalInterface::class);
$externalIP = (string)$service->getIP();
$externalIP = (string) $service->getIP();
}
return ['api_key' => $key, 'external_ip' => $externalIP];
@ -190,7 +191,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (null === $apiContext) {
return false;
}
if ('' === (string)$apiContext->data) {
if ('' === (string) $apiContext->data) {
return false;
}
@ -208,7 +209,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (null === $apiKey) {
return false;
}
if ('' === (string)$apiKey->data) {
if ('' === (string) $apiKey->data) {
return false;
}
@ -226,7 +227,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (null === $externalIP) {
return false;
}
if ('' === (string)$externalIP->data) {
if ('' === (string) $externalIP->data) {
return false;
}

View File

@ -25,11 +25,13 @@ namespace FireflyIII\Import\Prerequisites;
use FireflyIII\User;
use Illuminate\Support\MessageBag;
use Log;
use function request;
/**
* This class contains all the routines necessary for the fake import provider.
*
* Class FakePrerequisites
*
* @deprecated
* @codeCoverageIgnore
*/
@ -70,9 +72,9 @@ class FakePrerequisites implements PrerequisitesInterface
if ($this->hasApiKey()) {
$apiKey = app('preferences')->getForUser($this->user, 'fake_api_key', null)->data;
}
$oldKey = (string)\request()->old('api_key');
$oldKey = (string) request()->old('api_key');
if ('' !== $oldKey) {
$apiKey = \request()->old('api_key'); // @codeCoverageIgnore
$apiKey = request()->old('api_key'); // @codeCoverageIgnore
}
return ['api_key' => $apiKey];
@ -135,7 +137,7 @@ class FakePrerequisites implements PrerequisitesInterface
if (null === $apiKey->data) {
return false;
}
if (32 === strlen((string)$apiKey->data)) {
if (32 === strlen((string) $apiKey->data)) {
return true;
}

View File

@ -45,6 +45,7 @@ class FilePrerequisites implements PrerequisitesInterface
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/**
* Returns view name that allows user to fill in prerequisites.
*

View File

@ -27,6 +27,7 @@ use Illuminate\Support\MessageBag;
/**
* Interface PrerequisitesInterface
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -29,6 +29,7 @@ use Log;
/**
* This class contains all the routines necessary to connect to Spectre.
*
* @deprecated
* @codeCoverageIgnore
*/
@ -178,7 +179,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
if (null === $appId) {
return false;
}
if ('' === (string)$appId->data) {
if ('' === (string) $appId->data) {
return false;
}
@ -196,7 +197,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
if (null === $secret) {
return false;
}
if ('' === (string)$secret->data) {
if ('' === (string) $secret->data) {
return false;
}

View File

@ -29,6 +29,7 @@ use Log;
/**
* Class YnabPrerequisites
*
* @deprecated
* @codeCoverageIgnore
*/
@ -131,7 +132,7 @@ class YnabPrerequisites implements PrerequisitesInterface
if (null === $clientId) {
return false;
}
if ('' === (string)$clientId->data) {
if ('' === (string) $clientId->data) {
return false;
}
@ -149,7 +150,7 @@ class YnabPrerequisites implements PrerequisitesInterface
if (null === $clientSecret) {
return false;
}
if ('' === (string)$clientSecret->data) {
if ('' === (string) $clientSecret->data) {
return false;
}

View File

@ -32,6 +32,7 @@ use Log;
/**
* Class BunqRoutine
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -33,6 +33,7 @@ use Log;
/**
* Class FakeRoutine
*
* @deprecated
* @codeCoverageIgnore
*/
@ -51,9 +52,9 @@ class FakeRoutine implements RoutineInterface
* "ahoy": will log some nonsense and then drop job into status:"need_job_config" to force it back to the job config routine.
* "final": will do some logging, sleep for 10 seconds and then finish. Generates 5 random transactions.
*
* @return void
* @throws FireflyException
*
* @return void
*/
public function run(): void
{

View File

@ -30,6 +30,7 @@ use Log;
/**
* Class FileRoutine
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -33,6 +33,7 @@ use Illuminate\Support\Facades\Log;
/**
*
* Class FinTSRoutine
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -27,6 +27,7 @@ use FireflyIII\Models\ImportJob;
/**
* Interface RoutineInterface
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -32,6 +32,7 @@ use Log;
/**
* Class SpectreRoutine
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -34,6 +34,7 @@ use Log;
/**
* Class YnabRoutine
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class AbnAmroDescription.
*
* @deprecated
* @codeCoverageIgnore
*
@ -81,7 +82,7 @@ class AbnAmroDescription implements SpecificInterface
// If the description could not be parsed, specify an unknown opposing
// account, as an opposing account is required
if (!$parsed) {
$this->row[8] = (string)trans('firefly.unknown'); // opposing-account-name
$this->row[8] = (string) trans('firefly.unknown'); // opposing-account-name
}
return $this->row;

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class Belfius.
*
* @deprecated
* @codeCoverageIgnore
*
@ -56,19 +57,6 @@ class Belfius implements SpecificInterface
return 'import.specific_belfius_name';
}
/**
* Run the fix.
*
* @param array $row
*
* @return array
*
*/
public function run(array $row): array
{
return Belfius::processRecurringTransactionDescription($row);
}
/**
* Fixes the description for outgoing recurring transactions so doubles can be detected when the equivalent incoming
* transaction is imported for another bank account.
@ -82,7 +70,7 @@ class Belfius implements SpecificInterface
}
$opposingAccountName = $row[5];
$description = $row[14];
$description = $row[14];
preg_match('/DOORLOPENDE OPDRACHT.*\s+' . preg_quote($opposingAccountName, '/') . '\s+(.+)\s+REF.\s*:/', $description, $matches);
@ -92,4 +80,17 @@ class Belfius implements SpecificInterface
return $row;
}
/**
* Run the fix.
*
* @param array $row
*
* @return array
*
*/
public function run(array $row): array
{
return Belfius::processRecurringTransactionDescription($row);
}
}

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class IngBelgium.
*
* @deprecated
* @codeCoverageIgnore
*
@ -55,33 +56,26 @@ class IngBelgium implements SpecificInterface
}
/**
* Run the specific code.
*
* @param array $row
*
* @return array
* Gets the description from the transaction details and makes sure structured descriptions are in the
* "+++090/9337/55493+++" format.
*
* @return string the description
*/
public function run(array $row): array
protected static function description(string $transactionDetails): string
{
return IngBelgium::processTransactionDetails($row);
$description = IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/Mededeling:\s*(.+)$/');
return IngBelgium::convertStructuredDescriptionToProperFormat($description);
}
/**
* Gets the description and opposing account information (IBAN and name) from the transaction details and adds
* them to the row of data.
* Gets the opposing account's IBAN from the transaction details.
*
* @return array the row containing the description and opposing account's IBAN
* @return string the opposing account's IBAN
*/
protected static function processTransactionDetails(array $row): array
protected static function opposingAccountIban(string $transactionDetails): string
{
if(isset($row[9])) {
$transactionDetails = $row[9];
$row[11] = IngBelgium::opposingAccountName($transactionDetails);
$row[12] = IngBelgium::opposingAccountIban($transactionDetails);
$row[13] = IngBelgium::description($transactionDetails);
}
return $row;
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/IBAN:\s*(.+?)(?=\s+)/');
}
/**
@ -96,39 +90,36 @@ class IngBelgium implements SpecificInterface
}
/**
* Gets the opposing account's IBAN from the transaction details.
* Gets the description and opposing account information (IBAN and name) from the transaction details and adds
* them to the row of data.
*
* @return string the opposing account's IBAN
* @return array the row containing the description and opposing account's IBAN
*/
protected static function opposingAccountIban(string $transactionDetails): string
protected static function processTransactionDetails(array $row): array
{
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/IBAN:\s*(.+?)(?=\s+)/');
}
if (isset($row[9])) {
$transactionDetails = $row[9];
$row[11] = IngBelgium::opposingAccountName($transactionDetails);
$row[12] = IngBelgium::opposingAccountIban($transactionDetails);
$row[13] = IngBelgium::description($transactionDetails);
}
/**
* Gets the description from the transaction details and makes sure structured descriptions are in the
* "+++090/9337/55493+++" format.
*
* @return string the description
*/
protected static function description(string $transactionDetails): string
{
$description = IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/Mededeling:\s*(.+)$/');
return IngBelgium::convertStructuredDescriptionToProperFormat($description);
return $row;
}
private static function convertStructuredDescriptionToProperFormat(string $description): string
{
preg_match('/^\*\*\*(\d{3}\/\d{4}\/\d{5})\*\*\*$/', $description, $matches);
if(isset($matches[1])) {
if (isset($matches[1])) {
return '+++' . $matches[1] . '+++';
}
return $description;
}
private static function parseInformationFromTransactionDetails(string $transactionDetails, string $regex): string
{
if(isset($transactionDetails)) {
if (isset($transactionDetails)) {
preg_match($regex, $transactionDetails, $matches);
if (isset($matches[1])) {
return trim($matches[1]);
@ -137,4 +128,17 @@ class IngBelgium implements SpecificInterface
return '';
}
/**
* Run the specific code.
*
* @param array $row
*
* @return array
*
*/
public function run(array $row): array
{
return IngBelgium::processTransactionDetails($row);
}
}

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class IngDescription.
*
* @deprecated
* @codeCoverageIgnore
*
@ -106,11 +107,14 @@ class IngDescription implements SpecificInterface
}
/**
* Remove "Omschrijving" (and NOT its value) from the description.
* Move "Valutadatum" from the description to new column.
*/
protected function removeIngDescription(): void
protected function moveValutadatumDescription(): void
{
$this->row[8] = preg_replace('/Omschrijving: /', '', $this->row[8]);
$matches = [];
preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches);
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
}
/**
@ -123,6 +127,14 @@ class IngDescription implements SpecificInterface
$this->row[8] = preg_replace('/\sIBAN:\s' . $this->row[3] . '/', '', $this->row[8]);
}
/**
* Remove "Omschrijving" (and NOT its value) from the description.
*/
protected function removeIngDescription(): void
{
$this->row[8] = preg_replace('/Omschrijving: /', '', $this->row[8]);
}
/**
* Remove "Naam" (and its value) from the description.
*/
@ -131,31 +143,20 @@ class IngDescription implements SpecificInterface
$this->row[8] = preg_replace('/Naam:.*?([a-zA-Z\/]+:)/', '$1', $this->row[8]);
}
/**
* Move "Valutadatum" from the description to new column.
*/
protected function moveValutadatumDescription(): void
{
$matches = array();
preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches);
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
}
/**
* Move savings account number to column 1 and name to column 3.
*/
private function MoveSavingsAccount(): void
{
$matches = array();
if ('' === (string)$this->row[3]) {
$matches = [];
if ('' === (string) $this->row[3]) {
if (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[8], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]);
$matches[3] = sprintf("%010d", $matches[3]);
$this->row[1] = $matches[2]; // Savings account name
$this->row[3] = $matches[3]; // Savings account number
$this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([0-9]+)/', '', $this->row[8]); // Remove the savings account content from description
} elseif (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[1], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]);
$matches[3] = sprintf("%010d", $matches[3]);
$this->row[1] = $matches[2]; // Savings account name
$this->row[3] = $matches[3]; // Savings account number
}

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class PresidentsChoice.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class SnsDescription.
*
* @codeCoverageIgnore
* @deprecated
*/

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Interface SpecificInterface.
*
* @codeCoverageIgnore
* @deprecated
*/

View File

@ -32,17 +32,14 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\TransactionRules\Engine\RuleEngine;
use FireflyIII\TransactionRules\Processor;
use Illuminate\Database\QueryException;
use Illuminate\Support\Collection;
use Log;
@ -51,6 +48,7 @@ use Log;
* Creates new transactions based on arrays.
*
* Class ImportArrayStorage
*
* @codeCoverageIgnore
* @deprecated
*
@ -107,8 +105,8 @@ class ImportArrayStorage
* - Link to tag
* - Run rules (if set to)
*
* @return Collection
* @throws FireflyException
* @return Collection
*/
public function store(): Collection
{
@ -133,7 +131,7 @@ class ImportArrayStorage
app('preferences')->mark();
// email about this:
event(new RequestedReportOnJournals((int)$this->importJob->user_id, $collection));
event(new RequestedReportOnJournals((int) $this->importJob->user_id, $collection));
return $collection;
}
@ -218,7 +216,7 @@ class ImportArrayStorage
$hash = $this->getHash($transaction);
$existingId = $this->hashExists($hash);
if (null !== $existingId) {
$message = (string)trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]);
$message = (string) trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]);
$this->logDuplicateObject($transaction, $existingId);
$this->repository->addErrorMessage($this->importJob, $message);
@ -227,7 +225,7 @@ class ImportArrayStorage
// do transfer detection:
if ($this->checkForTransfers && $this->transferExists($transaction)) {
$message = (string)trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]);
$message = (string) trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]);
$this->logDuplicateTransfer($transaction);
$this->repository->addErrorMessage($this->importJob, $message);
@ -321,7 +319,7 @@ class ImportArrayStorage
}
Log::info(sprintf('Found a transaction journal with an existing hash: %s', $hash));
return (int)$entry->transaction_journal_id;
return (int) $entry->transaction_journal_id;
}
/**
@ -338,7 +336,7 @@ class ImportArrayStorage
$repository = app(TagRepositoryInterface::class);
$repository->setUser($this->importJob->user);
$data = [
'tag' => (string)trans('import.import_with_key', ['key' => $this->importJob->key]),
'tag' => (string) trans('import.import_with_key', ['key' => $this->importJob->key]),
'date' => new Carbon,
'description' => null,
'latitude' => null,
@ -475,9 +473,9 @@ class ImportArrayStorage
/**
* Store array as journals.
*
* @return Collection
* @throws FireflyException
*
* @return Collection
*/
private function storeGroupArray(): Collection
{
@ -531,21 +529,21 @@ class ImportArrayStorage
// get the amount:
/** @noinspection UnnecessaryCastingInspection */
$amount = (string)($transaction['amount'] ?? '0');
$amount = (string) ($transaction['amount'] ?? '0');
if (bccomp($amount, '0') === -1) {
$amount = bcmul($amount, '-1'); // @codeCoverageIgnore
}
// get the description:
//$description = '' === (string)$transaction['description'] ? $transaction['description'] : $transaction['description'];
$description = (string)$transaction['description'];
$description = (string) $transaction['description'];
// get the source and destination ID's:
$transactionSourceIDs = [(int)$transaction['source_id'], (int)$transaction['destination_id']];
$transactionSourceIDs = [(int) $transaction['source_id'], (int) $transaction['destination_id']];
sort($transactionSourceIDs);
// get the source and destination names:
$transactionSourceNames = [(string)$transaction['source_name'], (string)$transaction['destination_name']];
$transactionSourceNames = [(string) $transaction['source_name'], (string) $transaction['destination_name']];
sort($transactionSourceNames);
// then loop all transfers:
@ -587,7 +585,7 @@ class ImportArrayStorage
Log::debug(sprintf('Comparison is a hit! (%s)', $hits));
// compare source and destination id's
$transferSourceIDs = [(int)$transfer['source_account_id'], (int)$transfer['destination_account_id']];
$transferSourceIDs = [(int) $transfer['source_account_id'], (int) $transfer['destination_account_id']];
sort($transferSourceIDs);
/** @noinspection DisconnectedForeachInstructionInspection */
Log::debug('Comparing current transaction source+dest IDs', $transactionSourceIDs);
@ -602,7 +600,7 @@ class ImportArrayStorage
unset($transferSourceIDs);
// compare source and destination names
$transferSource = [(string)($transfer['source_account_name'] ?? ''), (string)($transfer['destination_account_name'] ?? '')];
$transferSource = [(string) ($transfer['source_account_name'] ?? ''), (string) ($transfer['destination_account_name'] ?? '')];
sort($transferSource);
/** @noinspection DisconnectedForeachInstructionInspection */
Log::debug('Comparing current transaction source+dest names', $transactionSourceNames);