mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Code reordering and reformatting. I should really start employing style CI.
This commit is contained in:
@@ -32,6 +32,22 @@ use Log;
|
||||
*/
|
||||
trait DepositValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param int $accountId
|
||||
* @param string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param mixed $accountName
|
||||
@@ -78,22 +94,6 @@ trait DepositValidation
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param int $accountId
|
||||
* @param string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param string|null $accountName
|
||||
|
||||
@@ -35,31 +35,6 @@ use Log;
|
||||
trait LiabilityValidation
|
||||
{
|
||||
|
||||
/**
|
||||
* Source of an liability credit must be a liability.
|
||||
*
|
||||
* @param string|null $accountName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateLCSource(?string $accountName): bool
|
||||
{
|
||||
$result = true;
|
||||
Log::debug(sprintf('Now in validateLCDestination("%s")', $accountName));
|
||||
if ('' === $accountName || null === $accountName) {
|
||||
$result = false;
|
||||
}
|
||||
if (true === $result) {
|
||||
// set the source to be a (dummy) revenue account.
|
||||
$account = new Account;
|
||||
$accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();
|
||||
$account->accountType = $accountType;
|
||||
$this->source = $account;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
*
|
||||
@@ -96,4 +71,29 @@ trait LiabilityValidation
|
||||
return $result ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Source of an liability credit must be a liability.
|
||||
*
|
||||
* @param string|null $accountName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateLCSource(?string $accountName): bool
|
||||
{
|
||||
$result = true;
|
||||
Log::debug(sprintf('Now in validateLCDestination("%s")', $accountName));
|
||||
if ('' === $accountName || null === $accountName) {
|
||||
$result = false;
|
||||
}
|
||||
if (true === $result) {
|
||||
// set the source to be a (dummy) revenue account.
|
||||
$account = new Account;
|
||||
$accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();
|
||||
$account->accountType = $accountType;
|
||||
$this->source = $account;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@ use Log;
|
||||
*/
|
||||
trait OBValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param mixed $accountName
|
||||
@@ -79,13 +86,6 @@ 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.
|
||||
|
||||
@@ -31,6 +31,22 @@ use Log;
|
||||
*/
|
||||
trait TransferValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param int $accountId
|
||||
* @param string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param mixed $accountName
|
||||
@@ -71,22 +87,6 @@ trait TransferValidation
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param int $accountId
|
||||
* @param string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param string|null $accountName
|
||||
|
||||
@@ -32,6 +32,22 @@ use Log;
|
||||
*/
|
||||
trait WithdrawalValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param int $accountId
|
||||
* @param string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param string|null $accountName
|
||||
@@ -103,13 +119,6 @@ trait WithdrawalValidation
|
||||
return true === $this->canCreateTypes($validTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param string|null $accountName
|
||||
@@ -143,13 +152,4 @@ trait WithdrawalValidation
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $validTypes
|
||||
* @param int $accountId
|
||||
* @param string $accountName
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user