GNOME Bugzilla – Bug 730255
Python bindings: Assigns bill entries to non-existant invoice.
Last modified: 2018-06-29 23:30:53 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.
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.
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.
Created attachment 277288 [details] [review] Supercede previous patch Rename method without underscores.
Committed to maint, 7c003f23e
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.