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 730255 - Python bindings: Assigns bill entries to non-existant invoice.
Python bindings: Assigns bill entries to non-existant invoice.
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Python Bindings
git-master
Other Linux
: Low normal
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2014-05-16 14:50 UTC by Mike Evans
Modified: 2018-06-29 23:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Check invoice type matches invoice-entry type. (4.27 KB, patch)
2014-05-27 12:27 UTC, Mike Evans
none Details | Review
Supercede previous patch (4.30 KB, patch)
2014-05-27 12:40 UTC, Mike Evans
none Details | Review

Description Mike Evans 2014-05-16 14:50:30 UTC
When creating a bill using python bindings the entries are assigned not to a bill guid but to an invoice guid, that doesn't exist.

The xml for one of the offending entries looks like:

<gnc:GncEntry version="2.0.0">
  <entry:guid type="guid">205b57c6bac13c57ac21baf7a30f1c5c</entry:guid>
  <entry:date>
    <ts:date>2014-04-30 00:00:00 +0100</ts:date>
  </entry:date>
  <entry:entered>
    <ts:date>2014-05-16 00:00:00 +0100</ts:date>
  </entry:entered>
  <entry:description>Diffused LEDs 3mm Red</entry:description>
  <entry:action>EA</entry:action>
  <entry:qty>1/1</entry:qty>
  <entry:invoice type="guid">7ac7a873a8c54e44070d07a3237c07fb</entry:invoice>
  <entry:i-disc-type>PERCENT</entry:i-disc-type>
  <entry:i-disc-how>PRETAX</entry:i-disc-how>
  <entry:i-taxable>1</entry:i-taxable>
  <entry:i-taxincluded>0</entry:i-taxincluded>
  <entry:b-acct type="guid">eb60e5a94a74c7f988d2c60d2667d128</entry:b-acct>
  <entry:b-price>145/100</entry:b-price>
  <entry:b-taxtable type="guid">29287e0f829355c915198d5382a47d25</entry:b-taxtable>
</gnc:GncEntry>

The erronious line is:
<entry:invoice type="guid">7ac7a873a8c54e44070d07a3237c07fb</entry:invoice>

It should be:
<entry:bill type="guid">7ac7a873a8c54e44070d07a3237c07fb</entry:bill>

Result is that the bill exists but has no entries.
Comment 1 Mike Evans 2014-05-18 10:16:26 UTC
This it seems is partly (mostly) a programming error on my part and partly a lack of type checking in the python bindings Entry class.

My code had this line:
bill = gnucash.gnucash_business.Invoice(self.book, bill_num, self.currency, vendor )

then later:
entry.SetBillAccount(self.exp_account)

This means that  that the Entry is a Bill entry type and the bill is an Invoice type.  

The first line should have read:
bill = gnucash.gnucash_business.Bill(self.book, bill_num, self.currency, vendor )

For some reason I had assumed that the Owner type determined the Invoice type, since there's only one Invoice class.  This, in my opinion, should have triggered a warning/error from the python bindings and alerted me to the object mis-match.

I'll post a patch to do that later.
Comment 2 Mike Evans 2014-05-27 12:27:51 UTC
Created attachment 277285 [details] [review]
Check invoice type matches invoice-entry type.

Putting this here for someone else to eyeball before I commit it.

Also, GetBill() should return Bill not Invoice.
Comment 3 Mike Evans 2014-05-27 12:40:29 UTC
Created attachment 277288 [details] [review]
Supercede previous patch

Rename method without underscores.
Comment 4 Mike Evans 2014-06-01 12:31:39 UTC
Committed to maint, 7c003f23e
Comment 5 John Ralls 2018-06-29 23:30:53 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=730255. Please update any external references or bookmarks.