mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-15 19:09:50 +00:00
Remove static references
This commit is contained in:
@@ -44,7 +44,7 @@ trait DepositValidation
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
|
||||
Log::debug('Now in validateDepositDestination', $array);
|
||||
app('log')->debug('Now in validateDepositDestination', $array);
|
||||
|
||||
// source can be any of the following types.
|
||||
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
|
||||
@@ -57,7 +57,7 @@ trait DepositValidation
|
||||
}
|
||||
// if the account can be created anyway we don't need to search.
|
||||
if (null === $result && true === $this->canCreateTypes($validTypes)) {
|
||||
Log::debug('Can create some of these types, so return true.');
|
||||
app('log')->debug('Can create some of these types, so return true.');
|
||||
$result = true;
|
||||
}
|
||||
|
||||
@@ -65,17 +65,17 @@ trait DepositValidation
|
||||
// otherwise try to find the account:
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
Log::debug('findExistingAccount() returned NULL, so the result is false.');
|
||||
app('log')->debug('findExistingAccount() returned NULL, so the result is false.');
|
||||
$this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search) {
|
||||
Log::debug(sprintf('findExistingAccount() returned #%d ("%s"), so the result is true.', $search->id, $search->name));
|
||||
app('log')->debug(sprintf('findExistingAccount() returned #%d ("%s"), so the result is true.', $search->id, $search->name));
|
||||
$this->setDestination($search);
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('validateDepositDestination will return %s', var_export($result, true)));
|
||||
app('log')->debug(sprintf('validateDepositDestination will return %s', var_export($result, true)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ trait DepositValidation
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
|
||||
Log::debug('Now in validateDepositSource', $array);
|
||||
app('log')->debug('Now in validateDepositSource', $array);
|
||||
|
||||
// null = we found nothing at all or didn't even search
|
||||
// false = invalid results
|
||||
@@ -141,11 +141,11 @@ trait DepositValidation
|
||||
if (null !== $accountId) {
|
||||
$search = $this->getRepository()->find($accountId);
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug(sprintf('User submitted an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type));
|
||||
Log::debug(sprintf('Firefly III accepts ID #%d as valid account data.', $accountId));
|
||||
app('log')->debug(sprintf('User submitted an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type));
|
||||
app('log')->debug(sprintf('Firefly III accepts ID #%d as valid account data.', $accountId));
|
||||
}
|
||||
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug('ID result is not null and seems valid, save as source account.');
|
||||
app('log')->debug('ID result is not null and seems valid, save as source account.');
|
||||
$this->setSource($search);
|
||||
$result = true;
|
||||
}
|
||||
@@ -155,11 +155,11 @@ trait DepositValidation
|
||||
if (null !== $accountIban) {
|
||||
$search = $this->getRepository()->findByIbanNull($accountIban, $validTypes);
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug(sprintf('User submitted IBAN ("%s"), which is a "%s", so this is not a valid source.', $accountIban, $search->accountType->type));
|
||||
app('log')->debug(sprintf('User submitted IBAN ("%s"), which is a "%s", so this is not a valid source.', $accountIban, $search->accountType->type));
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug('IBAN result is not null and seems valid, save as source account.');
|
||||
app('log')->debug('IBAN result is not null and seems valid, save as source account.');
|
||||
$this->setSource($search);
|
||||
$result = true;
|
||||
}
|
||||
@@ -169,13 +169,13 @@ trait DepositValidation
|
||||
if (null !== $accountNumber && '' !== $accountNumber) {
|
||||
$search = $this->getRepository()->findByAccountNumber($accountNumber, $validTypes);
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug(
|
||||
app('log')->debug(
|
||||
sprintf('User submitted number ("%s"), which is a "%s", so this is not a valid source.', $accountNumber, $search->accountType->type)
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug('Number result is not null and seems valid, save as source account.');
|
||||
app('log')->debug('Number result is not null and seems valid, save as source account.');
|
||||
$this->setSource($search);
|
||||
$result = true;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ trait LiabilityValidation
|
||||
*/
|
||||
protected function validateLCDestination(array $array): bool
|
||||
{
|
||||
Log::debug('Now in validateLCDestination', $array);
|
||||
app('log')->debug('Now in validateLCDestination', $array);
|
||||
$result = null;
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
@@ -62,7 +62,7 @@ trait LiabilityValidation
|
||||
}
|
||||
|
||||
if (null !== $accountName && '' !== $accountName) {
|
||||
Log::debug('Destination ID is null, now we can assume the destination is a (new) liability credit account.');
|
||||
app('log')->debug('Destination ID is null, now we can assume the destination is a (new) liability credit account.');
|
||||
return true;
|
||||
}
|
||||
app('log')->error('Destination ID is null, but destination name is also NULL.');
|
||||
@@ -78,19 +78,19 @@ trait LiabilityValidation
|
||||
*/
|
||||
protected function validateLCSource(array $array): bool
|
||||
{
|
||||
Log::debug('Now in validateLCSource', $array);
|
||||
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;
|
||||
if (null !== $accountId) {
|
||||
Log::debug('Source ID is not null, assume were looking for a liability.');
|
||||
app('log')->debug('Source ID is not null, assume were looking for a liability.');
|
||||
// find liability credit:
|
||||
$result = $this->findExistingAccount(config('firefly.valid_liabilities'), $array);
|
||||
if (null === $result) {
|
||||
app('log')->error('Did not find a liability account, return false.');
|
||||
return false;
|
||||
}
|
||||
Log::debug(sprintf('Return true, found #%d ("%s")', $result->id, $result->name));
|
||||
app('log')->debug(sprintf('Return true, found #%d ("%s")', $result->id, $result->name));
|
||||
$this->setSource($result);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ trait OBValidation
|
||||
$result = null;
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
Log::debug('Now in validateOBDestination', $array);
|
||||
app('log')->debug('Now in validateOBDestination', $array);
|
||||
|
||||
// source can be any of the following types.
|
||||
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
|
||||
@@ -56,7 +56,7 @@ trait OBValidation
|
||||
}
|
||||
// if the account can be created anyway we don't need to search.
|
||||
if (null === $result && true === $this->canCreateTypes($validTypes)) {
|
||||
Log::debug('Can create some of these types, so return true.');
|
||||
app('log')->debug('Can create some of these types, so return true.');
|
||||
$result = true;
|
||||
}
|
||||
|
||||
@@ -64,17 +64,17 @@ trait OBValidation
|
||||
// otherwise try to find the account:
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
Log::debug('findExistingAccount() returned NULL, so the result is false.', $validTypes);
|
||||
app('log')->debug('findExistingAccount() returned NULL, so the result is false.', $validTypes);
|
||||
$this->destError = (string)trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search) {
|
||||
Log::debug(sprintf('findExistingAccount() returned #%d ("%s"), so the result is true.', $search->id, $search->name));
|
||||
app('log')->debug(sprintf('findExistingAccount() returned #%d ("%s"), so the result is true.', $search->id, $search->name));
|
||||
$this->setDestination($search);
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('validateOBDestination(%d, "%s") will return %s', $accountId, $accountName, var_export($result, true)));
|
||||
app('log')->debug(sprintf('validateOBDestination(%d, "%s") will return %s', $accountId, $accountName, var_export($result, true)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ trait OBValidation
|
||||
{
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
Log::debug('Now in validateOBSource', $array);
|
||||
app('log')->debug('Now in validateOBSource', $array);
|
||||
$result = null;
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
@@ -114,19 +114,19 @@ trait OBValidation
|
||||
// if the user submits an ID only but that ID is not of the correct type,
|
||||
// return false.
|
||||
if (null !== $accountId && null === $accountName) {
|
||||
Log::debug('Source ID is not null, but name is null.');
|
||||
app('log')->debug('Source ID is not null, but name is null.');
|
||||
$search = $this->getRepository()->find($accountId);
|
||||
|
||||
// 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);
|
||||
Log::debug($message);
|
||||
app('log')->debug($message);
|
||||
$this->sourceError = $message;
|
||||
$result = false;
|
||||
}
|
||||
// the source resulted in an account, AND it's of a valid type.
|
||||
if (null !== $search && in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug(sprintf('Found account of correct type: #%d, "%s"', $search->id, $search->name));
|
||||
app('log')->debug(sprintf('Found account of correct type: #%d, "%s"', $search->id, $search->name));
|
||||
$this->setSource($search);
|
||||
$result = true;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ trait OBValidation
|
||||
|
||||
// if the account can be created anyway we don't need to search.
|
||||
if (null === $result && true === $this->canCreateTypes($validTypes)) {
|
||||
Log::debug('Result is still null.');
|
||||
app('log')->debug('Result is still null.');
|
||||
$result = true;
|
||||
|
||||
// set the source to be a (dummy) initial balance account.
|
||||
|
||||
@@ -53,7 +53,7 @@ trait ReconciliationValidation
|
||||
}
|
||||
|
||||
// after that, search for it expecting an asset account or a liability.
|
||||
Log::debug('Now in validateReconciliationDestination', $array);
|
||||
app('log')->debug('Now in validateReconciliationDestination', $array);
|
||||
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
@@ -65,7 +65,7 @@ trait ReconciliationValidation
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
Log::debug('Valid source account!');
|
||||
app('log')->debug('Valid source account!');
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -85,13 +85,13 @@ trait ReconciliationValidation
|
||||
// is expected to be "positive", i.e. the money flows from the
|
||||
// source to the asset account that is the destination.
|
||||
if (null === $accountId && null === $accountName) {
|
||||
Log::debug('The source is valid because ID and name are NULL.');
|
||||
app('log')->debug('The source is valid because ID and name are NULL.');
|
||||
$this->setSource(new Account());
|
||||
return true;
|
||||
}
|
||||
|
||||
// after that, search for it expecting an asset account or a liability.
|
||||
Log::debug('Now in validateReconciliationSource', $array);
|
||||
app('log')->debug('Now in validateReconciliationSource', $array);
|
||||
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
@@ -103,7 +103,7 @@ trait ReconciliationValidation
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
Log::debug('Valid source account!');
|
||||
app('log')->debug('Valid source account!');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ trait TransferValidation
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
Log::debug('Now in validateTransferDestination', $array);
|
||||
app('log')->debug('Now in validateTransferDestination', $array);
|
||||
// source can be any of the following types.
|
||||
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
|
||||
if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
|
||||
@@ -99,7 +99,7 @@ trait TransferValidation
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
|
||||
Log::debug('Now in validateTransferSource', $array);
|
||||
app('log')->debug('Now in validateTransferSource', $array);
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
if (null === $accountId && null === $accountName
|
||||
@@ -122,7 +122,7 @@ trait TransferValidation
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
Log::debug('Valid source!');
|
||||
app('log')->debug('Valid source!');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ trait WithdrawalValidation
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
Log::debug('Now in validateGenericSource', $array);
|
||||
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];
|
||||
if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
|
||||
@@ -63,7 +63,7 @@ trait WithdrawalValidation
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
Log::debug('Valid source account!');
|
||||
app('log')->debug('Valid source account!');
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ trait WithdrawalValidation
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
|
||||
Log::debug('Now in validateWithdrawalDestination()', $array);
|
||||
app('log')->debug('Now in validateWithdrawalDestination()', $array);
|
||||
// source can be any of the following types.
|
||||
$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];
|
||||
app('log')->debug('Source type can be: ', $validTypes);
|
||||
@@ -149,7 +149,7 @@ trait WithdrawalValidation
|
||||
$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;
|
||||
$accountNumber = array_key_exists('number', $array) ? $array['number'] : null;
|
||||
|
||||
Log::debug('Now in validateWithdrawalSource', $array);
|
||||
app('log')->debug('Now in validateWithdrawalSource', $array);
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
if (null === $accountId && null === $accountName && null === $accountNumber && null === $accountIban && false === $this->canCreateTypes($validTypes)) {
|
||||
@@ -170,7 +170,7 @@ trait WithdrawalValidation
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
Log::debug('Valid source account!');
|
||||
app('log')->debug('Valid source account!');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user