testing the book zeroing code (maybe for backport?) <<Offline>>

Derek Atkins warlord at MIT.EDU
Mon Mar 10 14:52:54 EDT 2008


Andreas Köhler <andi5.py at gmx.net> writes:

> Derek, in the currently active code we walk through the splits from the
> head of the list, searching for the first split (A) with a posted date
>>= the given one, and then return the balance of the split preceding A.
> In the book closing code you used cacb->cbw->close_date+1, so I wonder
> whether you worked around a bug or I fundamentally misunderstand
> something here.

The +1 was there for a reason, to make sure that it included previous
instances of the book closing transaction.  This is because the
AsOfDate uses <, not <=, so when the closing transaction is
posted at time T, if you run it again on the same date (which will
give you the same T) it didn't see the existing transaction,
so you'd get a second one.

So, for example, if on Dec 31 you had a balance in an account of $100
and you close it then, the closing transaction would put -$100 to get
a balance of zero.  If you ran the book closing again, you'd get a SECOND
transaction of -$100.  The "+1" worked around this problem.


       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available

More information about the gnucash-devel mailing list