Skip to content

Commit

Permalink
feat: query permitted order types
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Dec 3, 2024
1 parent 3079ed5 commit 56514e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions banking/ebics/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,30 @@ def download_bank_keys(self):
def activate_bank_keys(self) -> None:
self.bank.activate_keys()

def get_permitted_order_types(self) -> list[str]:
client = self.get_client()
user_data = client.HTD(parsed=True)
permissions = (
user_data.get("HTDResponseOrderData", {}).get("UserInfo", {}).get("Permission", [])
)

return [permission.get("OrderTypes") for permission in permissions]

def download_bank_statements(
self, start_date: str | None = None, end_date: str | None = None
) -> "Iterator[CAMTDocument]":
"""Yield an iterator over CAMTDocument objects for the given date range."""
from fintech.sepa import CAMTDocument

client = self.get_client()
camt53 = client.C53(start_date, end_date)
permitted_types = self.get_permitted_order_types()

try:
camt54 = client.C54(start_date, end_date)
except fintech.ebics.EbicsTechnicalError as e:
camt54 = None
camt53 = client.C53(start_date, end_date)
except fintech.ebics.EbicsNoDataAvailable:
return

camt54 = client.C54(start_date, end_date) if "C54" in permitted_types else None

for name in sorted(camt53):
yield CAMTDocument(xml=camt53[name], camt54=camt54)
Expand Down
1 change: 1 addition & 0 deletions banking/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ Bank Account not found for IBAN {0},Bankkonto nicht gefunden für IBAN {0},
EBICS Host ID,EBICS-Host-ID,
EBICS URL,EBICS-URL,
Usage,Nutzung,
Credentials,Anmeldedaten,

0 comments on commit 56514e0

Please sign in to comment.