-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PEK-715 spesialhåndtering av uttaksalder for brukere født 1. i måneden
- Loading branch information
1 parent
cfbc3e7
commit c1293b7
Showing
4 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/no/nav/tjenestepensjon/simulering/common/AlderUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package no.nav.tjenestepensjon.simulering.common | ||
|
||
import no.nav.tjenestepensjon.simulering.model.domain.pen.Alder | ||
import java.time.LocalDate | ||
import java.time.Period | ||
|
||
object AlderUtil { | ||
|
||
fun bestemAlderVedDato(fodselsdato: LocalDate, date: LocalDate): Alder { | ||
val periode = Period.between(fodselsdato, date) | ||
return Alder(periode.years, periode.months) | ||
} | ||
|
||
/* | ||
* Funksjonen returnerer uttaksaderen ved uttaksdato, kan være lavere enn faktisk alder, når, f eks, | ||
* bruker er født 1. i måned. Da skal brukeren ta ut pensjon en måned senere, selv om man er teknisk sett 1 måned eldre | ||
* 1.1.2001 -> 1.2.2063 = 62 år og 0 måneder | ||
*/ | ||
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 Alder(periode.years, periode.months) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nestepensjon/simulering/v2025/tjenestepensjon/v1/service/spk/SPKTjenestepensjonService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/kotlin/no/nav/tjenestepensjon/simulering/common/AlderUtilTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package no.nav.tjenestepensjon.simulering.common | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
import java.time.LocalDate | ||
|
||
class AlderUtilTest { | ||
|
||
@Test | ||
fun `spesialhaandtering for uttaksalder for brukere foedt foerste i maaneden`() { | ||
|
||
val foedselsdato = LocalDate.of(2001, 1, 1) | ||
val uttaksdato = LocalDate.of(2063, 2, 1) | ||
val alder = AlderUtil.bestemUttaksalderVedDato(foedselsdato, uttaksdato) | ||
assertEquals(62, alder.aar) | ||
assertEquals(0, alder.maaneder) | ||
} | ||
|
||
@Test | ||
fun `bestem uttaksalder for en foedselsdato paa foerste desember`() { | ||
|
||
val foedselsdato = LocalDate.of(2001, 12, 1) | ||
val uttaksdato = LocalDate.of(2064, 1, 1) | ||
val alder = AlderUtil.bestemUttaksalderVedDato(foedselsdato, uttaksdato) | ||
assertEquals(62, alder.aar) | ||
assertEquals(0, alder.maaneder) | ||
} | ||
|
||
@Test | ||
fun `test bestem uttaksalder`() { | ||
|
||
val foedselsdato = LocalDate.of(2000, 3, 15) | ||
val uttaksdato = LocalDate.of(2062, 4, 1) | ||
val alder = AlderUtil.bestemUttaksalderVedDato(foedselsdato, uttaksdato) | ||
assertEquals(62, alder.aar) | ||
assertEquals(0, alder.maaneder) | ||
} | ||
|
||
@Test | ||
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) | ||
} | ||
} |