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 460232 - advanced portfolio report fails
advanced portfolio report fails
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Reports
2.2.x
Other All
: Normal normal
: ---
Assigned To: Chris Shoemaker
Chris Lyttle
Depends on:
Blocks: backport
 
 
Reported: 2007-07-25 13:31 UTC by John
Modified: 2018-06-29 21:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix swig smob comparisons (1.96 KB, patch)
2007-10-17 17:09 UTC, Andrew Sackville-West
committed Details | Review

Description John 2007-07-25 13:31:48 UTC
Please describe the problem:
In /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:
 539:  98  [table-add-stock-rows-internal (# # # # ...) #t]
     ...
 294:  99  (let* (# # # # ...) (for-each # #) (set! use-txn #) ...)
 468: 100* (if (or include-empty #) (let* # # ...) ...)
 469: 101  (let* (# # # ...) (total-value # # ...) ...)
     ...
 294: 102  (let* (# # # # ...) (for-each # #) (set! use-txn #) ...)
 468: 103* (if (or include-empty #) (let* # # ...) ...)
 539: 104  [table-add-stock-rows-internal (# # # # ...) #f]
     ...
 294: 105  (let* (# # # # ...) (for-each # #) (set! use-txn #) ...)
 334: 106* [for-each #<procedure #f (split)> (# # # #)]
In unknown file:
   ?: 107* [#<procedure #f (split)> #<swig-pointer Split * 9a0e920>]
In /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:
 338: 108* (let* ((parent #)) (if (gnc:timepair-le # to-date) (begin # # #)))
 339: 109  (if (gnc:timepair-le # to-date) (begin # # #))
 340: 110  (begin (for-each # #) (set! basis-list #) (for-each # #))
 341: 111* [for-each #<procedure #f (s)> (# #)]
In unknown file:
   ?: 112* [#<procedure #f (s)> #<swig-pointer Split * 9a0e9f8>]
In /usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:
 345: 113* (cond (# # # # ...) (# #))
 346: 114* (and (not (same-account? current #)) (not (or # #)))
 346: 115* [not ...
 346: 116* [same-account? #<swig-pointer Account * 992a5d0> ()]
 197: 117  [string=? "4df81b26a12f370efd826818d78aa802" #<undefined>]
/usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:197:5: In procedure string= in expression (string=? (gncAccountGetGUID a1) (gncAccountGetGUID a2)):
/usr/share/gnucash/guile-modules/gnucash/report/advanced-portfolio.scm:197:5: Wrong type argument in position 2 (expecting string): #<undefined>


Steps to reproduce:
1. view advanced portfolio report
2. 
3. 


Actual results:
Error in report

Expected results:
Report displayed

Does this happen every time?
Yes

Other information:
Comment 1 Christian Stimming 2007-07-26 08:26:25 UTC
Other "advanced portfolio" bugs (feel free to close this one as "duplicate" if they are in fact identical or a direct subset of this bug):
bug#115267 bug#336240 bug#342245 bug#343245 bug#344566 bug#346062

@John: Do you think you could add a very simple gnucash example data file, together with instructions on how to reproduce this bug? That would help a lot. Thanks.

@Chris: Could this be SWIGification issue, in that gncAccountGetGUID returns #<undefined> where it used to return an empty string?
Comment 2 John 2007-07-26 14:35:57 UTC
- does not look like any of the bugs.
- only happened when I upgraded to 2.2.0
- I could not reproduce the problem with a new account tree,although it always happens with my old one. I tried some basic tests that looked like mine - ie accounts 0 balance etc. I will keep looking.
Comment 3 Chris Shoemaker 2007-07-30 21:07:18 UTC
(In reply to comment #1)
> @Chris: Could this be SWIGification issue, in that gncAccountGetGUID returns
> #<undefined> where it used to return an empty string?

Indeed, during the swigification I changed from using a gwrapped macro that, if the Account pointer was NULL, used to return the string version of the special guid_null(), to a swig-wrapped function that would just return SCM_UNDEFINED.  

I don't think I'd necessarily consider that change to be a bug though.  Instead it's the type of change that's likely to uncover bugs elsewhere.  In this case, it looks like there might be a split with a null account.

@John, please save off a copy of the datafile with which you can reproduce.  Then run Check and Repair on a copy of that datafile, and re-run the report that was crashing, and report back what happens.  Thanks.
Comment 4 John 2007-08-01 10:39:59 UTC
Chris - I tried the check and repair - didn't fix the problem. 

I tracked the problem down to a single account though. 'stock' account type, and there is a transaction with a price of 1 and no other values other than the date. I can't seem to delete the transaction. Blank transaction does nothing. Remove splits - does nothing - there don't seem to be any. I  can't add values to it. Edit date and it gets reset. 

There were some transactions - from 2001 - earlier in the register that seemed to have lost their transfer account. I changed them to 'opening balances' and it now works. It used to have an account:

<split:account type="guid">00000000000000000000000000000000</split:account>
Comment 5 Andrew Sackville-West 2007-10-17 01:34:56 UTC
Is this bug still out there? 

what about:

(define (same-account? a1 a2)
  (if (and a1 a2)
      (string=? (gncAccountGetGUID a1) (gncAccountGetGUID a2))
      '()
  )
)

and the same for (same-split? ...)

I think that would return a false if one of the two accounts is #undefined which would be technically correct, but I don't know what the impact would be on the report overall.
Comment 6 Andrew Sackville-West 2007-10-17 16:17:13 UTC
Actually I think my solution above is silly. Probably better to just do something like:

(define (same-account? a1 a2)
  (equal? a1 a2)
)

this works in other code I've done since swigification. Then, once we realise that its just equal? we can probably rip that function out all together and replace it with equal? not sure how it works with same-split? but will check. patch to come.

BTW, although this is caused by a likely corrupted file, it seems like this kind of failure shouldn't happen. Am I right in that? 
Comment 7 Andrew Sackville-West 2007-10-17 17:07:32 UTC
Here is a patch that I think will fix this bug. I *think* that equal? won't care what type the arguments are and will just work despite whatever highlighted the error in the OP's file.
Comment 8 Andrew Sackville-West 2007-10-17 17:09:04 UTC
Created attachment 97370 [details] [review]
fix swig smob comparisons
Comment 9 Andrew Sackville-West 2007-12-05 19:28:08 UTC
This patch is included in a larger patch to Advanced Portfolio posted to gnucash-devel: https://lists.gnucash.org/pipermail/gnucash-devel/2007-December/021694.html

thanks
Comment 10 Andrew Sackville-West 2007-12-08 18:04:36 UTC
this patch is committed as part of r16620
Comment 11 Andrew Sackville-West 2007-12-10 21:30:30 UTC
did I do this right? blocks 486922 and it's definitely "Confirmed"
Comment 12 Andreas Köhler 2007-12-16 12:38:49 UTC
branches/2.2@r16663.

Thanks a lot!
Comment 13 John Ralls 2018-06-29 21:44:04 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=460232. Please update any external references or bookmarks.