mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Finalise account tests
This commit is contained in:
@@ -124,6 +124,9 @@ class AccountValidator
|
||||
case TransactionType::OPENING_BALANCE:
|
||||
$result = $this->validateOBDestination($destinationId, $destinationName);
|
||||
break;
|
||||
case TransactionType::RECONCILIATION:
|
||||
$result = $this->validateReconciliationDestination($destinationId);
|
||||
break;
|
||||
//case TransactionType::OPENING_BALANCE:
|
||||
//case TransactionType::RECONCILIATION:
|
||||
// die(sprintf('Cannot handle type "%s"', $this->transactionType));
|
||||
@@ -159,6 +162,9 @@ class AccountValidator
|
||||
case TransactionType::OPENING_BALANCE:
|
||||
$result = $this->validateOBSource($accountId, $accountName);
|
||||
break;
|
||||
case TransactionType::RECONCILIATION:
|
||||
$result = $this->validateReconciliationSource($accountId);
|
||||
break;
|
||||
//case TransactionType::OPENING_BALANCE:
|
||||
//case TransactionType::RECONCILIATION:
|
||||
// die(sprintf('Cannot handle type "%s"', $this->transactionType));
|
||||
@@ -582,5 +588,51 @@ class AccountValidator
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @return bool
|
||||
*/
|
||||
private function validateReconciliationSource(?int $accountId): bool
|
||||
{
|
||||
if (null === $accountId) {
|
||||
return false;
|
||||
}
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::RECONCILIATION];
|
||||
if (null === $result) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($result->accountType->type, $types, true)) {
|
||||
$this->source = $result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @return bool
|
||||
*/
|
||||
private function validateReconciliationDestination(?int $accountId): bool
|
||||
{
|
||||
if (null === $accountId) {
|
||||
return false;
|
||||
}
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::RECONCILIATION];
|
||||
if (null === $result) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($result->accountType->type, $types, true)) {
|
||||
$this->destination = $result;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user