After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 325170 - Importing of SWIFT MT 940 files
Importing of SWIFT MT 940 files
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Import - Other
git-master
Other other
: Normal enhancement
: ---
Assigned To: Christian Stimming
Christian Stimming
Depends on:
Blocks:
 
 
Reported: 2005-12-28 21:17 UTC by Florian Steinel
Modified: 2018-06-29 20:54 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
mt940.patch (2.44 KB, patch)
2006-01-02 18:56 UTC, Florian Steinel
committed Details | Review
gnucashtest.940 (239 bytes, text/plain)
2006-02-28 20:41 UTC, Florian Steinel
  Details

Description Florian Steinel 2005-12-28 21:17:40 UTC
Distribution: Gentoo Base System version 1.6.13
Package: GnuCash
Severity: enhancement
Version: GNOME2.10.2 CVS
Gnome-Distributor: Gentoo
Synopsis: add omport druid for SWIFT MT 940
Bugzilla-Product: GnuCash
Bugzilla-Component: Import
Bugzilla-Version: CVS
Description:
Please describe your feature request:

StarMoney and VR-NetWorld provides an exports to S.W.i.F.T. MT 940.
It would be nice to have an importer for this, see

http://www.google.de/search?hl=en&q=SWIFT+MT+940+Format
https://www.companyworld.de/de/support/download_center/files/mt940.pdf
http://www.google.com/search?q=site%3Awww.hbci-zka.de%20MT%20940&ie=UTF-8&oe=UTF-8
http://www.zahlungsverkehrsfragen.de/formate.html#mt940
http://www.sskduesseldorf.de/downloads/pdf/datensatzbeschreibung-mt940.pdf
http://de.wikipedia.org/wiki/SWIFT
http://www.hbci-zka.de/dokumente/spezifikation_deutsch/HBCI22d.pdf <-
detailed description of MT 940 on page 132
for the format specs.
ping me for testdata or anything else you need
or give me some hints where to start myself




------- Bug created by bug-buddy at 2005-12-28 21:17 -------

Comment 1 Christian Stimming 2006-01-02 11:31:23 UTC
There used to be a MT940 importer in CVS-HEAD at the time when HBCI support was implemented by openhbci1 and most of the work could be re-used from the HBCI module. After the transition of HBCI to aqbanking, the existing MT940 importer could not be used any longer and was disabled from compilation. 

Nevertheless aqbanking also has a MT940 importer module inside, and again most of ; you would "just" need to read in the aqbanking documentation and/or ask their developers how to do that. And again most of the required work could directly be re-used from gnucash's HBCI module. It's just not in there because nobody was working on it since the aqbanking transition.
Comment 2 Florian Steinel 2006-01-02 17:21:16 UTC
for example one pointer is in the aqbanking package the file
src/tools/aqbanking-tools/import.c .
manuell workaround:
aqbanking-tool import --ctxfile=imported.ctx --importer=swift --infile=thefilename.940 --profile=SWIFT-MT940
aqbanking-tool listtrans --ctxfile=imported.ctx --outfile=result.csv
Comment 3 Florian Steinel 2006-01-02 18:56:09 UTC
Created attachment 56674 [details] [review]
mt940.patch

just some testing how it could be done. No real working code.
Comment 4 Christian Stimming 2006-01-04 10:33:48 UTC
Oh, you are actually working on the import-export/mt940 module? I'll happily apply your changes to the gnucash SVN. No matter if it doesn't work (yet), since the existing code will work even less :-). I'll commit that later today, and you or anyone else can try to improve that.
Comment 5 Christian Stimming 2006-01-17 21:27:09 UTC
Code applied to SVN, r12835. You're very invited to continue your work on this :-))
Comment 6 Christian Stimming 2006-01-24 13:38:07 UTC
Some internal notes: Die Implementierung vom mt940-Importer war daher darauf ausgelegt, sich aus der hbci-lib die Liste der (seinerzeit) HBCI_Transactions zu besorgen, diese dann an den existierenden anderen Code weiterzugeben und fertig ist. *blätter blätter* Oh, ich stelle fest, dass dazu die passende Funktion im hbci-Modul nicht mehr direkt vorhanden ist. Früher wurde wohl der Inhalt von gnc_hbci_gettrans_final() in hbci/gnc-hbci-gettrans.c benutzt. Das wäre jetzt wieder verfügbar, wenn ich den Teil ab Vorhandensein einer AB_TRANSACTION_LIST2 eben in eine separate Funktion packe, die dann vom mt940/gnc-mt940-import.c aus aufgerufen wird.

Andererseits geht jene Funktion davon aus, dass der Gnucash-Account (der "LocalAccount") bereits bekannt ist, was ja bei HBCI immer der Fall ist und technisch so gelöst ist, dass die HBCI-Menüpunkte nur innerhalb eines Kontofensters erreichbar sind (und damit der gnucash-Account vom aktuellen Kontofenster implizit der "LocalAccount" ist). Da müsste man bei mt940 nochmal sich was einfallen lassen, also ggf. eine zusätzliche Auswahl durch gnc_import_select_account() machen lassen.

Und dann ist natürlich noch das "Problem", dass man via "AB_ImExporter_Import() -> AB_ImExporterContext_GetFirstAccountInfo() / NextAccountInfo() -> AB_ImExporterAccountInfo_GetFirstTransaction() / NextTransaction()" keine vollständige AB_TRANSACTION_LIST2 in die Hand bekommt (intern ist das eine AB_TRANSACTION_LIST). Da würde ich wohl in gnucash eine kleine Konverter-Funktion einbauen
Comment 7 Christian Stimming 2006-02-24 21:59:50 UTC
Okay. There is a mt940 importer module now in SVN r13380 that actually compiles. Now someone would have to test it with a mt940 test file. (Requires aqbanking-1.9.7 and at gnucash configure --enable-hbci and --enable-mt940). Please report back if a test with real files worked.
Comment 8 Florian Steinel 2006-02-25 17:38:14 UTC
I'm testing with gnucash svn 13387 / aqbanking-1.6.0_beta and get this:
distcc[21356] ERROR: compile /var/tmp/ccache/gnc-mt940-.tmp.r2d2.21352.i on localhost failed
gnc-mt940-import.c:78: error: parse error before "AB_IMEXPORTER_ACCOUNTINFO_LIST2_FOREACH"
gnc-mt940-import.c: In function `AB_ImExporterContext_AccountInfoForEach':
gnc-mt940-import.c:83: error: `iec' undeclared (first use in this function)
gnc-mt940-import.c:83: error: (Each undeclared identifier is reported only once
gnc-mt940-import.c:83: error: for each function it appears in.)
gnc-mt940-import.c:87: error: `user_data' undeclared (first use in this function)
gnc-mt940-import.c:87: warning: assignment makes pointer from integer without a cast
gnc-mt940-import.c: At top level:
gnc-mt940-import.c:98: error: parse error before "AB_TRANSACTION_CONSTLIST2_FOREACH"
gnc-mt940-import.c: In function `AB_ImExporterAccountInfo_TransactionsForEach':
gnc-mt940-import.c:103: error: `iea' undeclared (first use in this function)
gnc-mt940-import.c:107: error: `user_data' undeclared (first use in this function)
gnc-mt940-import.c:107: warning: assignment makes pointer from integer without a cast
make[5]: *** [gnc-mt940-import.lo] Fehler 1

Comment 9 Christian Stimming 2006-02-25 18:07:11 UTC
1. Please attach an mt940 test file so that I can test myself, too.
2. compile error shows up because of your old aqbanking; anyway, it's fixed in r13388 now.
Comment 10 Florian Steinel 2006-02-25 18:20:51 UTC
1. I would like to, but to do so i need an testaccount for hbci.
2. I'm updating to aqbanking 1.9.6
Comment 11 Florian Steinel 2006-02-26 11:56:16 UTC
Ok, testing gnucash svn 13388 now with mt940 (aqbanking-1.9.6):
- Create an new File
- Start mt940 import
- gnucash hangs (as in no screen updates)
(console says: 
*** glibc detected *** double free or corruption (fasttop): 0x08534b78 ***
)
Comment 12 Christian Stimming 2006-02-26 15:00:00 UTC
... what about a test file? Also, the console output is definitely not sufficient; we would need a stack trace at least. See http://linuxwiki.de/gdb in German for stack trace.
Comment 13 Christian Stimming 2006-02-27 10:23:25 UTC
sorry, didn't intend to close this as "fixed" before it is really fixed.
Comment 14 Florian Steinel 2006-02-27 18:37:54 UTC
I've copied gnucash to ~/gnucash replaced gnucash-bin with gdb and run gnucash-bin from gdb:

/usr/bin/gnucash-bin:1: parser error : Start tag expected, '<' not foundELF^
/usr/bin/gnucash-bin:1: parser error : Start tag expected, '<' not foundELF^
/usr/bin/gnucash-bin:1: parser error : Start tag expected, '<' not foundELF^
[New Thread 32769 (LWP 21940)]
[New Thread 16386 (LWP 21941)]
[New Thread 32771 (LWP 21942)]
*** glibc detected *** double free or corruption (fasttop): 0x0853ace0 ***

Program received signal SIGABRT, Aborted.

Thread 16384 (LWP 21914)

  • #0 kill
    from /lib/libc.so.6
  • #1 pthread_kill
    from /lib/libpthread.so.0
  • #2 raise
    from /lib/libpthread.so.0
  • #3 raise
    from /lib/libc.so.6
  • #4 abort
    from /lib/libc.so.6
  • #5 __fsetlocking
    from /lib/libc.so.6
  • #6 mallopt
    from /lib/libc.so.6
  • #7 mallopt
    from /lib/libc.so.6
  • #8 free
    from /lib/libc.so.6
  • #9 gnc_extract_directory
    from /usr/lib/gnucash/libgncmod-app-utils.so.0
  • #10 gnc_file_mt940_import
    from /usr/lib/gnucash/libgncmod-mt940.so.0
  • #11 gnc_plugin_mt940_cmd_import
    from /usr/lib/gnucash/libgncmod-mt940.so.0
  • #12 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #13 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #14 g_signal_has_handler_pending
    from /usr/lib/libgobject-2.0.so.0
  • #15 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #16 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #17 gtk_action_create_menu_item
    from /usr/lib/libgtk-x11-2.0.so.0
  • #18 gtk_action_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #19 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #20 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #21 g_signal_has_handler_pending
    from /usr/lib/libgobject-2.0.so.0
  • #22 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #23 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #24 gtk_widget_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #25 gtk_menu_shell_activate_item
    from /usr/lib/libgtk-x11-2.0.so.0
  • #26 gtk_menu_shell_activate_item
    from /usr/lib/libgtk-x11-2.0.so.0
  • #27 gtk_menu_reorder_child
    from /usr/lib/libgtk-x11-2.0.so.0
  • #28 gtk_marshal_VOID__UINT_STRING
    from /usr/lib/libgtk-x11-2.0.so.0
  • #29 g_cclosure_new_swap
    from /usr/lib/libgobject-2.0.so.0
  • #30 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #31 g_signal_has_handler_pending
    from /usr/lib/libgobject-2.0.so.0
  • #32 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #33 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #34 gtk_widget_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #35 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #36 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #37 gdk_event_get_graphics_expose
    from /usr/lib/libgdk-x11-2.0.so.0
  • #38 g_source_remove_poll
    from /usr/lib/libglib-2.0.so.0
  • #39 g_main_context_acquire
    from /usr/lib/libglib-2.0.so.0
  • #40 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #41 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #42 gnc_ui_start_event_loop
    from /usr/lib/gnucash/libgncmod-gnome-utils.so.0
  • #43 inner_main
  • #44 scm_init_guile
    from /usr/lib/libguile.so.12
  • #45 scm_init_guile
    from /usr/lib/libguile.so.12
  • #46 scm_boot_guile
    from /usr/lib/libguile.so.12
  • #47 main

Comment 15 Florian Steinel 2006-02-27 19:57:11 UTC
i'm in progress with the test hbci account.
https://bugzilla.kapott.org/show_bug.cgi?id=31
Comment 16 Florian Steinel 2006-02-27 19:59:42 UTC
backtrace was from svn 13413.
Comment 17 Florian Steinel 2006-02-28 20:41:33 UTC
Created attachment 60352 [details]
gnucashtest.940

Finally the mt940 test file, genrated from the "VR-Networld" export.
Comment 18 Christian Stimming 2006-03-02 12:25:06 UTC
Ok, I still didn't have time to commit this to SVN, but according to src/app-utils/gnc-ui-util.h one has to insert an extra line before the "gnc_extract_directory" command which reads 

  default_dir = NULL;

What happens with this change?
Comment 19 Christian Stimming 2006-03-02 14:38:55 UTC
Note to self: replace gnc_extract_directory by g_path_get_dirname from glib.
Comment 20 Christian Stimming 2006-03-02 21:53:04 UTC
This crash fixed in r13440. However, there's a different crash now with a failed assertion in the gwenhywfar library, "bufferedio.c:234: GWEN_BufferedIO_PeekChar: assert failed", which I don't know how to fix yet.
Comment 21 Christian Stimming 2006-03-02 22:04:48 UTC
Correction: Completely fixed in r13444 now.
Comment 22 John Ralls 2018-06-29 20:54:48 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=325170. Please update any external references or bookmarks.