Working on MT940 importer

Best, Jan-Pascal van j.p.vanbest at tbm.tudelft.nl
Tue Sep 16 12:08:30 CDT 2003


Hi,

The importer now can import my mt940 files. The actual importer
core is quite simple: it just calls HBCI_SWIFTparser_readMT940()
repeatedly, and then uses list_HBCI_Transaction_foreach() with
a callback function based on the one from gnc-hbci-gettrans.c.
Unfortunately, I couldn't just use trans_list_cb() directly
because this function expects to be given the gnucash account
to import to, while in the mt940 importer this information
needs to be deduced from the HBCI data structures.

I guess we should split off the part from trans_list_cb() that 
get the gnucash account from the part that does the actual 
importing, to reduce code duplication.

One other thing: the swift parser in openhbci is incorrect for the
case that the account id in :25: does not contain a '/'. It should
return the entire string in "id" while leaving "instCode" empty,
like this:

    pos=0;
    bool found_inst=false;
    // first read the institute code (BLZ)
    while(pos<tc.length()) {
        if (tc.at(pos)=='/'){
            // store our institute code
            instCode=tc.substr(0,pos);
            found_inst=true;
            break;
        } // if
        pos++;
    } // while

    if(!found_inst)
      pos=0;
    else {
        // then read the account id
        pos++; // skip "/"
        if (pos>=tc.length())
            // no id
            return false;
    }
    id=tc.substr(pos);
    return true;

By the way, why isn't string.find() used here?

> [booking code]
> > Okay. For my bank, it tells what kind of transaction it is 
> (transfer,
> > automatic transfer, cash withdrawal, etc.). Not documented, 
> of course.
> > I've asked the bank Wednesday, but I haven't had a response yet.

I had a response yesterday, telling me how to get the mt940 files 
using the bank's web interface and that the bank had discounts on
financial software that could read the mt940 files. I asked them to
read the question and answer it this time, we'll see that happens...

> I've observed the same thing with one of my banks. However, 
> my other bank uses 
> 999 for any transaction statement, so in this case the code is kinda' 
> useless.

Is there a way to handle "special cases" like this in the code?  It would
probably mean that the parser needs to act differently depending on the
bank that issued the mt940 data.

[:86: tags]
> Hmm, that's completely different from how it is supposed to be...
> However, my parser could check for fields within the :86: tag 
> (they are introduced by a question mark followed by a 2 digit number), 
> and if there is none it could simply add the :86: data to the HBCI::Transaction.
> 
> The content of your tag looks like a purpose description, 
> maybe we should add 
> it to the Transaction::description member. Whould that be ok 
> with you ?

Seems OK. I think it's just the descriptive text they normally
print in the biweekly account overviews.

By the way, I tried the make-gnucash-patch script which created a
multi-megabyte diff, so I'm attaching only the files in
src/import-export/mt940. There are some other changes to be made,
for instance in configure.in and in (I think) src/scm/main.scm, but
they are montly trivial.

What do you think?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile.am
Type: application/octet-stream
Size: 1075 bytes
Desc: Makefile.am
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20030916/c066691f/Makefile.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gncmod-mt940-import.c
Type: application/octet-stream
Size: 3087 bytes
Desc: gncmod-mt940-import.c
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20030916/c066691f/gncmod-mt940-import.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnc-mt940-import.c
Type: application/octet-stream
Size: 8384 bytes
Desc: gnc-mt940-import.c
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20030916/c066691f/gnc-mt940-import.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnc-mt940-import.h
Type: application/octet-stream
Size: 1896 bytes
Desc: gnc-mt940-import.h
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20030916/c066691f/gnc-mt940-import-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mt940-import.scm
Type: application/octet-stream
Size: 307 bytes
Desc: mt940-import.scm
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20030916/c066691f/mt940-import.obj


More information about the gnucash-devel mailing list