Skip to content

Commit

Permalink
Merge pull request #183 from navikt/PEK-715-hente-simulert-tjenestepe…
Browse files Browse the repository at this point in the history
…nsjon-spk

PEK-715 håndter aldersskifte ved bestemmelse av uttaksalder for brukere født 01.01
  • Loading branch information
antonfofanov authored Dec 9, 2024
2 parents 6bc884c + 2d9be08 commit abd1f66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ object AlderUtil {
fun bestemUttaksalderVedDato(fodselsdato: LocalDate, date: LocalDate): Alder {
val periode = Period.between(fodselsdato, date)
if (fodselsdato.dayOfMonth == 1) {
return Alder(periode.years, periode.months - 1)
return if (periode.months - 1 < 0) { //Substraction of months doesn't affect years in java.time.Period
Alder(periode.years - 1, 11)
} else {
Alder(periode.years, periode.months - 1)
}
}
return Alder(periode.years, periode.months)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,29 @@ class AlderUtilTest {
}

@Test
fun `test bestem uttaksalder for X aar og 11 maaneder`(){
fun `test bestem uttaksalder for X aar og 11 maaneder`() {
val foedselsdato = LocalDate.of(2000, 3, 15)
val uttaksdato = LocalDate.of(2062, 3, 1)
val alder = AlderUtil.bestemUttaksalderVedDato(foedselsdato, uttaksdato)
assertEquals(61, alder.aar)
assertEquals(11, alder.maaneder)
}

@Test
fun `bestem uttaksalder haandterer aarskifte for brukere foedt i foerste i foerste`() {
val foedselsdato = LocalDate.of(2001, 1, 1)
val uttaksdato = LocalDate.of(2064, 1, 1)
val alder = AlderUtil.bestemUttaksalderVedDato(foedselsdato, uttaksdato)
assertEquals(62, alder.aar)
assertEquals(11, alder.maaneder)
}

@Test
fun `bestem uttaksalder haandterer generell aldersskifte`() {
val foedselsdato = LocalDate.of(2001, 1, 2)
val uttaksdato = LocalDate.of(2064, 1, 1)
val alder = AlderUtil.bestemUttaksalderVedDato(foedselsdato, uttaksdato)
assertEquals(62, alder.aar)
assertEquals(11, alder.maaneder)
}
}

0 comments on commit abd1f66

Please sign in to comment.