Skip to content

Commit

Permalink
refactor: defaultcurrency 정적 팩토리 메소드 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
waterricecake committed Jul 27, 2023
1 parent f144428 commit f1d84a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/java/hanglog/expense/domain/Currency.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Currency {
private Double krw;

// TODO : 추후 currency 데이터 입력 후 default 값 생성시 삭제
public static Currency ofDefault() {
public static Currency getDefaultCurrency() {
return new Currency();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public enum CurrencyCodeType {
this.getRate = getRate;
}

public static double mappingCurrency(final String currency, final Currency currencies) {
public static double mappingCurrency(final String currencyCode, final Currency currencies) {
return Arrays.stream(values())
.filter(value -> value.code.equals(currency.toLowerCase()))
.filter(value -> value.code.equals(currencyCode.toLowerCase()))
.findAny().orElseThrow(() -> new InvalidDomainException(INVALID_CURRENCY))
.getRate.apply(currencies);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class ExpenseService {

// TODO: 추후 Currency 데이터 생길시 deafault 값 추가
private static final Currency DEFAULT_CURRENCY = Currency.ofDefault();
private static final Currency DEFAULT_CURRENCY = Currency.getDefaultCurrency();
private final TripRepository tripRepository;
private final CurrencyRepository currencyRepository;
private final TripCityRepository tripCityRepository;
Expand All @@ -47,7 +47,9 @@ public ExpenseGetResponse getAllExpenses(final long tripId) {
calculateAmounts(dayLog, currency, dayLogTotalAmounts, categoryTotalAmounts);
}

final int totalAmount = dayLogTotalAmounts.values().stream().reduce(Integer::sum).orElse(0);
final int totalAmount = dayLogTotalAmounts.values().stream()
.reduce(Integer::sum)
.orElse(0);

return ExpenseGetResponse.of(
trip,
Expand Down

0 comments on commit f1d84a3

Please sign in to comment.