Skip to content

Commit

Permalink
이만 원 이상 납부 시 비례해서 만료일 계산 - #19
Browse files Browse the repository at this point in the history
  • Loading branch information
hou27 committed Jan 12, 2023
1 parent afe5337 commit 3f50087
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public LocalDate calculateExpiryDate(PayData payData) {
if(payData.getFirstBillingDate() != null) {
return payData.getBillingDate().plusMonths(1).withDayOfMonth(payData.getFirstBillingDate().getDayOfMonth());
}
if(payData.getPayAmount() >= 20_000) {
return payData.getBillingDate().plusMonths(payData.getPayAmount() / 10_000);
}
return payData.getBillingDate().plusMonths(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ public class ExpiryDateCalculatorTest {
assertExpiryDate(payData3, LocalDate.of(2020, 3, 30));
}

@Test
void 이만__이상_납부__비례해서_만료일_계산() {
assertExpiryDate(PayData.builder()
.billingDate(LocalDate.of(2019, 1, 31))
.payAmount(20_000)
.build(),
LocalDate.of(2019, 3, 31));
assertExpiryDate(PayData.builder()
.billingDate(LocalDate.of(2019, 5, 31))
.payAmount(40_000)
.build(),
LocalDate.of(2019, 9, 30));
assertExpiryDate(PayData.builder()
.billingDate(LocalDate.of(2020, 1, 31))
.payAmount(60_000)
.build(),
LocalDate.of(2020, 7, 31));
}


private void assertExpiryDate(PayData payData, LocalDate expiryDate) {
ExpiryDateCalculator cal = new ExpiryDateCalculator();
Expand Down

0 comments on commit 3f50087

Please sign in to comment.