Having problem to monetary-collector

Christian Stimming stimming@tuhh.de
Tue, 26 Feb 2002 16:03:13 +0100

Martijn van Oosterhout wrote:

 > Unfortunatly, it appears the source of the numeric-collector is 
internal and
 > thus not shipped with the compiled version. Any see what the problem 
is? And
 > what to do about it?

Every bit of code related to the {numeric,commodity}-collector resides 
in the file report-utilities.scm, which lies in src/scm in the 
gnucash-1.6 branch (thus, should be shipped even with compiled versions) 
and in src/report/report-system in the unstable HEAD branch. Code for 
numeric-collector is right before the code for commodity-collector in 
that file. You can browse the HEAD CVS online:


Note that about a week ago I added some code in an admittantly late 
attempt to go away from this procedure-style calls like (c 'add this 
that) and rather use an conventional code like 
(gnc:numeric-collector-add c this that). I think the latter one is much 
more readable. For one thing, you know which sort of collector you are 
talking about. This code is in both CVS branches right now, but it 
didn't make it into any stable release so far.

> c is the collector, currency is just the currentcy we happen to be using, s
> is the split:

I guess you mean c is a commodity-collector, i.e. you had (let ((c 
(gnc:make-commodity-collector)) beforehand.

> ;; debug output of the values going in
> (gnc:debug (c 'getpair currency #f)) 
>   -> (#<gw:wcp <gnc:commodity*> 0x81acb38> #<<gnc-numeric> num: -40950 denom: 100>)
> (gnc:debug (gnc:split-get-amount s))
>   -> #<<gnc-numeric> num: 3709000 denom: 100000>
> ;; Add them up
> (c 'add currency (gnc:split-get-amount s))
> ;; Display to output
> (gnc:debug (c 'getpair currency #f))
>   -> (#<gw:wcp <gnc:commodity*> 0x81acb38> #<<gnc-numeric> num: -3 denom: 0>)
> Huh?
> -40950/100 + 3709000/100000  !=  -3/0
> Two possibilities:
> 1. It doesn't like the differing denominators
> 2. It doesn't like the differing signs

Oh, wasn't a zero denominator supposed to signal an gnc-numeric error 
anyway? Because a zero denominator doesn't make any sense in the first 
place. The code for gnc-numeric can be found in 
http://www.gnucash.org/lxr/gnucash/source/src/engine/gnc-numeric.h and 
there you are anyway -- the error code '-3' stands for 'denominator 
difference' -- for adding two gnc-numerics you need to get them onto a 
common denominator first. Maybe the code of the commodity-collector 
needs to be extended here, but I don't have time and/or a source tree 
available at the moment. You can come back to me about this in a few 
days if you can't get it working by yourself.

Anyway, I greatly appreciate your work here and I'm looking forward to 
hearing more of you about that.