Skip to content

Commit

Permalink
Merge pull request #108 from jicka/master
Browse files Browse the repository at this point in the history
Adding simple support for Raiffeisen Schweiz MT940 files.
  • Loading branch information
tarioch authored Jan 29, 2024
2 parents ddca35c + eef1399 commit b559bb1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/importers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ Import mt940 from `Zürcher Kantonalbank <https://www.zkb.ch/>`__
CONFIG = [zkbimp.ZkbImporter("/\d+\.mt940", "Assets:ZKB")]
Raiffeisen CH
-------------

Import mt940 from `Raiffeisen Schweiz <https://www.raiffeisen.ch//>`__

.. code-block:: python
from tariochbctools.importers.raiffeisench import importer as raiffeisenimp
CONFIG = [
raiffeisenimp.RaiffeisenCHImporter("/Konto_CH\d+_\d+\.mt940", "Assets:Raiffeisen")
]
Interactivebrokers
------------------

Expand Down
34 changes: 34 additions & 0 deletions src/tariochbctools/importers/raiffeisench/importer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import re

from tariochbctools.importers.general import mt940importer


class RaiffeisenCHImporter(mt940importer.Importer):
"""An importer for MT940 from Raiffeisen CH"""

"""To get the correct file, choose SWIFT -> 'Période prédéfinie du relevé de compte' -> Sans détails"""

def prepare_payee(self, trxdata):
return ""

def prepare_narration(self, trxdata):
extra = trxdata["extra_details"]
details = trxdata["transaction_details"]

extraReplacements = {}

detailsReplacements = {}
detailsReplacements[r"\n"] = ", "

for pattern, replacement in extraReplacements.items():
extra = re.sub(pattern, replacement, extra)

for pattern, replacement in detailsReplacements.items():
details = re.sub(pattern, replacement, details)

if extra:
narration = extra.strip() + ": " + details.strip()
else:
narration = details.strip()

return narration

0 comments on commit b559bb1

Please sign in to comment.