Merge pull request #9202 from paulwer/fix-nordigen-9198

FIX: Nordigen Import Error, when missing transactionId from instituition
This commit is contained in:
David Bomba 2024-01-28 08:30:37 +11:00 committed by GitHub
commit 3ad0a255fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,9 +81,16 @@ class TransactionTransformer implements BankRevenueInterface
public function transformTransaction($transaction) public function transformTransaction($transaction)
{ {
// depending on institution, the result can be different, so we load the first available unique id
if (!array_key_exists('transactionId', $transaction) || !array_key_exists('transactionAmount', $transaction)) $transactionId = '';
throw new \Exception('invalid dataset'); if (array_key_exists('transactionId', $transaction))
$transactionId = $transaction["transactionId"];
else if (array_key_exists('internalTransactionId', $transaction))
$transactionId = $transaction["internalTransactionId"];
else {
nlog(`Invalid Input for nordigen transaction transformer: ` . $transaction);
throw new \Exception('invalid dataset: missing transactionId - Please report this error to the developer');
}
$amount = (float) $transaction["transactionAmount"]["amount"]; $amount = (float) $transaction["transactionAmount"]["amount"];
@ -119,7 +126,7 @@ class TransactionTransformer implements BankRevenueInterface
return [ return [
'transaction_id' => 0, 'transaction_id' => 0,
'nordigen_transaction_id' => $transaction["transactionId"], 'nordigen_transaction_id' => $transactionId,
'amount' => $amount, 'amount' => $amount,
'currency_id' => $this->convertCurrency($transaction["transactionAmount"]["currency"]), 'currency_id' => $this->convertCurrency($transaction["transactionAmount"]["currency"]),
'category_id' => null, 'category_id' => null,