Skip to content

Commit

Permalink
Revert "Feat/112 (#113)"
Browse files Browse the repository at this point in the history
This reverts commit 5a3f90d.
  • Loading branch information
ahnsugyeong authored Feb 13, 2024
1 parent 5a3f90d commit 840a44e
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public OpenAPI openAPI() {
---
### 🔑 테스트 사용자 인증 토큰
**eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzYjk5ZjYwZC1mOWY1LTQ2MmUtODg5NS0yM2E1MmVkZDI0NTEiLCJhdXRoIjoiVVNFUiIsImV4cCI6MTcwNzg0NjgxOX0.ovjnSjn0Dmm1d8AYTlL4Fklh5KhHEDNpmW-3zr3ZRks**
**eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzYjk5ZjYwZC1mOWY1LTQ2MmUtODg5NS0yM2E1MmVkZDI0NTEiLCJhdXRoIjoiVVNFUiIsImV4cCI6MTcwNzc4OTE2MX0.hrEnXsmipLqpWSv9pw4GHHo3LfIo_yFVM7Ojg9DwN6I**
""");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -44,10 +39,9 @@ public class Transaction extends BaseTimeEntity {
private List<Account> 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;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<AccountDto> debitAccounts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ public List<AccountInfo> 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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -121,34 +116,4 @@ private void checkTransactionOwnership(Member member, Transaction transaction) {
}
}

private TransactionType getTransactionType(List<AccountCreateDto> 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;
}
}

}

0 comments on commit 840a44e

Please sign in to comment.