Verified Commit 96a6bf6a authored by Jakob Moser's avatar Jakob Moser
Browse files

Add method to get the FinTS account

One FinTS client might have access to more than one account. We query for all accounts (because that is how the tutorial did it), and then filter for our account using the IBAN.
parent 9195c1f8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ from collections.abc import Generator
from contextlib import contextmanager

from fints.client import FinTS3PinTanClient
from fints.models import SEPAAccount
from schwifty import IBAN
from sqlalchemy.orm import Mapped, mapped_column

@@ -45,3 +46,8 @@ class BankAccount(Base):
        )
        with client:
            yield client

    def _fints_account(self, client: FinTS3PinTanClient) -> SEPAAccount:
        accounts = client.get_sepa_accounts()
        return next(account for account in accounts if account.iban == str(self.iban))