Skip to content

Commit

Permalink
[Feat/#104] TransactionConverter null 조건문 추가 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnsugyeong authored Feb 12, 2024
1 parent 7f1ef1d commit 206d7e8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,47 @@ public static TransactionDto toTransactionDto(Transaction transaction) {
}

public static AccountDto toAccountDto(Account account) {
Long primaryCategoryId = null;
String primaryCategoryContent = null;
Long secondaryCategoryId = null;
String secondaryCategoryContent = null;
Long tertiaryCategoryId = null;
String tertiaryCategoryContent = null;
Long cardId = null;
String cardName = null;

if (account.getTertiaryCategory() != null) {
primaryCategoryId = account.getTertiaryCategory().getId();
primaryCategoryContent = account.getTertiaryCategory().getContent();
secondaryCategoryId = account.getTertiaryCategory().getSecondaryCategory().getId();
secondaryCategoryContent = account.getTertiaryCategory().getSecondaryCategory().getContent();
tertiaryCategoryId = account.getTertiaryCategory().getSecondaryCategory().getPrimaryCategory().getId();
tertiaryCategoryContent = account.getTertiaryCategory().getSecondaryCategory().getPrimaryCategory()
.getContent();

} else if (account.getCard() == null) {
primaryCategoryId = 2L;
primaryCategoryContent = "부채";
secondaryCategoryId = 8L;
secondaryCategoryContent = "카드대금";
cardId = account.getCard().getId();
cardName = account.getCard().getName();
}

return AccountDto.builder()
.accountId(account.getId())
.accountType(account.getAccountType())
.primaryCategoryId(account.getTertiaryCategory().getSecondaryCategory().getPrimaryCategory().getId())
.primaryCategoryContent(
account.getTertiaryCategory().getSecondaryCategory().getPrimaryCategory().getContent())
.secondaryCategoryId(account.getTertiaryCategory().getSecondaryCategory().getId())
.secondaryCategoryContent(account.getTertiaryCategory().getSecondaryCategory().getContent())
.tertiaryCategoryId(account.getTertiaryCategory().getId())
.tertiaryCategoryContent(account.getTertiaryCategory().getContent())
.amount(account.getAmount()).build();
.primaryCategoryId(primaryCategoryId)
.primaryCategoryContent(primaryCategoryContent)
.secondaryCategoryId(secondaryCategoryId)
.secondaryCategoryContent(secondaryCategoryContent)
.tertiaryCategoryId(tertiaryCategoryId)
.tertiaryCategoryContent(tertiaryCategoryContent)
.cardId(cardId)
.cardName(cardName)
.amount(account.getAmount())
.build();

}

private static boolean isDebitAccount(AccountType accountType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public static class AccountDto {
@Schema(description = "소분류", example = "카페/간식")
private String tertiaryCategoryContent;

@Schema(description = "카드 ID", example = "3")
private Long cardId;

@Schema(description = "카드 이름", example = "롯데카드")
private String cardName;

@Schema(description = "금액", example = "12000")
private BigDecimal amount;

Expand Down

0 comments on commit 206d7e8

Please sign in to comment.