mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -23,10 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class PiggyBankEventTransformer
|
||||
@@ -55,8 +57,8 @@ class PiggyBankEventTransformer extends AbstractTransformer
|
||||
* @param PiggyBankEvent $event
|
||||
*
|
||||
* @return array
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function transform(PiggyBankEvent $event): array
|
||||
{
|
||||
|
@@ -23,11 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class PiggyBankTransformer
|
||||
@@ -56,8 +58,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return array
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function transform(PiggyBank $piggyBank): array
|
||||
{
|
||||
|
@@ -56,10 +56,23 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
{
|
||||
$this->groupRepos = app(TransactionGroupRepositoryInterface::class);
|
||||
$this->metaFields = [
|
||||
'sepa_cc', 'sepa_ct_op', 'sepa_ct_id', 'sepa_db', 'sepa_country', 'sepa_ep',
|
||||
'sepa_ci', 'sepa_batch_id', 'internal_reference', 'bunq_payment_id', 'import_hash_v2',
|
||||
'recurrence_id', 'external_id', 'original_source', 'external_url',
|
||||
'recurrence_count', 'recurrence_total',
|
||||
'sepa_cc',
|
||||
'sepa_ct_op',
|
||||
'sepa_ct_id',
|
||||
'sepa_db',
|
||||
'sepa_country',
|
||||
'sepa_ep',
|
||||
'sepa_ci',
|
||||
'sepa_batch_id',
|
||||
'internal_reference',
|
||||
'bunq_payment_id',
|
||||
'import_hash_v2',
|
||||
'recurrence_id',
|
||||
'external_id',
|
||||
'original_source',
|
||||
'external_url',
|
||||
'recurrence_count',
|
||||
'recurrence_total',
|
||||
];
|
||||
$this->metaDateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
|
||||
}
|
||||
@@ -251,6 +264,16 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return $this->groupRepos->getLocation($journalId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Location|null
|
||||
*/
|
||||
private function getLocation(TransactionJournal $journal): ?Location
|
||||
{
|
||||
return $journal->locations()->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
@@ -633,14 +656,4 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Location|null
|
||||
*/
|
||||
private function getLocation(TransactionJournal $journal): ?Location
|
||||
{
|
||||
return $journal->locations()->first();
|
||||
}
|
||||
}
|
||||
|
@@ -37,10 +37,41 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class AccountTransformer extends AbstractTransformer
|
||||
{
|
||||
private array $currencies;
|
||||
private array $accountMeta;
|
||||
private ?TransactionCurrency $currency;
|
||||
private array $balances;
|
||||
private array $currencies;
|
||||
private ?TransactionCurrency $currency;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
$this->currency = null;
|
||||
$this->currencies = [];
|
||||
$this->accountMeta = [];
|
||||
$this->balances = app('steam')->balancesByAccounts($objects, $this->getDate());
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
// get currencies:
|
||||
$accountIds = $objects->pluck('id')->toArray();
|
||||
$meta = AccountMeta::whereIn('account_id', $accountIds)
|
||||
->where('name', 'currency_id')
|
||||
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);
|
||||
$currencyIds = $meta->pluck('data')->toArray();
|
||||
|
||||
$currencies = $repository->getByIds($currencyIds);
|
||||
foreach ($currencies as $currency) {
|
||||
$id = (int)$currency->id;
|
||||
$this->currencies[$id] = $currency;
|
||||
}
|
||||
foreach ($meta as $entry) {
|
||||
$id = (int)$entry->account_id;
|
||||
$this->accountMeta[$id][$entry->name] = $entry->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the account.
|
||||
@@ -115,35 +146,4 @@ class AccountTransformer extends AbstractTransformer
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
$this->currency = null;
|
||||
$this->currencies = [];
|
||||
$this->accountMeta = [];
|
||||
$this->balances = app('steam')->balancesByAccounts($objects, $this->getDate());
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
// get currencies:
|
||||
$accountIds = $objects->pluck('id')->toArray();
|
||||
$meta = AccountMeta::whereIn('account_id', $accountIds)
|
||||
->where('name', 'currency_id')
|
||||
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);
|
||||
$currencyIds = $meta->pluck('data')->toArray();
|
||||
|
||||
$currencies = $repository->getByIds($currencyIds);
|
||||
foreach ($currencies as $currency) {
|
||||
$id = (int) $currency->id;
|
||||
$this->currencies[$id] = $currency;
|
||||
}
|
||||
foreach ($meta as $entry) {
|
||||
$id = (int) $entry->account_id;
|
||||
$this->accountMeta[$id][$entry->name] = $entry->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Transformers\V2;
|
||||
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepository;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
|
||||
@@ -39,6 +38,14 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
'budget',
|
||||
];
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// TODO: Implement collectMetaData() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Include Budget
|
||||
*
|
||||
@@ -105,12 +112,4 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// TODO: Implement collectMetaData() method.
|
||||
}
|
||||
}
|
||||
|
@@ -47,6 +47,14 @@ class BudgetTransformer extends AbstractTransformer
|
||||
$this->parameters = new ParameterBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// TODO: Implement collectMetaData() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a budget.
|
||||
*
|
||||
@@ -123,12 +131,4 @@ class BudgetTransformer extends AbstractTransformer
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// TODO: Implement collectMetaData() method.
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,14 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class PreferenceTransformer extends AbstractTransformer
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// TODO: Implement collectMetaData() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the preference
|
||||
*
|
||||
@@ -48,12 +56,4 @@ class PreferenceTransformer extends AbstractTransformer
|
||||
'data' => $preference->data,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// TODO: Implement collectMetaData() method.
|
||||
}
|
||||
}
|
||||
|
@@ -25,8 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Transformers\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Factory\TransactionFactory;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
@@ -45,6 +43,41 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
private TransactionCurrency $default;
|
||||
private array $meta;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// start with currencies:
|
||||
$currencies = [];
|
||||
$journals = [];
|
||||
/** @var array $object */
|
||||
foreach ($objects as $object) {
|
||||
foreach ($object['sums'] as $sum) {
|
||||
$id = $sum['currency_id'];
|
||||
if (!array_key_exists($id, $currencies)) {
|
||||
$currencyObject = TransactionCurrency::find($sum['currency_id']);
|
||||
$currencies[$id] = $currencyObject;
|
||||
}
|
||||
}
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
$id = $transaction['transaction_journal_id'];
|
||||
$journals[$id] = [];
|
||||
}
|
||||
}
|
||||
$this->currencies = $currencies;
|
||||
$this->default = app('amount')->getDefaultCurrency();
|
||||
|
||||
// grab meta for all journals:
|
||||
$meta = TransactionJournalMeta::whereIn('transaction_journal_id', array_keys($journals))->get();
|
||||
/** @var TransactionJournalMeta $entry */
|
||||
foreach ($meta as $entry) {
|
||||
$id = (int)$entry->transaction_journal_id;
|
||||
$this->meta[$id][$entry->name] = $entry->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $group
|
||||
*
|
||||
@@ -219,41 +252,6 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function collectMetaData(Collection $objects): void
|
||||
{
|
||||
// start with currencies:
|
||||
$currencies = [];
|
||||
$journals = [];
|
||||
/** @var array $object */
|
||||
foreach ($objects as $object) {
|
||||
foreach ($object['sums'] as $sum) {
|
||||
$id = $sum['currency_id'];
|
||||
if (!array_key_exists($id, $currencies)) {
|
||||
$currencyObject = TransactionCurrency::find($sum['currency_id']);
|
||||
$currencies[$id] = $currencyObject;
|
||||
}
|
||||
}
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
$id = $transaction['transaction_journal_id'];
|
||||
$journals[$id] = [];
|
||||
}
|
||||
}
|
||||
$this->currencies = $currencies;
|
||||
$this->default = app('amount')->getDefaultCurrency();
|
||||
|
||||
// grab meta for all journals:
|
||||
$meta = TransactionJournalMeta::whereIn('transaction_journal_id', array_keys($journals))->get();
|
||||
/** @var TransactionJournalMeta $entry */
|
||||
foreach ($meta as $entry) {
|
||||
$id = (int) $entry->transaction_journal_id;
|
||||
$this->meta[$id][$entry->name] = $entry->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $string
|
||||
* @return Carbon|null
|
||||
|
@@ -32,21 +32,6 @@ use Log;
|
||||
*/
|
||||
trait DepositValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
@@ -95,6 +80,21 @@ trait DepositValidation
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
|
@@ -33,13 +33,6 @@ use Log;
|
||||
*/
|
||||
trait OBValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
@@ -87,6 +80,13 @@ trait OBValidation
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* Source of an opening balance can either be an asset account
|
||||
* or an "initial balance account". The latter can be created.
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Validation\Account;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
|
@@ -31,21 +31,6 @@ use Log;
|
||||
*/
|
||||
trait TransferValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
@@ -87,6 +72,21 @@ trait TransferValidation
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
|
@@ -32,21 +32,6 @@ use Log;
|
||||
*/
|
||||
trait WithdrawalValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
@@ -82,6 +67,21 @@ trait WithdrawalValidation
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, array $data): ?Account;
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FireflyValidator.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -188,8 +189,35 @@ class FireflyValidator extends Validator
|
||||
// replace characters outside of ASCI range.
|
||||
$value = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
|
||||
$search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
||||
$replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31',
|
||||
'32', '33', '34', '35',];
|
||||
$replace = [
|
||||
'',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
'16',
|
||||
'17',
|
||||
'18',
|
||||
'19',
|
||||
'20',
|
||||
'21',
|
||||
'22',
|
||||
'23',
|
||||
'24',
|
||||
'25',
|
||||
'26',
|
||||
'27',
|
||||
'28',
|
||||
'29',
|
||||
'30',
|
||||
'31',
|
||||
'32',
|
||||
'33',
|
||||
'34',
|
||||
'35',
|
||||
];
|
||||
|
||||
// take
|
||||
$first = substr($value, 0, 4);
|
||||
@@ -306,8 +334,14 @@ class FireflyValidator extends Validator
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$account = $repository->findByName(
|
||||
$value,
|
||||
[AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,
|
||||
AccountType::CREDITCARD]
|
||||
[
|
||||
AccountType::DEFAULT,
|
||||
AccountType::ASSET,
|
||||
AccountType::LOAN,
|
||||
AccountType::DEBT,
|
||||
AccountType::MORTGAGE,
|
||||
AccountType::CREDITCARD,
|
||||
]
|
||||
);
|
||||
|
||||
return null !== $account;
|
||||
@@ -354,11 +388,28 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
// these trigger types need a simple strlen check:
|
||||
$length = ['source_account_starts', 'source_account_ends', 'source_account_is', 'source_account_contains', 'destination_account_starts',
|
||||
$length = [
|
||||
'source_account_starts',
|
||||
'source_account_ends',
|
||||
'source_account_is',
|
||||
'source_account_contains',
|
||||
'destination_account_starts',
|
||||
'destination_account_ends',
|
||||
'destination_account_is', 'destination_account_contains', 'description_starts', 'description_ends', 'description_contains', 'description_is',
|
||||
'destination_account_is',
|
||||
'destination_account_contains',
|
||||
'description_starts',
|
||||
'description_ends',
|
||||
'description_contains',
|
||||
'description_is',
|
||||
'category_is',
|
||||
'budget_is', 'tag_is', 'currency_is', 'notes_contain', 'notes_start', 'notes_end', 'notes_are',];
|
||||
'budget_is',
|
||||
'tag_is',
|
||||
'currency_is',
|
||||
'notes_contain',
|
||||
'notes_start',
|
||||
'notes_end',
|
||||
'notes_are',
|
||||
];
|
||||
if (in_array($triggerType, $length, true)) {
|
||||
return '' !== $value;
|
||||
}
|
||||
@@ -637,16 +688,6 @@ class FireflyValidator extends Validator
|
||||
return $this->validateUniqueCurrency('code', (string)$attribute, (string)$value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUniqueCurrencyName($attribute, $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param string $attribute
|
||||
@@ -658,6 +699,16 @@ class FireflyValidator extends Validator
|
||||
return 0 === DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
public function validateUniqueCurrencyName($attribute, $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('name', (string)$attribute, (string)$value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
|
@@ -35,20 +35,22 @@ use Log;
|
||||
*/
|
||||
trait GroupValidation
|
||||
{
|
||||
/**
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getTransactionsArray(Validator $validator): array;
|
||||
|
||||
/**
|
||||
* @param Validator $validator
|
||||
*/
|
||||
protected function preventNoAccountInfo(Validator $validator): void
|
||||
{
|
||||
$transactions = $this->getTransactionsArray($validator);
|
||||
$keys = ['source_id', 'destination_id', 'source_name', 'destination_name', 'source_iban', 'destination_iban', 'source_number', 'destination_number'];
|
||||
$keys = [
|
||||
'source_id',
|
||||
'destination_id',
|
||||
'source_name',
|
||||
'destination_name',
|
||||
'source_iban',
|
||||
'destination_iban',
|
||||
'source_number',
|
||||
'destination_number',
|
||||
];
|
||||
/** @var array $transaction */
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
$hasAccountInfo = false;
|
||||
@@ -70,10 +72,16 @@ trait GroupValidation
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// only an issue if there is no transaction_journal_id
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getTransactionsArray(Validator $validator): array;
|
||||
|
||||
/**
|
||||
* Adds an error to the "description" field when the user has submitted no descriptions and no
|
||||
* journal description.
|
||||
|
Reference in New Issue
Block a user