Make sure IBAN's have their spaces removed.

This commit is contained in:
James Cole
2022-01-03 06:34:42 +01:00
parent 0c53a8db66
commit 87ced85657
8 changed files with 115 additions and 2 deletions

View File

@@ -69,6 +69,7 @@ class CorrectDatabase extends Command
'firefly-iii:delete-empty-journals',
'firefly-iii:delete-empty-groups',
'firefly-iii:fix-account-types',
'firefly-iii:fix-ibans',
'firefly-iii:fix-account-order',
'firefly-iii:rename-meta-fields',
'firefly-iii:fix-ob-currencies',

View File

@@ -0,0 +1,50 @@
<?php
namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Models\Account;
use Illuminate\Console\Command;
/**
* Class FixIbans
*/
class FixIbans extends Command
{
/**
* The console command description.
*
* @var string
*/
protected $description = 'Removes spaces from IBANs';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:fix-ibans';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
$accounts = Account::whereNotNull('iban')->get();
/** @var Account $account */
foreach ($accounts as $account) {
$iban = $account->iban;
if (str_contains($iban, ' ')) {
$iban = app('steam')->filterSpaces((string)$account->iban);
if ('' !== $iban) {
$account->iban = $iban;
$account->save();
$this->line(sprintf('Removed spaces from IBAN of account #%d', $account->id));
}
}
}
return 0;
}
}

View File

@@ -98,6 +98,7 @@ class UpgradeDatabase extends Command
'firefly-iii:unify-group-accounts',
'firefly-iii:fix-transaction-types',
'firefly-iii:fix-frontpage-accounts',
'firefly-iii:fix-ibans',
// two report commands
'firefly-iii:report-empty-objects',