Skip to content

Commit

Permalink
Fix first term calculator to use correct date to calculate remaining … (
Browse files Browse the repository at this point in the history
#6)

* Fix first term calculator to use correct date to calculate remaining months

* Address comment
ngoulongkam authored Mar 20, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f24123c commit c23e980
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ Where `input` have the following object:
regularPayment: Double, // 25.0
currentBalance: Double, // 25.0
paidInThisMonth: Double, // 50.0
accountStartDate: YearMonthDayInput, // YearMonthDayInput(2020, 3)
thisMonthEndDate: YearMonthDayInput, // YearMonthDayInput(2020, 3, 31)
firstTermEndDate: YearMonthDayInput, // YearMonthDayInput(2022, 2, 28)
secondTermEndDate: YearMonthDayInput, // YearMonthDayInput(2024, 2, 28)
balanceMustBeMoreThanForBonus: Double // 50.0
Original file line number Diff line number Diff line change
@@ -87,11 +87,11 @@ internal class FirstBonusTermCalculation {
}

fun calculateMonthsLeftInScheme(input: FirstBonusInput): Pair<Int, Int> {
val startDate = input.accountStartDate.convertToDateTime()
val thisMonthEndDate = input.thisMonthEndDate.convertToDateTime()
val secondTermEndDate = input.secondTermEndDate.convertToDateTime()
val firstTermEndDate = input.firstTermEndDate.convertToDateTime()
val monthsLeftInScheme = startDate.monthsSince(secondTermEndDate)
val monthsLeftInFirstTerm = startDate.monthsSince(firstTermEndDate)
val monthsLeftInScheme = thisMonthEndDate.monthsSince(secondTermEndDate)
val monthsLeftInFirstTerm = thisMonthEndDate.monthsSince(firstTermEndDate)
return Pair(monthsLeftInScheme, monthsLeftInFirstTerm)
}
}
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ data class FirstBonusInput(
val regularPayment: Double,
val currentBalance: Double,
val paidInThisMonth: Double,
val accountStartDate: YearMonthDayInput,
val thisMonthEndDate: YearMonthDayInput,
val firstTermEndDate: YearMonthDayInput,
val secondTermEndDate: YearMonthDayInput,
val balanceMustBeMoreThanForBonus: Double

0 comments on commit c23e980

Please sign in to comment.