From 840a44e1825631a8cbdd89da5b4479837fd4b56b Mon Sep 17 00:00:00 2001 From: Ahn Su-gyeong <88311377+ahnsugyeong@users.noreply.github.com> Date: Wed, 14 Feb 2024 03:17:57 +0900 Subject: [PATCH] Revert "Feat/112 (#113)" This reverts commit 5a3f90d69796cab457b16584e80ef6ffbb29d066. --- .../service/FinancialServiceImpl.java | 4 --- .../easybud/global/config/SwaggerConfig.java | 2 +- .../converter/TransactionConverter.java | 1 - .../transaction/domain/Transaction.java | 8 +---- .../transaction/domain/TransactionType.java | 5 --- .../transaction/dto/TransactionResponse.java | 4 --- .../AccountCustomRepositoryImpl.java | 3 +- .../TransactionCommandServiceImpl.java | 35 ------------------- 8 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 src/main/java/com/friends/easybud/transaction/domain/TransactionType.java diff --git a/src/main/java/com/friends/easybud/financial/service/FinancialServiceImpl.java b/src/main/java/com/friends/easybud/financial/service/FinancialServiceImpl.java index 8f5dff0..df524ec 100644 --- a/src/main/java/com/friends/easybud/financial/service/FinancialServiceImpl.java +++ b/src/main/java/com/friends/easybud/financial/service/FinancialServiceImpl.java @@ -157,10 +157,6 @@ public IncomeStatementDto getIncomeStatement(Member member, LocalDateTime startD .multiply(new BigDecimal(100)); revenuePercentage = revenue.divide(revenue.add(expense), 4, RoundingMode.HALF_UP) .multiply(new BigDecimal(100)); - } else if (expense.compareTo(BigDecimal.ZERO) == 0 && revenue.compareTo(BigDecimal.ZERO) > 0) { - revenuePercentage = BigDecimal.valueOf(100); - } else if (revenue.compareTo(BigDecimal.ZERO) == 0 && expense.compareTo(BigDecimal.ZERO) > 0) { - expensePercentage = BigDecimal.valueOf(100); } return IncomeStatementDto.builder() diff --git a/src/main/java/com/friends/easybud/global/config/SwaggerConfig.java b/src/main/java/com/friends/easybud/global/config/SwaggerConfig.java index a3890a1..a194bfe 100644 --- a/src/main/java/com/friends/easybud/global/config/SwaggerConfig.java +++ b/src/main/java/com/friends/easybud/global/config/SwaggerConfig.java @@ -42,7 +42,7 @@ public OpenAPI openAPI() { --- ### πŸ”‘ ν…ŒμŠ€νŠΈ μ‚¬μš©μž 인증 토큰 - **eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzYjk5ZjYwZC1mOWY1LTQ2MmUtODg5NS0yM2E1MmVkZDI0NTEiLCJhdXRoIjoiVVNFUiIsImV4cCI6MTcwNzg0NjgxOX0.ovjnSjn0Dmm1d8AYTlL4Fklh5KhHEDNpmW-3zr3ZRks** + **eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzYjk5ZjYwZC1mOWY1LTQ2MmUtODg5NS0yM2E1MmVkZDI0NTEiLCJhdXRoIjoiVVNFUiIsImV4cCI6MTcwNzc4OTE2MX0.hrEnXsmipLqpWSv9pw4GHHo3LfIo_yFVM7Ojg9DwN6I** """); diff --git a/src/main/java/com/friends/easybud/transaction/converter/TransactionConverter.java b/src/main/java/com/friends/easybud/transaction/converter/TransactionConverter.java index 5af8383..de69e4d 100644 --- a/src/main/java/com/friends/easybud/transaction/converter/TransactionConverter.java +++ b/src/main/java/com/friends/easybud/transaction/converter/TransactionConverter.java @@ -37,7 +37,6 @@ public static TransactionDto toTransactionDto(Transaction transaction) { .transactionId(transaction.getId()) .date(transaction.getDate()) .summary(transaction.getSummary()) - .type(transaction.getType()) .debitAccounts(debitAccounts) .creditAccounts(creditAccounts) .build(); diff --git a/src/main/java/com/friends/easybud/transaction/domain/Transaction.java b/src/main/java/com/friends/easybud/transaction/domain/Transaction.java index efc6631..4b434ec 100644 --- a/src/main/java/com/friends/easybud/transaction/domain/Transaction.java +++ b/src/main/java/com/friends/easybud/transaction/domain/Transaction.java @@ -4,8 +4,6 @@ import com.friends.easybud.member.domain.Member; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -33,9 +31,6 @@ public class Transaction extends BaseTimeEntity { private LocalDateTime date; private String summary; - @Enumerated(value = EnumType.STRING) - private TransactionType type; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id") private Member member; @@ -44,10 +39,9 @@ public class Transaction extends BaseTimeEntity { private List accounts = new ArrayList<>(); @Builder - public Transaction(LocalDateTime date, String summary, TransactionType type, Member member) { + public Transaction(LocalDateTime date, String summary, Member member) { this.date = date; this.summary = summary; - this.type = type; this.member = member; } } diff --git a/src/main/java/com/friends/easybud/transaction/domain/TransactionType.java b/src/main/java/com/friends/easybud/transaction/domain/TransactionType.java deleted file mode 100644 index e73e05d..0000000 --- a/src/main/java/com/friends/easybud/transaction/domain/TransactionType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.friends.easybud.transaction.domain; - -public enum TransactionType { - EXPENSE_TRANSACTION, REVENUE_TRANSACTION, ACCOUNT_TRANSFER -} diff --git a/src/main/java/com/friends/easybud/transaction/dto/TransactionResponse.java b/src/main/java/com/friends/easybud/transaction/dto/TransactionResponse.java index eff5c56..0cf46a5 100644 --- a/src/main/java/com/friends/easybud/transaction/dto/TransactionResponse.java +++ b/src/main/java/com/friends/easybud/transaction/dto/TransactionResponse.java @@ -1,7 +1,6 @@ package com.friends.easybud.transaction.dto; import com.friends.easybud.transaction.domain.AccountType; -import com.friends.easybud.transaction.domain.TransactionType; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; import java.math.BigDecimal; @@ -48,9 +47,6 @@ public static class TransactionDto { @Schema(description = "μ μš”", example = "μŠ€νƒ€λ²…μŠ€") private String summary; - @Schema(description = "거래 μœ ν˜•", example = "EXPENSE_TRANSACTION") - private TransactionType type; - @ArraySchema(schema = @Schema(description = "μ°¨λ³€ 계정 λͺ©λ‘", implementation = AccountDto.class)) private List debitAccounts; diff --git a/src/main/java/com/friends/easybud/transaction/repository/AccountCustomRepositoryImpl.java b/src/main/java/com/friends/easybud/transaction/repository/AccountCustomRepositoryImpl.java index 417e85c..a50f3f2 100644 --- a/src/main/java/com/friends/easybud/transaction/repository/AccountCustomRepositoryImpl.java +++ b/src/main/java/com/friends/easybud/transaction/repository/AccountCustomRepositoryImpl.java @@ -130,8 +130,7 @@ public List getAccountInfosByAccountNameAndMember(AccountName accou account.accountType.typeState) .from(account) .join(account.transaction, transaction) - .where(account.accountType.typeName.eq(accountName), - transaction.member.id.eq(memberId)) + .where(account.accountType.typeName.eq(accountName)) .fetch(); return results.stream().map(tuple -> { diff --git a/src/main/java/com/friends/easybud/transaction/service/TransactionCommandServiceImpl.java b/src/main/java/com/friends/easybud/transaction/service/TransactionCommandServiceImpl.java index c8732d2..84b7eff 100644 --- a/src/main/java/com/friends/easybud/transaction/service/TransactionCommandServiceImpl.java +++ b/src/main/java/com/friends/easybud/transaction/service/TransactionCommandServiceImpl.java @@ -8,15 +8,11 @@ import com.friends.easybud.global.response.code.ErrorStatus; import com.friends.easybud.member.domain.Member; import com.friends.easybud.transaction.domain.Account; -import com.friends.easybud.transaction.domain.AccountName; -import com.friends.easybud.transaction.domain.AccountState; import com.friends.easybud.transaction.domain.Transaction; -import com.friends.easybud.transaction.domain.TransactionType; import com.friends.easybud.transaction.dto.TransactionRequest.AccountCreateDto; import com.friends.easybud.transaction.dto.TransactionRequest.TransactionCreateDto; import com.friends.easybud.transaction.repository.AccountRepository; import com.friends.easybud.transaction.repository.TransactionRepository; -import java.math.BigDecimal; import java.time.Duration; import java.time.LocalDateTime; import java.util.List; @@ -51,7 +47,6 @@ private Transaction buildTransaction(TransactionCreateDto request, Member member Transaction transaction = Transaction.builder() .date(request.getDate()) .summary(request.getSummary()) - .type(getTransactionType(request.getAccounts())) .member(member) .build(); return transaction; @@ -121,34 +116,4 @@ private void checkTransactionOwnership(Member member, Transaction transaction) { } } - private TransactionType getTransactionType(List accounts) { - BigDecimal totalExpenses = BigDecimal.ZERO; - BigDecimal totalRevenues = BigDecimal.ZERO; - - for (AccountCreateDto account : accounts) { - if (account.getAccountType().getTypeName() == AccountName.EXPENSE) { - if (account.getAccountType().getTypeState() == AccountState.INCREASE) { - totalExpenses = totalExpenses.add(account.getAmount()); - } else if (account.getAccountType().getTypeState() == AccountState.DECREASE) { - totalExpenses = totalExpenses.subtract(account.getAmount()); - } - - } else if (account.getAccountType().getTypeName() == AccountName.REVENUE) { - if (account.getAccountType().getTypeState() == AccountState.INCREASE) { - totalRevenues = totalRevenues.add(account.getAmount()); - } else if (account.getAccountType().getTypeState() == AccountState.DECREASE) { - totalRevenues = totalRevenues.subtract(account.getAmount()); - } - } - } - - if (totalExpenses.compareTo(totalRevenues) > 0) { - return TransactionType.EXPENSE_TRANSACTION; - } else if (totalRevenues.compareTo(totalExpenses) > 0) { - return TransactionType.REVENUE_TRANSACTION; - } else { - return TransactionType.ACCOUNT_TRANSFER; - } - } - }