-
-
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.
Add an importer for BCGE MT940 exports.
This importer tries to parse the data that BCGE exports in the transaction detail field, namely ORDP, BENM and REMI. This should probably be added to the mt940 library, as it's MT940 specific encoding.
- Loading branch information
Showing
3 changed files
with
42 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
Empty file.
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,31 @@ | ||
import re | ||
|
||
from tariochbctools.importers.general import mt940importer | ||
|
||
|
||
def strip_newline(string): | ||
return string.replace("\n", "").replace("\r", "") | ||
|
||
|
||
class BCGEImporter(mt940importer.Importer): | ||
def prepare_payee(self, trxdata): | ||
transaction_details = strip_newline(trxdata["transaction_details"]) | ||
payee = re.search(r'ORDP/([^/]+)', transaction_details) | ||
if payee is None: | ||
return "" | ||
else: | ||
return payee.group(1) | ||
|
||
def prepare_narration(self, trxdata): | ||
transaction_details = strip_newline(trxdata["transaction_details"]) | ||
extra_details = strip_newline(trxdata["extra_details"]) | ||
beneficiary = re.search( | ||
r'/BENM/([^/]+)', transaction_details) | ||
remittance = re.search( | ||
r'/REMI/([^/]+)', transaction_details) | ||
narration = [] | ||
if beneficiary is not None: | ||
narration.append("Beneficiary: %s" % beneficiary.group(1)) | ||
if remittance is not None: | ||
narration.append("Remittance: %s" % remittance.group(1)) | ||
return ("%s - %s" % (extra_details, ",".join(narration))) |