]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Allow to request pending transactions
authorRaphael Michel <michel@rami.io>
Sat, 26 Oct 2024 12:46:56 +0000 (14:46 +0200)
committerRaphael Michel <michel@rami.io>
Sat, 26 Oct 2024 12:46:56 +0000 (14:46 +0200)
fints/client.py

index 0931e549bc58c4dbb869fa393a6e9a1c97d2b7b0..42584dbcebf42b97ae2240d8e4732e8935003c87 100644 (file)
@@ -512,13 +512,15 @@ class FinTS3Client:
         else:
             return version_map.get(max_version.header.version)
 
-    def get_transactions(self, account: SEPAAccount, start_date: datetime.date = None, end_date: datetime.date = None):
+    def get_transactions(self, account: SEPAAccount, start_date: datetime.date = None, end_date: datetime.date = None,
+                         include_pending = False):
         """
         Fetches the list of transactions of a bank account in a certain timeframe.
 
         :param account: SEPA
         :param start_date: First day to fetch
         :param end_date: Last day to fetch
+        :param include_pending: Include pending transactions (might lack some data like booking day)
         :return: A list of mt940.models.Transaction objects
         """
 
@@ -535,7 +537,10 @@ class FinTS3Client:
                     date_end=end_date,
                     touchdown_point=touchdown,
                 ),
-                lambda responses: mt940_to_array(''.join([seg.statement_booked.decode('iso-8859-1') for seg in responses])),
+                lambda responses: mt940_to_array(''.join(
+                    [seg.statement_booked.decode('iso-8859-1') for seg in responses] +
+                    ([seg.statement_pending.decode('iso-8859-1') for seg in responses] if include_pending else [])
+            )),
                 'HIKAZ',
                 # Note 1: Some banks send the HIKAZ data in arbitrary splits.
                 # So better concatenate them before MT940 parsing.