Data commit not reflected in the data

Hi,

I am trying to commit data through data manager I receive no errors but there is no changes occurring in the data I always receive the same values.

The idea is I have a customer with multiple accounts each account has a property debt this value is position if he owes me and negative if i owe him. So what I am trying to implement is settleAccounts which checks all his accounts and settles all the debt of the customer accounts and places any extra debt in main account.

for example:
Customer A: has 2 accounts A, B
Account A: has 2000 Debt - main account
Account B: has -500 Debt

result should be: A.Debt = 1500, B.Debt = 0

public void settleAccount(Customer customer) {

    BigDecimal total = BigDecimal.ZERO;

    for (Account acc: customer.getAccounts()) {
        if (acc.getDebt().doubleValue() < 0) {
            total = total.add(acc.getDebt().abs());
        }
    }

    for (Account acc: customer.getAccounts()) {
        if(!acc.getName().equals("عام")) {
            if(acc.getDebt().doubleValue() > 0) {
                if (acc.getDebt().subtract(total).doubleValue() <= 0) {
                    total = total.subtract(acc.getDebt());
                    acc.setDebt(BigDecimal.ZERO);
                    dataManager.commit(acc);
                } else {
                    total = BigDecimal.ZERO;
                    acc.setDebt(acc.getDebt().subtract(total));
                    dataManager.commit(acc);
                }
            }else{
                acc.setDebt(BigDecimal.ZERO);
                dataManager.commit(acc);
            }
        }
    }

    if(total.doubleValue() != 0){
        for (Account acc: customer.getAccounts()) {
            if(acc.getName().equals("عام")) {
                if(acc.getDebt().doubleValue() < 0)
                    acc.setDebt(BigDecimal.ZERO);
                acc.setDebt(acc.getDebt().subtract(total));
                dataManager.commit(acc);
            }
        }
    }


}

Hi,

What if you just invoke dataManager.commit() with an account set to a certain value? Will it change?
If yes, there should be an error in your business logic.
If no, the next question would be where do you invoke the method from?

Regards,
Konstantin

Hi,

I am calling it from the customerEdit view using a service. the least I would expect is that one of the customer accounts to change its value of debt but all keep the same result and I receive no error or exceptions of any sort.

Regards,
Mohamed