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 727647 - "gncInvoiceGetTotal" is not read-only function?
"gncInvoiceGetTotal" is not read-only function?
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Business
2.6.2
Other All
: Low minor
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2014-04-05 09:17 UTC by Amm
Modified: 2018-06-29 23:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Amm 2014-04-05 09:17:13 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
Comment 1 Amm 2014-04-05 10:15:56 UTC
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.
Comment 2 Geert Janssens 2014-04-05 12:38:13 UTC
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.
Comment 3 Geert Janssens 2015-01-28 16:02:40 UTC
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.
Comment 4 John Ralls 2018-06-29 23:29:21 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=727647. Please update any external references or bookmarks.