GNOME Bugzilla – Bug 727647
"gncInvoiceGetTotal" is not read-only function?
Last modified: 2018-06-29 23:29:21 UTC
Ok so I was trying to generate "Customer Report" with one-line modification. Instead of using "Credit amount" from transaction, I wanted it to pick from "Invoice". So I made one-line modification to file 'owner-report.scm' #### Original code #### 330: (value (xaccTransGetAccountValue txn acc)) ... 359: ; Now print out the invoice row 360: (if (not (null? invoice)) 361: (set! due-date (gncInvoiceGetDateDue invoice))) I changed it to: #### New code (line 362 is new line, rest same) #### 330: (value (xaccTransGetAccountValue txn acc)) ... 359: ; Now print out the invoice row 360: (if (not (null? invoice)) 361: (begin (set! due-date (gncInvoiceGetDateDue invoice)) 362: (set! value (gncInvoiceGetTotal invoice)))) After this change, I run "Customer Report". It runs fine. Output is also working as expected. BUT, now if I try to exit GnuCash, it prompts me to save the file. Apparently calling "gncInvoiceGetTotal" made some changes! This is weird, because I thought it was meant to be read-only function. Same applies if I try any gncInvoiceGet* (Tax, Subtotal etc.) function. Is this bug? Or it is expected? Please check. Thank you. Reference document: http://gnucash.sourcearchive.com/documentation/2.2.9/gncInvoice_8h.html
More update. Same bug exists, if you run ANY default invoice related reports (any of Easy/Fancy/Tax invoice reports). i.e. no sooner you run those reports GnuCash thinks there is modification and it asks to save before exiting.
Thank you for your report. I superficially checked the code and found that getting the invoice amounts always triggers a recalculation of the internal values of the invoice entries (ie it calls gncEntryRecomputeValues). This results in marking your book as dirty. Hence gnucash will ask if you want to save the changes. I'd consider this a bug. But it will take some careful study to change this correctly for all possible uses of these functions. Given there is no damage done by this bug I'll reduce the priority to low.
This bug will be fixed in the next release (2.6.6). It turns out the gncRecomputeValues functions I mentioned in the previous comment is not supposed to trigger a book change. It only works on cached runtim values. Thank you for your report.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=727647. Please update any external references or bookmarks.