-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from jicka/master
Adding simple support for Raiffeisen Schweiz MT940 files.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |