Browse Source

🤖 Auto commit for release 'develop' on 2025-06-27

pull/850/head
JC5 4 months ago
parent
commit
4f8c8401d1
No known key found for this signature in database GPG Key ID: 910CF2B5E8B6CC6E
  1. 49
      app/Services/Nordigen/Conversion/Routine/GenerateTransactions.php
  2. 12
      composer.lock
  3. 2
      config/importer.php

49
app/Services/Nordigen/Conversion/Routine/GenerateTransactions.php

@ -90,20 +90,20 @@ class GenerateTransactions
*/
public function collectNordigenAccounts(): void
{
$url = config('nordigen.url');
$accessToken = TokenManager::getAccessToken();
$info = [];
$url = config('nordigen.url');
$accessToken = TokenManager::getAccessToken();
$info = [];
Log::debug('Going to collect account information from Nordigen.');
/**
* @var string $nordigenIdentifier
* @var int $account
* @var int $account
*/
foreach ($this->accounts as $nordigenIdentifier => $account) {
Log::debug(sprintf('Now at #%d => %s', $account, $nordigenIdentifier));
$set = [];
$set = [];
// get account details
$request = new GetAccountInformationRequest($url, $accessToken, $nordigenIdentifier);
$request = new GetAccountInformationRequest($url, $accessToken, $nordigenIdentifier);
$request->setTimeOut(config('importer.connection.timeout'));
// @var ArrayResponse $response
@ -161,14 +161,14 @@ class GenerateTransactions
/**
* @var string $accountId
* @var array $entries
* @var array $entries
*/
foreach ($transactions as $accountId => $entries) {
$total = count($entries);
Log::debug(sprintf('Going to parse account %s with %d transaction(s).', $accountId, $total));
/**
* @var int $index
* @var int $index
* @var Transaction $entry
*/
foreach ($entries as $index => $entry) {
@ -192,13 +192,13 @@ class GenerateTransactions
{
Log::debug(sprintf('Nordigen transaction: "%s" with amount %s %s', $entry->getDescription(), $entry->currencyCode, $entry->transactionAmount));
$return = [
$return = [
'apply_rules' => $this->configuration->isRules(),
'error_if_duplicate_hash' => $this->configuration->isIgnoreDuplicateTransactions(),
'transactions' => [],
];
$valueDate = $entry->getValueDate();
$transaction = [
$valueDate = $entry->getValueDate();
$transaction = [
'type' => 'withdrawal',
'date' => $entry->getDate()->toW3cString(),
'datetime' => $entry->getDate()->toW3cString(),
@ -239,6 +239,7 @@ class GenerateTransactions
// #9533 add entry reference as tag or as booking date.
if ('' !== $entry->entryReference) {
$parsed = null;
try {
$parsed = Carbon::parse($entry->entryReference)->getTimestamp();
} catch (InvalidFormatException $e) {
@ -266,18 +267,18 @@ class GenerateTransactions
private function appendPositiveAmountInfo(string $accountId, array $transaction, Transaction $entry): array
{
// amount is positive: deposit or transfer. Nordigen account is the destination
$transaction['type'] = 'deposit';
$transaction['amount'] = $entry->transactionAmount;
$transaction['type'] = 'deposit';
$transaction['amount'] = $entry->transactionAmount;
// destination is a Nordigen account (has to be!)
$transaction['destination_id'] = (int)$this->accounts[$accountId];
Log::debug(sprintf('Destination ID is now #%d, which should be a Firefly III asset account.', $transaction['destination_id']));
// append source iban and number (if present)
$transaction = $this->appendAccountFields($transaction, $entry, 'source');
$transaction = $this->appendAccountFields($transaction, $entry, 'source');
// TODO clean up mapping
$mappedId = null;
$mappedId = null;
if (isset($transaction['source_name'])) {
Log::debug(sprintf('Check if "%s" is mapped to an account by the user.', $transaction['source_name']));
$mappedId = $this->getMappedAccountId($transaction['source_name']);
@ -304,7 +305,7 @@ class GenerateTransactions
}
}
$transaction = $this->positiveTransactionSafetyCatch($transaction, (string)$entry->getSourceName(), (string)$entry->getSourceIban());
$transaction = $this->positiveTransactionSafetyCatch($transaction, (string)$entry->getSourceName(), (string)$entry->getSourceIban());
Log::debug(sprintf('destination_id = %d, source_name = "%s", source_iban = "%s", source_id = "%s"', $transaction['destination_id'] ?? '', $transaction['source_name'] ?? '', $transaction['source_iban'] ?? '', $transaction['source_id'] ?? ''));
@ -343,7 +344,7 @@ class GenerateTransactions
break;
}
// temp measure to make sure it's a string:
$iban = (string)$iban;
$iban = (string)$iban;
Log::debug('Done collecting account numbers and names.');
if ('' !== $number) {
@ -452,8 +453,8 @@ class GenerateTransactions
*/
private function getAccountType(int $accountId): string
{
$token = SecretManager::getAccessToken();
$url = SecretManager::getBaseUrl();
$token = SecretManager::getAccessToken();
$url = SecretManager::getBaseUrl();
Log::debug(sprintf('Going to download account #%d', $accountId));
$request = new GetAccountRequest($url, $token);
$request->setTimeOut(config('importer.connection.timeout'));
@ -465,7 +466,7 @@ class GenerateTransactions
} catch (ApiHttpException $e) {
throw new ImporterHttpException($e->getMessage(), 0, $e);
}
$type = $result->getAccount()->type;
$type = $result->getAccount()->type;
Log::debug(sprintf('Discovered that account #%d is of type "%s"', $accountId, $type));
@ -507,9 +508,9 @@ class GenerateTransactions
$transaction['source_id'] = (int)$this->accounts[$accountId]; // TODO entry may not exist, then what?
// append source iban and number (if present)
$transaction = $this->appendAccountFields($transaction, $entry, 'destination');
$transaction = $this->appendAccountFields($transaction, $entry, 'destination');
$mappedId = null;
$mappedId = null;
if (isset($transaction['destination_name'])) {
Log::debug(sprintf('Check if "%s" is mapped to an account by the user.', $transaction['destination_name']));
$mappedId = $this->getMappedAccountId($transaction['destination_name']);
@ -520,7 +521,7 @@ class GenerateTransactions
if (null !== $mappedId && 0 !== $mappedId) {
Log::debug(sprintf('Account name "%s" is mapped to Firefly III account ID "%d"', $transaction['destination_name'], $mappedId));
$mappedType = $this->getMappedAccountType($mappedId);
$mappedType = $this->getMappedAccountType($mappedId);
$originalDestName = $transaction['destination_name'];
$transaction['destination_id'] = $mappedId;
@ -537,7 +538,7 @@ class GenerateTransactions
}
}
$transaction = $this->negativeTransactionSafetyCatch($transaction, (string)$entry->getDestinationName(), (string)$entry->getDestinationIban());
$transaction = $this->negativeTransactionSafetyCatch($transaction, (string)$entry->getDestinationName(), (string)$entry->getDestinationIban());
Log::debug(sprintf('source_id = %d, destination_id = "%s", destination_name = "%s", destination_iban = "%s"', $transaction['source_id'], $transaction['destination_id'] ?? '', $transaction['destination_name'] ?? '', $transaction['destination_iban'] ?? ''));

12
composer.lock

@ -8247,16 +8247,16 @@
},
{
"name": "phpunit/phpunit",
"version": "12.2.3",
"version": "12.2.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "60a8ea2d8b2f070000051b56778009e11576e7d1"
"reference": "b71849b29f7a8d7574e4401873cb8b539896613f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/60a8ea2d8b2f070000051b56778009e11576e7d1",
"reference": "60a8ea2d8b2f070000051b56778009e11576e7d1",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b71849b29f7a8d7574e4401873cb8b539896613f",
"reference": "b71849b29f7a8d7574e4401873cb8b539896613f",
"shasum": ""
},
"require": {
@ -8324,7 +8324,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.2.3"
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.2.5"
},
"funding": [
{
@ -8348,7 +8348,7 @@
"type": "tidelift"
}
],
"time": "2025-06-20T11:33:06+00:00"
"time": "2025-06-27T04:37:55+00:00"
},
{
"name": "rector/rector",

2
config/importer.php

@ -24,7 +24,7 @@
declare(strict_types=1);
return [
'version' => '1.7.0',
'version' => 'develop/2025-06-27',
'flows' => ['nordigen', 'spectre', 'file', 'simplefin'],
'enabled_flows' => [
'nordigen' => true,

Loading…
Cancel
Save