Account Balance Computation with opening balance w/o any splits
Derek Atkins
warlord@MIT.EDU
14 Mar 2001 13:51:06 -0500
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