Remove spaces from account numbers.

This commit is contained in:
James Cole
2025-05-29 22:04:42 +02:00
parent 08e2c1684f
commit 7e9c5a668f
2 changed files with 19 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Factory;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
use FireflyIII\Support\Facades\Steam;
/**
* Class AccountMetaFactory
@@ -41,11 +42,16 @@ class AccountMetaFactory
$entry = $account->accountMeta()->where('name', $field)->first();
// must not be an empty string:
if ('' !== $value) {
if('account_number' === $field) {
$value = Steam::filterSpaces($value);
$value = trim(str_replace([' ',"\t", "\n", "\r"], '', $value));
}
// if $data has field and $entry is null, create new one:
if (null === $entry) {
return $this->create(['account_id' => $account->id, 'name' => $field, 'data' => $value]);
}
// if $data has field and $entry is not null, update $entry:
$entry->data = $value;
$entry->save();