mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-02 03:51:18 +00:00
Fix #1564
This commit is contained in:
@@ -50,6 +50,8 @@ class StageImportDataHandler
|
||||
private $accountRepository;
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var array */
|
||||
private $jobConfiguration;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $repository;
|
||||
/** @var array */
|
||||
@@ -71,10 +73,11 @@ class StageImportDataHandler
|
||||
public function run(): void
|
||||
{
|
||||
$this->getContext();
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
$mapping = $config['mapping'] ?? [];
|
||||
$collection = [[]];
|
||||
$config = $this->repository->getConfiguration($this->importJob);
|
||||
$accounts = $config['accounts'] ?? [];
|
||||
$mapping = $config['mapping'] ?? [];
|
||||
$collection = [[]];
|
||||
$this->jobConfiguration = $config;
|
||||
/** @var array $bunqAccount */
|
||||
foreach ($accounts as $bunqAccount) {
|
||||
$bunqAccountId = $bunqAccount['id'] ?? 0;
|
||||
@@ -192,9 +195,24 @@ class StageImportDataHandler
|
||||
*/
|
||||
private function convertToAccount(LabelMonetaryAccount $party, string $expectedType): LocalAccount
|
||||
{
|
||||
Log::debug('in convertToAccount()');
|
||||
|
||||
Log::debug(sprintf('in convertToAccount() with LabelMonetaryAccount: %s', ''));
|
||||
if (null !== $party->getIban()) {
|
||||
// find opposing party by IBAN first.
|
||||
// find account in 'bunq-iban' array first.
|
||||
$bunqIbans = $this->jobConfiguration['bunq-iban'] ?? [];
|
||||
if (isset($bunqIbans[$party->getIban()])) {
|
||||
$accountId = (int)$bunqIbans[$party->getIban()];
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
if (null !== $result) {
|
||||
Log::debug(
|
||||
sprintf('Search for #%s (based on IBAN %s) resulted in account %s (#%d)', $accountId, $party->getIban(), $result->name, $result->id)
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// find opposing party by IBAN second.
|
||||
$result = $this->accountRepository->findByIbanNull($party->getIban(), [$expectedType]);
|
||||
if (null !== $result) {
|
||||
Log::debug(sprintf('Search for %s resulted in account %s (#%d)', $party->getIban(), $result->name, $result->id));
|
||||
|
||||
@@ -150,6 +150,7 @@ class StageNewHandler
|
||||
'balance' => $mab->getBalance(),
|
||||
'status' => $mab->getStatus(),
|
||||
'type' => 'MonetaryAccountBank',
|
||||
'iban' => null,
|
||||
'aliases' => [],
|
||||
];
|
||||
|
||||
@@ -168,6 +169,11 @@ class StageNewHandler
|
||||
'name' => $alias->getName(),
|
||||
'value' => $alias->getValue(),
|
||||
];
|
||||
|
||||
// store IBAN alias separately:
|
||||
if ('IBAN' === $alias->getType()) {
|
||||
$return['iban'] = $alias->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user