Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #204 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FIX]: 예금 계산기 12개월 옵션으로 고정 (#203)
  • Loading branch information
sejineer authored Jan 17, 2024
2 parents 08448f6 + 595b88d commit ff5f6a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,14 @@ public DepositCalculateRes depositCalculate(Long depositId, Double amount) {
.orElseThrow(InvalidFinancialProductException::new);

List<FinancialProductOption> depositOptions = financialProductOptionRepository.findFinancialProductOptionsByFinancialProduct(deposit);
FinancialProductOption maxOption = depositOptions.stream()
.max(Comparator.comparing(FinancialProductOption::getMaximumPreferredInterestRate))
.orElse(null);
FinancialProductOption defaultOption = depositOptions.stream()
.max(Comparator.comparing(FinancialProductOption::getInterestRate))
.orElseThrow(RuntimeException::new);
FinancialProductOption financialOption = depositOptions.stream()
.filter(option -> option.getSavingsTerm().equals(12))
.toList().get(0);

Double maxInterestRate = amount + (amount * (Double.parseDouble(maxOption.getMaximumPreferredInterestRate()) / 100) * 0.846);
Double interestRate = amount + (amount * (Double.parseDouble(defaultOption.getInterestRate()) / 100) * 0.846);
Double maxInterestRate = amount + (amount * (Double.parseDouble(financialOption.getMaximumPreferredInterestRate()) / 100) * 0.846);
Double interestRate = amount + (amount * (Double.parseDouble(financialOption.getInterestRate()) / 100) * 0.846);

return DepositCalculateRes.toDto(maxInterestRate, interestRate);
return DepositCalculateRes.toDto(String.format("%.0f", maxInterestRate), String.format("%.0f", interestRate));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
@Builder
public class DepositCalculateRes {

private Double defaultInterestCalculation;
private String defaultInterestCalculation;

private Double maxInterestCalculation;
private String maxInterestCalculation;

public static DepositCalculateRes toDto(Double maxInterestRate, Double interestRate) {
public static DepositCalculateRes toDto(String maxInterestRate, String interestRate) {
return DepositCalculateRes.builder()
.defaultInterestCalculation(interestRate)
.maxInterestCalculation(maxInterestRate)
Expand Down

0 comments on commit ff5f6a2

Please sign in to comment.