joonis Logo

Processing CAMT documents

If orders were submitted in batch mode, there are three methods to resolve the underlying transactions. Either (A) directly within the CAMT52/CAMT53 document, (B) within a separate CAMT54 document or (C) by a reference to the originally transferred PAIN message. The applied method depends on the bank (method B is most commonly used). It could be handeled differently for incoming and outgoing transactions.

from __future__ import print_function

import fintech

from fintech.ebics import EbicsKeyRing, EbicsBank, EbicsUser, EbicsClient
from fintech.sepa import CAMTDocument

keyring = EbicsKeyRing(keys='~/mykeys', passphrase='mysecret')
bank = EbicsBank(keyring=keyring, hostid='MYBANK', url='')
user = EbicsUser(keyring=keyring, partnerid='CUSTOMER123', userid='USER1')

start = '2016-11-01'
end = '2016-11-30'

with EbicsClient(bank, user) as client:

    camt53 = client.C53(start, end)
    camt54 = client.C54(start, end)

    for name in sorted(camt53):
        doc = CAMTDocument(camt53[name], camt54)
        print('transactions for account:', doc.iban)
        for trans in doc:
            if trans.batch:
                if len(trans):
                    for subtrans in trans:
                        print(,, subtrans.purpose, subtrans.amount)
                elif trans.kref:
                    # Batch transactions referenced by KREF (method C)
                    for subtrans in get_submitted_transactions_by_kref(trans.kref):
                        print(, subtrans['name'], subtrans['purpose'], subtrans['amount'])
                    raise RuntimeError('Unresolved batch transaction')
                print(,, trans.purpose, trans.amount)

Can I
  help you?

Just drop me a line at