for (Account account : accounts.values()) {
Money money = new Money(0);
Map<String, Operation> operations = (Map<String, Operation>) system.query(new GetOperationByAccountId(account.getId()));
for (Operation operation : operations.values()) {
if(operation.isCredit()){
money.credit(operation.getValue());
}else{
money.debit(operation.getValue());
}
}
system.execute(new SetAmountOfAccount(money, account.getId()));