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 624911 - Add the ability to import invoices and purchase orders (Bills)
Add the ability to import invoices and purchase orders (Bills)
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Business
git-master
Other All
: Normal enhancement
: ---
Assigned To: Derek Atkins
Derek Atkins
Depends on:
Blocks:
 
 
Reported: 2010-07-21 10:19 UTC by Mike Evans
Modified: 2018-06-29 22:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Extract with "tar zxvf invoice_importer.tgz" in the project root dir. (886.91 KB, application/x-gzip)
2010-07-21 10:19 UTC, Mike Evans
  Details
Adds plugin tree to build (1.86 KB, patch)
2010-07-21 11:05 UTC, Mike Evans
needs-work Details | Review
Adds the ability to create invoices and bills from CSV data. (79.41 KB, patch)
2010-09-14 10:25 UTC, Mike Evans
accepted-commit_after_freeze Details | Review

Description Mike Evans 2010-07-21 10:19:02 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.
Comment 1 Mike Evans 2010-07-21 11:05:36 UTC
Created attachment 166267 [details] [review]
Adds plugin tree to build

Missing patch to add plugins to build.
Comment 2 Christian Stimming 2010-08-14 20:45:13 UTC
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!
Comment 3 Christian Stimming 2010-08-14 20:47:10 UTC
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.
Comment 4 Mike Evans 2010-08-15 15:57:07 UTC
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.
Comment 5 Christian Stimming 2010-08-16 07:03:12 UTC
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.
Comment 6 Christian Stimming 2010-09-13 07:34:11 UTC
Is the content of this bug already implemented by the recent src/engine/ additions?
Comment 7 Mike Evans 2010-09-13 08:16:38 UTC
(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.
Comment 8 Mike Evans 2010-09-14 10:25:42 UTC
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 9 Mike Evans 2010-12-29 13:21:54 UTC
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.
Comment 10 Christian Stimming 2010-12-29 20:57:12 UTC
(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...
Comment 11 Mike Evans 2010-12-30 10:14:29 UTC
(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.
Comment 12 Christian Stimming 2010-12-30 10:43:15 UTC
(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.
Comment 13 Mike Evans 2011-01-07 14:25:43 UTC
Commited to SVN as r20034.
Please test and leave feedback.
Comment 14 John Ralls 2018-06-29 22:42:10 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=624911. Please update any external references or bookmarks.