Skip to content

Commit

Permalink
🐛 Fix: 정산 참여자가 없을때 0으로 나누어 발생하는 에러 해결
Browse files Browse the repository at this point in the history
<body>
정산 참여자가 한명 이상일 때만 정산금 계산 진행

- 관련 : #313
  • Loading branch information
hosung-222 committed Sep 18, 2024
1 parent 1d2fbf4 commit 0748f2b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public static ActivityResponse.ActivitySettlementInfoDto toActivitySettlementInf
long divisionCount = activity.getActivityParticipants().stream()
.filter(ActivityParticipant::isIncludedInSettlement)
.count();
BigDecimal amountPerPerson = activity.getTotalAmount()
.divide(BigDecimal.valueOf(divisionCount), RoundingMode.HALF_UP);
BigDecimal amountPerPerson = BigDecimal.ZERO;
if (divisionCount > 0) {
amountPerPerson = activity.getTotalAmount()
.divide(BigDecimal.valueOf(divisionCount), RoundingMode.HALF_UP);
}

return ActivityResponse.ActivitySettlementInfoDto.builder()
.totalAmount(activity.getTotalAmount())
Expand Down

0 comments on commit 0748f2b

Please sign in to comment.