Routine to make sure imported entries have the correct opposing account and the correct amount.

This commit is contained in:
James Cole
2017-07-08 06:53:06 +02:00
parent f747f3bd10
commit 952328d55c
2 changed files with 57 additions and 16 deletions

View File

@@ -67,6 +67,22 @@ class ImportAccount
return $this->account;
}
/**
* @return string
*/
public function getExpectedType(): string
{
return $this->expectedType;
}
/**
* @param string $expectedType
*/
public function setExpectedType(string $expectedType)
{
$this->expectedType = $expectedType;
}
/**
* @param array $accountIban
*/
@@ -99,14 +115,6 @@ class ImportAccount
$this->accountNumber = $accountNumber;
}
/**
* @param string $expectedType
*/
public function setExpectedType(string $expectedType)
{
$this->expectedType = $expectedType;
}
/**
* @param User $user
*/
@@ -241,6 +249,16 @@ class ImportAccount
$search = intval($array['mapped']);
$account = $this->repository->find($search);
if ($account->accountType->type !== $this->expectedType) {
Log::error(
sprintf(
'Mapped account #%d is of type "%s" but we expect a "%s"-account. Mapping will be ignored.', $account->id, $account->accountType->type,
$this->expectedType
)
);
return new Account;
}
Log::debug(sprintf('Found account! #%d ("%s"). Return it', $account->id, $account->name));
return $account;