mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add more IBAN filters
This commit is contained in:
parent
0b63ba26bb
commit
cd7ddd1c61
@ -63,7 +63,7 @@ class StoreRequest extends FormRequest
|
|||||||
'order' => $this->convertInteger('order'),
|
'order' => $this->convertInteger('order'),
|
||||||
'currency_code' => $this->convertString('currency_code'),
|
'currency_code' => $this->convertString('currency_code'),
|
||||||
'virtual_balance' => $this->convertString('virtual_balance'),
|
'virtual_balance' => $this->convertString('virtual_balance'),
|
||||||
'iban' => $this->convertString('iban'),
|
'iban' => $this->convertIban('iban'),
|
||||||
'BIC' => $this->convertString('bic'),
|
'BIC' => $this->convertString('bic'),
|
||||||
'account_number' => $this->convertString('account_number'),
|
'account_number' => $this->convertString('account_number'),
|
||||||
'account_role' => $this->convertString('account_role'),
|
'account_role' => $this->convertString('account_role'),
|
||||||
|
@ -51,7 +51,7 @@ class UpdateRequest extends FormRequest
|
|||||||
'include_net_worth' => ['include_net_worth', 'boolean'],
|
'include_net_worth' => ['include_net_worth', 'boolean'],
|
||||||
'account_type_name' => ['type', 'convertString'],
|
'account_type_name' => ['type', 'convertString'],
|
||||||
'virtual_balance' => ['virtual_balance', 'convertString'],
|
'virtual_balance' => ['virtual_balance', 'convertString'],
|
||||||
'iban' => ['iban', 'convertString'],
|
'iban' => ['iban', 'convertIban'],
|
||||||
'BIC' => ['bic', 'convertString'],
|
'BIC' => ['bic', 'convertString'],
|
||||||
'account_number' => ['account_number', 'convertString'],
|
'account_number' => ['account_number', 'convertString'],
|
||||||
'account_role' => ['account_role', 'convertString'],
|
'account_role' => ['account_role', 'convertString'],
|
||||||
|
@ -103,14 +103,14 @@ class StoreRequest extends FormRequest
|
|||||||
// source of transaction. If everything is null, assume cash account.
|
// source of transaction. If everything is null, assume cash account.
|
||||||
'source_id' => $this->integerFromValue((string)$object['source_id']),
|
'source_id' => $this->integerFromValue((string)$object['source_id']),
|
||||||
'source_name' => $this->clearString((string)$object['source_name']),
|
'source_name' => $this->clearString((string)$object['source_name']),
|
||||||
'source_iban' => $this->clearString((string)$object['source_iban']),
|
'source_iban' => $this->clearIban((string)$object['source_iban']),
|
||||||
'source_number' => $this->clearString((string)$object['source_number']),
|
'source_number' => $this->clearString((string)$object['source_number']),
|
||||||
'source_bic' => $this->clearString((string)$object['source_bic']),
|
'source_bic' => $this->clearString((string)$object['source_bic']),
|
||||||
|
|
||||||
// destination of transaction. If everything is null, assume cash account.
|
// destination of transaction. If everything is null, assume cash account.
|
||||||
'destination_id' => $this->integerFromValue((string)$object['destination_id']),
|
'destination_id' => $this->integerFromValue((string)$object['destination_id']),
|
||||||
'destination_name' => $this->clearString((string)$object['destination_name']),
|
'destination_name' => $this->clearString((string)$object['destination_name']),
|
||||||
'destination_iban' => $this->clearString((string)$object['destination_iban']),
|
'destination_iban' => $this->clearIban((string)$object['destination_iban']),
|
||||||
'destination_number' => $this->clearString((string)$object['destination_number']),
|
'destination_number' => $this->clearString((string)$object['destination_number']),
|
||||||
'destination_bic' => $this->clearString((string)$object['destination_bic']),
|
'destination_bic' => $this->clearString((string)$object['destination_bic']),
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class AccountFormRequest extends FormRequest
|
|||||||
'account_type_name' => $this->convertString('objectType'),
|
'account_type_name' => $this->convertString('objectType'),
|
||||||
'currency_id' => $this->convertInteger('currency_id'),
|
'currency_id' => $this->convertInteger('currency_id'),
|
||||||
'virtual_balance' => $this->convertString('virtual_balance'),
|
'virtual_balance' => $this->convertString('virtual_balance'),
|
||||||
'iban' => $this->convertString('iban'),
|
'iban' => $this->convertIban('iban'),
|
||||||
'BIC' => $this->convertString('BIC'),
|
'BIC' => $this->convertString('BIC'),
|
||||||
'account_number' => $this->convertString('account_number'),
|
'account_number' => $this->convertString('account_number'),
|
||||||
'account_role' => $this->convertString('account_role'),
|
'account_role' => $this->convertString('account_role'),
|
||||||
|
@ -37,6 +37,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
|
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
|
||||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||||
|
use FireflyIII\Support\Facades\Steam;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
@ -123,6 +124,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
public function findByIbanNull(string $iban, array $types): ?Account
|
public function findByIbanNull(string $iban, array $types): ?Account
|
||||||
{
|
{
|
||||||
|
$iban = Steam::filterSpaces($iban);
|
||||||
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
||||||
|
|
||||||
if (0 !== count($types)) {
|
if (0 !== count($types)) {
|
||||||
|
@ -31,6 +31,7 @@ use FireflyIII\Models\ObjectGroup;
|
|||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||||
|
use FireflyIII\Support\Facades\Steam;
|
||||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -80,6 +81,7 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
public function findByIbanNull(string $iban, array $types): ?Account
|
public function findByIbanNull(string $iban, array $types): ?Account
|
||||||
{
|
{
|
||||||
|
$iban = Steam::filterSpaces($iban);
|
||||||
$query = $this->userGroup->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
$query = $this->userGroup->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
||||||
|
|
||||||
if (0 !== count($types)) {
|
if (0 !== count($types)) {
|
||||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Rules;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Support\Facades\Steam;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,6 +96,10 @@ class UniqueIban implements ValidationRule
|
|||||||
$maxCounts = $this->getMaxOccurrences();
|
$maxCounts = $this->getMaxOccurrences();
|
||||||
|
|
||||||
foreach ($maxCounts as $type => $max) {
|
foreach ($maxCounts as $type => $max) {
|
||||||
|
|
||||||
|
// make sure to trim the value of $value so all spaces are removed.
|
||||||
|
$value = Steam::filterSpaces($value);
|
||||||
|
|
||||||
$count = $this->countHits($type, $value);
|
$count = $this->countHits($type, $value);
|
||||||
app('log')->debug(sprintf('Count for "%s" and IBAN "%s" is %d', $type, $value, $count));
|
app('log')->debug(sprintf('Count for "%s" and IBAN "%s" is %d', $type, $value, $count));
|
||||||
if ($count > $max) {
|
if ($count > $max) {
|
||||||
|
@ -27,6 +27,7 @@ use Carbon\Carbon;
|
|||||||
use Carbon\Exceptions\InvalidDateException;
|
use Carbon\Exceptions\InvalidDateException;
|
||||||
use Carbon\Exceptions\InvalidFormatException;
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Facades\Steam;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,6 +115,11 @@ trait ConvertsDataTypes
|
|||||||
return (string)$this->clearString((string)$entry);
|
return (string)$this->clearString((string)$entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function convertIban(string $field): string
|
||||||
|
{
|
||||||
|
return Steam::filterSpaces($this->convertString($field));
|
||||||
|
}
|
||||||
|
|
||||||
public function clearString(?string $string): ?string
|
public function clearString(?string $string): ?string
|
||||||
{
|
{
|
||||||
$string = $this->clearStringKeepNewlines($string);
|
$string = $this->clearStringKeepNewlines($string);
|
||||||
@ -131,6 +137,12 @@ trait ConvertsDataTypes
|
|||||||
return trim($string);
|
return trim($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clearIban(?string $string): ?string
|
||||||
|
{
|
||||||
|
$string = $this->clearString($string);
|
||||||
|
return Steam::filterSpaces($string);
|
||||||
|
}
|
||||||
|
|
||||||
public function clearStringKeepNewlines(?string $string): ?string
|
public function clearStringKeepNewlines(?string $string): ?string
|
||||||
{
|
{
|
||||||
if (null === $string) {
|
if (null === $string) {
|
||||||
|
@ -681,11 +681,13 @@ class Steam
|
|||||||
"\u{202F}", // narrow no-break space
|
"\u{202F}", // narrow no-break space
|
||||||
"\u{3000}", // ideographic space
|
"\u{3000}", // ideographic space
|
||||||
"\u{FEFF}", // zero width no -break space
|
"\u{FEFF}", // zero width no -break space
|
||||||
"\x20", // plain old normal space
|
"\x20", // plain old normal space,
|
||||||
|
' '
|
||||||
];
|
];
|
||||||
|
|
||||||
// clear zalgo text
|
// clear zalgo text
|
||||||
$string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
|
$string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
|
||||||
|
$string = preg_replace('/\s+/', '', $string);
|
||||||
|
|
||||||
return str_replace($search, '', $string);
|
return str_replace($search, '', $string);
|
||||||
}
|
}
|
||||||
|
@ -170,6 +170,7 @@ class FireflyValidator extends Validator
|
|||||||
"\u{202F}", // narrow no-break space
|
"\u{202F}", // narrow no-break space
|
||||||
"\u{3000}", // ideographic space
|
"\u{3000}", // ideographic space
|
||||||
"\u{FEFF}", // zero width no -break space
|
"\u{FEFF}", // zero width no -break space
|
||||||
|
' ',
|
||||||
'-',
|
'-',
|
||||||
'?',
|
'?',
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user