Menu

#300 Categories in Split Transaction not updated in My Budget

Release_3.4
closed-fixed
nobody
Workflow (18)
5
2011-10-19
2011-01-03
Anonymous
No

Hi,

I have a split transaction as follows, I buy white meat in super market and have separate budget categories for fish and poultry. When i record the split the budget categories for fish and poultry are not updated.

I have attached the screenshots for the above example.

Discussion

  • Nobody/Anonymous

    Screenshot for split transaction and my budget panel

     
  • Nobody/Anonymous

    It doesn't just affect subcategories, it affects main budget categories as well.

     
  • Srinath s/o Ravinathan

    Hi,

    This defect is because the in the MyBudgetTreeTableModel the amounts from splits are not calculated. I have fixed this and the source for the method private long getActual(BudgetCategory bc, Date date, boolean includeChildren) in the class org.homeunix.thecave.buddi.model.swing.MyBudgetTreeTableModel is below,

    private long getActual\(BudgetCategory bc, Date date, boolean includeChildren\) \{
        List<Transaction> transactions = model.getTransactions\(bc, date,
                getSelectedBudgetPeriodType\(\).getEndOfBudgetPeriod\(date\)\);
    
        long actual = 0;
        for \(Transaction transaction : transactions\) \{
            if \(\!transaction.isDeleted\(\)\)\{
                if \(transaction.getTo\(\) instanceof BudgetCategory\)\{
                    actual -= transaction.getAmount\(\);
                \} else if \(transaction.getFrom\(\) instanceof BudgetCategory\)\{
                    actual += transaction.getAmount\(\);
                \}
                for \(TransactionSplit split : transaction.getToSplits\(\)\) \{
                    if\(split.getSource\(\).getFullName\(\).equals\(bc.getFullName\(\)\)\)
                        actual -= split.getAmount\(\);
                \}
                for \(TransactionSplit split : transaction.getFromSplits\(\)\) \{
                    if\(split.getSource\(\).getFullName\(\).equals\(bc.getFullName\(\)\)\)
                        actual += split.getAmount\(\);
                \}
            \}
        \}
    
        if\(includeChildren\) \{
            for\(BudgetCategory child: bc.getChildren\(\)\) \{
                // we could avoid recursion, but it's just so cool
                actual += getActual\(child, date, true\);
            \}
        \}
    
        return actual;
    \}
    

    Thanks.

     
  • Wyatt

    Wyatt - 2011-01-17

    Thanks for the fix to the code, I will include this in the next version.

     
  • Wyatt

    Wyatt - 2011-10-19
    • status: open --> closed-fixed
     
  • Wyatt

    Wyatt - 2011-10-19

    Fixed as of 3.4.0.8