Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: Updated Order totalCost methods #23

Merged
merged 2 commits into from
Dec 29, 2024

Conversation

koreanMike513
Copy link
Collaborator

우선 말씀하신 대로 인터페이스에 노출된 메서드를 고려했을 때 애매했던 updateTotalCost()를 제거했습니다.
그 후 calculateTotalCost()는 로직을 변경한 후 남겨놓았는데

  • Voucher entity를 추가하고 나서 따로 order level 에서의 totalCost를 따로 구할 필요가 생겼기 때문에 아래와 같이 변경했습니다.

또 말씀하신 대로 NoArgsConstructor 와 Setter 를 Food 와 Order 에 한해서 일단 풀어두었습니다.
위의 변경 사항으로 인한 Food Test도 변경하였으며 통과하는 것을 확인하였습니다.

@koreanMike513 koreanMike513 added the enhancement New feature or request label Dec 28, 2024
@koreanMike513 koreanMike513 self-assigned this Dec 28, 2024
- removed updateTotalCost() method
- added Voucher entity
- added setters to Food and Order
- updated NoArgsConstructor to Public
- updated calculateTotalCost() method
- updated Food tests
@koreanMike513 koreanMike513 force-pushed the update/update-order-totalCostMethods branch from 27715dd to b89c5a3 Compare December 28, 2024 22:34
private BigDecimal percentages;

public BigDecimal apply(BigDecimal totalCost) {
BigDecimal afterDiscounts = BigDecimal.valueOf(1).subtract(percentages);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

percentages가 보통 생각하게 되는 45%인지 아니면 rate으로 변환된 0.45인지 로직을 읽어서 파악하기 전까지 명확하지 않습니다.
Multiply후 생길수 있는 decimal place에 대한 rounding logic도 추가 후 테스트 케이스를 넣을 수 있으면 좋습니다.

@koreanMike513 koreanMike513 merged commit 93e74c2 into main Dec 29, 2024
1 check passed
@koreanMike513 koreanMike513 deleted the update/update-order-totalCostMethods branch January 9, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants