GNOME Bugzilla – Bug 325170
Importing of SWIFT MT 940 files
Last modified: 2018-06-29 20:54:48 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 -------
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.
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
Created attachment 56674 [details] [review] mt940.patch just some testing how it could be done. No real working code.
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.
Code applied to SVN, r12835. You're very invited to continue your work on this :-))
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
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.
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
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.
1. I would like to, but to do so i need an testaccount for hbci. 2. I'm updating to aqbanking 1.9.6
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 *** )
... 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.
sorry, didn't intend to close this as "fixed" before it is really fixed.
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.
+ Trace 66561
Thread 16384 (LWP 21914)
i'm in progress with the test hbci account. https://bugzilla.kapott.org/show_bug.cgi?id=31
backtrace was from svn 13413.
Created attachment 60352 [details] gnucashtest.940 Finally the mt940 test file, genrated from the "VR-Networld" export.
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?
Note to self: replace gnc_extract_directory by g_path_get_dirname from glib.
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.
Correction: Completely fixed in r13444 now.
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.