diff --git a/fints/client.py b/fints/client.py index 3fcb3b7..6b9c682 100644 --- a/fints/client.py +++ b/fints/client.py @@ -567,17 +567,27 @@ def _response_handler_get_transactions_xml(responses): return booked_streams, pending_streams def get_transactions_xml(self, account: SEPAAccount, start_date: datetime.date = None, - end_date: datetime.date = None) -> list: + end_date: datetime.date = None, supported_camt_messages = None) -> list: """ - Fetches the list of transactions of a bank account in a certain timeframe as camt.052.001.02 XML files. + Fetches the list of transactions of a bank account in a certain timeframe as camt XML files. Returns both booked and pending transactions. :param account: SEPA :param start_date: First day to fetch :param end_date: Last day to fetch + :param supported_camt_messages: Names of accepted camt formats. If `None`, we'll accept whatever the bank offers. :return: Two lists of bytestrings containing XML documents, possibly empty: first one for booked transactions, second for pending transactions """ + hicazs = self.bpd.find_segment_first('HICAZS') + if hicazs: + bank_supported_camt_messages = list(hicazs.parameter.supported_camt_formats) + else: + bank_supported_camt_messages = [] + if supported_camt_messages is None: + supported_camt_messages = bank_supported_camt_messages + else: + supported_camt_messages = [m for m in supported_camt_messages if m in bank_supported_camt_messages] with self._get_dialog() as dialog: hkcaz = self._find_highest_supported_command(HKCAZ1) @@ -591,7 +601,7 @@ def get_transactions_xml(self, account: SEPAAccount, start_date: datetime.date = date_start=start_date, date_end=end_date, touchdown_point=touchdown, - supported_camt_messages=SupportedMessageTypes(['urn:iso:std:iso:20022:tech:xsd:camt.052.001.02']), + supported_camt_messages=SupportedMessageTypes(supported_camt_messages), ), FinTS3Client._response_handler_get_transactions_xml, 'HICAZ' diff --git a/fints/formals.py b/fints/formals.py index 877c0be..2d9d907 100644 --- a/fints/formals.py +++ b/fints/formals.py @@ -919,6 +919,16 @@ class ScheduledBatchDebitParameter1(DataElementGroup): single_booking_allowed = DataElementField(type='jn', _d="Einzelbuchung erlaubt") +class TransactionsTimeParameter1(DataElementGroup): + """Parameter Kontoumsätze/Zeitraum camt, version 1 + + Source: FinTS Financial Transaction Services, Schnittstellenspezifikation, Messages -- Multibankfähige Geschäftsvorfälle """ + storage_duration = DataElementField(type='num', max_length=4, _d="Speicherzeitraum") + entry_number_entries_allowed = DataElementField(type='jn', _d="Eingabe Anzahl Einträge erlaubt") + all_accounts_allowed = DataElementField(type='jn', _d="Alle Konten erlaubt") + supported_camt_formats = DataElementField(type='an', max_length=256, max_count=99, required=False, _d="Unterstützte camt-Datenformate") + + class ScheduledBatchDebitParameter2(DataElementGroup): """Parameter terminierte SEPA-Sammellastschrift einreichen, version 2 diff --git a/fints/segments/statement.py b/fints/segments/statement.py index bc45c95..58dd5f5 100644 --- a/fints/segments/statement.py +++ b/fints/segments/statement.py @@ -1,6 +1,6 @@ from fints.fields import DataElementField, DataElementGroupField, CodeField from fints.formals import KTI1, Account2, Account3, QueryCreditCardStatements2, SupportedMessageTypes, \ - BookedCamtStatements1, StatementFormat, Confirmation, ReportPeriod2 + BookedCamtStatements1, StatementFormat, Confirmation, ReportPeriod2, TransactionsTimeParameter1 from .base import FinTS3Segment, ParameterSegment @@ -90,6 +90,13 @@ class DIKKUS2(ParameterSegment): parameter = DataElementGroupField(type=QueryCreditCardStatements2, _d="Parameter Kreditkartenumsätze anfordern") +class HICAZS1(ParameterSegment): + """Kontoumsätze/Zeitraum camt Parameter, version 1 + + Source: FinTS Financial Transaction Services, Schnittstellenspezifikation, Messages -- Multibankfähige Geschäftsvorfälle """ + parameter = DataElementGroupField(type=TransactionsTimeParameter1, _d="Parameter Kontoumsätze/Zeitraum camt") + + class HKCAZ1(FinTS3Segment): """Kontoumsätze anfordern/Zeitraum, version 5