Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#295 Split Transaction Bug

open
nobody
None
5
2012-12-10
2010-08-07
Anonymous
No

Hi there,

I've just discovered the split transaction programming but am dismayed that it isn't working correctly for me. I'm attempting to record that, in a transaction, I used my checking account to purchase groceries and get cash back. I am able to record this in the checking account; however, when I check my cash account, the transaction shows up with no amount instead of showing an addition for the cash back. In addition, it seems as if sometimes it's adding the entire amount to the cash account instead of the portion that was cash back, or subtracting the entire amount from the cash account. Finally, every other time I go back to the checking account to review it, that transaction will also zero out, along with other transactions that are unrelated.

I am using the latest Buddi 3.4.0.2 for Mac running 10.6.

Discussion

  • 5 screenshots showing errors

     
    Attachments
  • Martin
    Martin
    2010-10-03

    Hi,

    I get exactly the same problem. I'm not sure what triggered it, but all my scheduled transactions are passivated by this. It definitely appeared only after switch to Version 3.4.0.2 (running under Windows 7).
    Your effort to fix this will be greatly appreciated.

    Best wishes,
    Martin

     
  • Martin
    Martin
    2010-10-03

    Sorry, that was the wrong thread ... wish I could delete it ...

     
  • Hi,

    There is an error in the class AccountImpl - it does not handle balances of accounts involved in split transactions correctly. The following is the code to fix it in the method updateBalance() of the class org.homeunix.thecave.buddi.model.impl.AccountImpl

    [code]
    public void updateBalance(){
    if (getDocument() == null)
    return;

        long balance = this.getStartingBalance\(\);
    
        List<Transaction> transactions = getDocument\(\).getTransactions\(this\);
    
        for \(Transaction transaction : transactions\) \{
            try \{
                if \(\!transaction.isDeleted\(\)\)\{
                    //We are moving money \*to\* this account
                    if \(transaction.getTo\(\).equals\(this\)\)\{
                        balance += transaction.getAmount\(\);
                        transaction.setBalance\(this.getUid\(\), balance\);
                    \} 
                    //We are moving money \*from\* this account
                    else if \(transaction.getFrom\(\).equals\(this\)\)\{
                        balance -= transaction.getAmount\(\);
                        transaction.setBalance\(this.getUid\(\), balance\);
                    \}
                    //We are moving money \*to\* this account
                    for \(TransactionSplit split : transaction.getToSplits\(\)\) \{
                        if\(split.getSource\(\).equals\(this\)\)
                            balance += split.getAmount\(\);
                    \}
                    //We are moving money \*from\* this account
                    for \(TransactionSplit split : transaction.getFromSplits\(\)\) \{
                        if\(split.getSource\(\).equals\(this\)\)
                            balance -= split.getAmount\(\);
                    \}
                \}
            \}
            catch \(InvalidValueException ive\)\{
                Logger.getLogger\(AccountImpl.class.getName\(\)\).log\(Level.WARNING, "Incorrect value", ive\);
            \}
        \}
    
        setBalance\(balance\);
    \}
    

    [/code]

    Thanks and expecting a new Buddi release soon :)