Various code cleanup and fixed alignments.

This commit is contained in:
James Cole
2024-01-01 14:43:56 +01:00
parent 1368aafe5f
commit f963ac63f1
443 changed files with 3668 additions and 3672 deletions

View File

@@ -41,13 +41,13 @@ trait DepositValidation
app('log')->debug('Now in validateDepositDestination', $array);
// source can be any of the following types.
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a deposit can't be created.
$this->destError = (string) trans('validation.deposit_dest_need_data');
app('log')->error('Both values are NULL, cant create deposit destination.');
$result = false;
$result = false;
}
// if the account can be created anyway we don't need to search.
if (null === $result && true === $this->canCreateTypes($validTypes)) {
@@ -94,10 +94,10 @@ trait DepositValidation
// null = we found nothing at all or didn't even search
// false = invalid results
$result = null;
$result = null;
// source can be any of the following types.
$validTypes = array_keys($this->combinations[$this->transactionType]);
$validTypes = array_keys($this->combinations[$this->transactionType]);
if (null === $accountId
&& null === $accountName
&& null === $accountIban
@@ -168,7 +168,7 @@ trait DepositValidation
// if the account can be created anyway we don't need to search.
if (null === $result && true === $this->canCreateTypes($validTypes)) {
$result = true;
$result = true;
// set the source to be a (dummy) revenue account.
$account = new Account();

View File

@@ -76,7 +76,7 @@ trait LiabilityValidation
app('log')->debug('Now in validateLCSource', $array);
// if the array has an ID and ID is not null, try to find it and check type.
// this account must be a liability
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
if (null !== $accountId) {
app('log')->debug('Source ID is not null, assume were looking for a liability.');
// find liability credit:
@@ -95,7 +95,7 @@ trait LiabilityValidation
// if array has name and is not null, return true.
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
$result = true;
$result = true;
if ('' === $accountName || null === $accountName) {
app('log')->error('Array must have a name, is not the case, return false.');
$result = false;

View File

@@ -40,13 +40,13 @@ trait OBValidation
app('log')->debug('Now in validateOBDestination', $array);
// source can be any of the following types.
$validTypes = $this->combinations[$this->transactionType][$this->source?->accountType->type] ?? [];
$validTypes = $this->combinations[$this->transactionType][$this->source?->accountType->type] ?? [];
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a deposit can't be created.
$this->destError = (string)trans('validation.ob_dest_need_data');
app('log')->error('Both values are NULL, cant create OB destination.');
$result = false;
$result = false;
}
// if the account can be created anyway we don't need to search.
if (null === $result && true === $this->canCreateTypes($validTypes)) {
@@ -84,9 +84,9 @@ trait OBValidation
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
app('log')->debug('Now in validateOBSource', $array);
$result = null;
$result = null;
// source can be any of the following types.
$validTypes = array_keys($this->combinations[$this->transactionType]);
$validTypes = array_keys($this->combinations[$this->transactionType]);
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL return false,
@@ -104,7 +104,7 @@ trait OBValidation
// the source resulted in an account, but it's not of a valid type.
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
$message = sprintf('User submitted only an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type);
$message = sprintf('User submitted only an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type);
app('log')->debug($message);
$this->sourceError = $message;
$result = false;
@@ -120,10 +120,10 @@ trait OBValidation
// if the account can be created anyway we don't need to search.
if (null === $result && true === $this->canCreateTypes($validTypes)) {
app('log')->debug('Result is still null.');
$result = true;
$result = true;
// set the source to be a (dummy) initial balance account.
$account = new Account();
$account = new Account();
/** @var AccountType $accountType */
$accountType = AccountType::whereType(AccountType::INITIAL_BALANCE)->first();

View File

@@ -50,8 +50,8 @@ trait ReconciliationValidation
app('log')->debug('Now in validateReconciliationDestination', $array);
// source can be any of the following types.
$validTypes = array_keys($this->combinations[$this->transactionType]);
$search = $this->findExistingAccount($validTypes, $array);
$validTypes = array_keys($this->combinations[$this->transactionType]);
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->sourceError = (string)trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
app('log')->warning('Not a valid source. Cant find it.', $validTypes);
@@ -85,8 +85,8 @@ trait ReconciliationValidation
app('log')->debug('Now in validateReconciliationSource', $array);
// source can be any of the following types.
$validTypes = array_keys($this->combinations[$this->transactionType]);
$search = $this->findExistingAccount($validTypes, $array);
$validTypes = array_keys($this->combinations[$this->transactionType]);
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->sourceError = (string)trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
app('log')->warning('Not a valid source. Cant find it.', $validTypes);

View File

@@ -37,7 +37,7 @@ trait TransferValidation
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
app('log')->debug('Now in validateTransferDestination', $array);
// source can be any of the following types.
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a transfer can't be created.
@@ -48,7 +48,7 @@ trait TransferValidation
}
// or try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->destError = (string)trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
@@ -79,7 +79,7 @@ trait TransferValidation
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
app('log')->debug('Now in validateTransferSource', $array);
// source can be any of the following types.
$validTypes = array_keys($this->combinations[$this->transactionType]);
$validTypes = array_keys($this->combinations[$this->transactionType]);
if (null === $accountId && null === $accountName
&& null === $accountIban && null === $accountNumber
&& false === $this->canCreateTypes($validTypes)) {
@@ -92,7 +92,7 @@ trait TransferValidation
}
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->sourceError = (string)trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
app('log')->warning('Not a valid source, cant find it.', $validTypes);

View File

@@ -38,7 +38,7 @@ trait WithdrawalValidation
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
app('log')->debug('Now in validateGenericSource', $array);
// source can be any of the following types.
$validTypes = [AccountType::ASSET, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
$validTypes = [AccountType::ASSET, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return TRUE
// because we assume the user doesn't want to submit / change anything.
@@ -49,7 +49,7 @@ trait WithdrawalValidation
}
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
app('log')->warning('Not a valid source. Cant find it.', $validTypes);
@@ -74,7 +74,7 @@ trait WithdrawalValidation
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
app('log')->debug('Now in validateWithdrawalDestination()', $array);
// source can be any of the following types.
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
app('log')->debug('Source type can be: ', $validTypes);
if (null === $accountId && null === $accountName && null === $accountIban && null === $accountNumber && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL return false,
@@ -88,7 +88,7 @@ trait WithdrawalValidation
if (null !== $accountId && 0 !== $accountId) {
$found = $this->getRepository()->find($accountId);
if (null !== $found) {
$type = $found->accountType->type;
$type = $found->accountType->type;
if (in_array($type, $validTypes, true)) {
$this->setDestination($found);
@@ -126,7 +126,7 @@ trait WithdrawalValidation
app('log')->debug('Now in validateWithdrawalSource', $array);
// source can be any of the following types.
$validTypes = array_keys($this->combinations[$this->transactionType]);
$validTypes = array_keys($this->combinations[$this->transactionType]);
if (null === $accountId && null === $accountName && null === $accountNumber && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the source of a withdrawal can't be created.
@@ -137,7 +137,7 @@ trait WithdrawalValidation
}
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
$this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
app('log')->warning('Not a valid source. Cant find it.', $validTypes);