Account Balance Computation with opening balance w/o any splits
Derek Atkins
warlord@MIT.EDU
14 Mar 2001 14:37:44 -0500
Ugg, I hate responding to my own mail. Anyways, changing the code in
Account.c:xaccAccountRecomputeBalance() from:
else {
acc -> balance = gnc_numeric_zero();
acc -> cleared_balance = gnc_numeric_zero();
acc -> reconciled_balance = gnc_numeric_zero();
}
to read as:
else {
acc -> balance = dbalance;
acc -> cleared_balance = dcleared_balance;
acc -> reconciled_balance = dreconciled_balance;
}
seems to fix the problem, and starting account balances are working
for me (with this change :) Hopefully this doesn't break other things
as well, but I haven't noticed anything yet.
-derek
Derek Atkins <warlord@MIT.EDU> writes:
> I've got a problem with how account balances are computed. In
> particular, the function xaccAccountRecomputeBalance() seems to not
> work "right" for Stock and Mutual Fund accounts. In particular, it
> fails to recognize opening balances properly. The code in question is
> at the end of the function. In particular, I've got the proper
> numbers but there just aren't any splits. So the balances get set to
> zero. I think this is a bug (or I can just reset the balance after I
> 'commit' the account and force the numbers).
>
> Is this a bug or is there something else going on that I just don't
> understand?
>
> if ( (STOCK == acc->type) ||
> (MUTUAL == acc->type) ||
> (CURRENCY == acc->type) ) {
> acc -> share_balance = share_balance;
> acc -> share_cleared_balance = share_cleared_balance;
> acc -> share_reconciled_balance = share_reconciled_balance;
> if (last_split) {
> acc -> balance = price_xfer(last_split, share_balance);
> acc -> cleared_balance = price_xfer(last_split, share_cleared_balance);
> acc -> reconciled_balance =
> price_xfer(last_split, share_reconciled_balance);
> }
> else {
> acc -> balance = gnc_numeric_zero();
> acc -> cleared_balance = gnc_numeric_zero();
> acc -> reconciled_balance = gnc_numeric_zero();
> }
> } else {
> acc -> share_balance = dbalance;
> acc -> share_cleared_balance = dcleared_balance;
> acc -> share_reconciled_balance = dreconciled_balance;
> acc -> balance = dbalance;
> acc -> cleared_balance = dcleared_balance;
> acc -> reconciled_balance = dreconciled_balance;
> }
>
> --
> 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@MIT.EDU PGP key available
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel@lists.gnumatic.com
> http://www.gnumatic.com/cgi-bin/mailman/listinfo/gnucash-devel
--
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@MIT.EDU PGP key available