mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Routine to make sure imported entries have the correct opposing account and the correct amount.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user