1. Java / Говнокод #76

    −32.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    public void updateAmountValues(List<TransactionResultItem> transactionResultItems) {
            for (TransactionResultItem transaction : transactionResultItems) {
                Account account = getAccountById(transaction.getAccountId());
                if ((transaction.getMainTransaction()
                        && ! transaction.getTransactionTypeId().equals(4)
                        && ! transaction.getTransactionTypeId().equals(5)
                        && ! transaction.getTransactionTypeId().equals(6))
                        ||
                        (! transaction.getMainTransaction() &&
                                (transaction.getTransactionTypeId().equals(5) &&
                                        ((account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                                account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                                transaction.getAmount() > 0)
                                        || (transaction.getAccountId().equals(getSalesTaxPayableAccountId()) && transaction.getAmount() > 0)
                                        || ((account.getAccountTypeId().equals(AccountType.EXPENSE_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_EXPENSE_TYPE_ID)) && transaction.getAmount() < 0))
                                || (transaction.getTransactionTypeId().equals(1) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() < 0)
                                || (transaction.getTransactionTypeId().equals(2) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() > 0)
                        )) {
                    Double amount = transaction.getAmount();
                    transaction.setAmount(-amount);
                }
            }
        }

    Потрясающий по понятности код. Вызывался несколько раз в одном и том же методе.

    Запостил: guest, 08 Декабря 2008

    Комментарии (3) RSS

    Добавить комментарий