Skip to content

Commit c23e980

Browse files
authored
Fix first term calculator to use correct date to calculate remaining … (#6)
* Fix first term calculator to use correct date to calculate remaining months * Address comment
1 parent f24123c commit c23e980

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Where `input` have the following object:
5555
regularPayment: Double, // 25.0
5656
currentBalance: Double, // 25.0
5757
paidInThisMonth: Double, // 50.0
58-
accountStartDate: YearMonthDayInput, // YearMonthDayInput(2020, 3)
58+
thisMonthEndDate: YearMonthDayInput, // YearMonthDayInput(2020, 3, 31)
5959
firstTermEndDate: YearMonthDayInput, // YearMonthDayInput(2022, 2, 28)
6060
secondTermEndDate: YearMonthDayInput, // YearMonthDayInput(2024, 2, 28)
6161
balanceMustBeMoreThanForBonus: Double // 50.0

src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/FirstBonusTermCalculation.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ internal class FirstBonusTermCalculation {
8787
}
8888

8989
fun calculateMonthsLeftInScheme(input: FirstBonusInput): Pair<Int, Int> {
90-
val startDate = input.accountStartDate.convertToDateTime()
90+
val thisMonthEndDate = input.thisMonthEndDate.convertToDateTime()
9191
val secondTermEndDate = input.secondTermEndDate.convertToDateTime()
9292
val firstTermEndDate = input.firstTermEndDate.convertToDateTime()
93-
val monthsLeftInScheme = startDate.monthsSince(secondTermEndDate)
94-
val monthsLeftInFirstTerm = startDate.monthsSince(firstTermEndDate)
93+
val monthsLeftInScheme = thisMonthEndDate.monthsSince(secondTermEndDate)
94+
val monthsLeftInFirstTerm = thisMonthEndDate.monthsSince(firstTermEndDate)
9595
return Pair(monthsLeftInScheme, monthsLeftInFirstTerm)
9696
}
9797
}

src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/FirstBonusInput.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data class FirstBonusInput(
1919
val regularPayment: Double,
2020
val currentBalance: Double,
2121
val paidInThisMonth: Double,
22-
val accountStartDate: YearMonthDayInput,
22+
val thisMonthEndDate: YearMonthDayInput,
2323
val firstTermEndDate: YearMonthDayInput,
2424
val secondTermEndDate: YearMonthDayInput,
2525
val balanceMustBeMoreThanForBonus: Double

0 commit comments

Comments
 (0)