- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 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 05.05.2010 19:35 # 0
guest8 21.09.2019 15:15 # −999
guest8 26.09.2019 20:36 # −999