GNOME Bugzilla – Bug 624911
Add the ability to import invoices and purchase orders (Bills)
Last modified: 2018-06-29 22:42:10 UTC
Created attachment 166266 [details] Extract with "tar zxvf invoice_importer.tgz" in the project root dir. I often make purchases of electronic components with often 30-50 lines in the purchase order. Some of the PO is for stock (assets?), some for a specific project(expense or stock?) and some of it may be tools (assets). Manually re-inputting a PO into GnuCash is a PITA and since most vendors offer a order download in CSV format a better solution is wanted. With a simple Python script to massage their CSV into the correct format the import becomes trivial and each PO line can be manually assigned to the correct account. Untar'ing will create plugins/... in the src dir. To use users will need to create or edit their ~/.gnucash/config.user adding the following lines: (gnc:module-load "gnucash/plugins/customer_import" 0) (gnc:module-load "gnucash/plugins/invoice_import" 0) (gnc:module-load "gnucash/plugins/bill_import" 0) This is for Linux, I've no idea where this file is in Windows.
Created attachment 166267 [details] [review] Adds plugin tree to build Missing patch to add plugins to build.
Comment on attachment 166267 [details] [review] Adds plugin tree to build I'm afraid I have to ask for some additional work in the original code contribution (of course this single patch is only the final clean-up work). The contribution of these three importers contains a lot of duplicated code. I agree there should be three separate menu items for each of the three imports. But don't you think you could implement that action inside on single gnucash plugin instead of three? And, pushing this further, wouldn't it be possible to re-use the majority of the code so that the only difference between the three imports is the file format regex and the place where the data is stored? But all other GUI and setup code is pretty much the same (except for different GUI labels, which will then of course need to be adapted), and thus they should be refactored into common code, if possible. One side-note regarding GUI labels: Please don't unify this too much by starting to use sprintf-string, like "Import %s" where %s is {Customer,Bill,Invoice} - this sort of strings are impossible to translate correctly. Instead, use three different strings "Import Customer", "Import Bill", "Import Invoice" and switch between those. Thanks!
Oh, but in principle I think your code is a very good contribution and looks very good to be committed! Thanks a lot. (I'm just hesitating to commit this obviously three-fold duplicated code...) I would like to commit this very much.
I agree there is far too much duplicated code and much re-factoring is needed before adding to a release. I wanted to test the principle and to see if others thought it an useful enhancement. I'm pretty sure the original author is no longer interested in maintaining this code. In which case I'll look at re-factoring. It might take a while though! Some of the code has been incorporated in Bug 625193 so at least that could be removed from this as a start.
Ok. I indeed think this is very useful enhancement. Feel free to submit your patches again - I'll happily review those (even though I might have delays of 1-2 weeks until I have spare time for this, unfortunately). The common functions can readily be moved into src/engine/ as soon as they compile. The code from bug#625193 is in SVN now, so you can send patches to move it within SVN into places which are more appropriate. But in any case, feel free to take your time on this. There's no need to hurry but the code is a good enhancement in any case.
Is the content of this bug already implemented by the recent src/engine/ additions?
(In reply to comment #6) > Is the content of this bug already implemented by the recent src/engine/ > additions? No, but the search on ID is a part of the solution and had to go in first. I have refactored the code I originally sent in to a single plugin. I'll post it here this week. I'm still looking through it, but it seems to work as it should.
Created attachment 170232 [details] [review] Adds the ability to create invoices and bills from CSV data. Add a module to create invoices and bills from CSV data. The CSV file has to follow a specific format which can be derived from the regex. Alternatively the regex can be edited in the dialog box. I've used simple Python scripts to massage data into the correct format. Users need to add (gnc:module-load "gnucash/plugins/bi_import" 0) to their ~/.gnucash/config.user file in order to use this plugin. Obviously needs much testing and I need to write documentation if this approved. NEEDS: Documenting. Ability to load user custom regexes or more flexible field allocation. Import from CSV will append existing invoices/bills with the same ID unless they are posted, in which case no import/create is performed. The append feature could be a curse or a benefit. I'll await feedback.
Comment on attachment 170232 [details] [review] Adds the ability to create invoices and bills from CSV data. Changes to trunk sources and minor changes to this plugin have made this patch obsolete.
(In reply to comment #9) > Changes to trunk sources and minor changes to this plugin have made this patch > obsolete. It does? I was hoping this patch and new feature can now get into SVN...
(In reply to comment #10) > > It does? I was hoping this patch and new feature can now get into SVN... Don't panic! I'll update it, test it and re-submit in a day or two. QueryNew.h and QueryCore.h have been renamed which broke the patch so I thought I'd have a look through the code again and see if anything can be improved.
(In reply to comment #11) > Don't panic! I'll update it, test it and re-submit in a day or two. QueryNew.h > and QueryCore.h have been renamed which broke the patch so I thought I'd have > a look through the code again and see if anything can be improved. Oh, right. Yes, I *removed* those two files because they didn't contain anything else except a bunch of #defines from deprecated names to the up-to-date names. In case you used any of the deprecated names, you will need to find out the new names for yourself, unfortunately (or by browsing to a revision that still had those files). Sorry for that.
Commited to SVN as r20034. Please test and leave feedback.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=624911. Please update any external references or bookmarks.