-
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.
Merge pull request #78 from navikt/use-class-as-request-body-for-simu…
…lering-endpoint Use class as request body for simulering endpoint
- Loading branch information
Showing
19 changed files
with
460 additions
and
57 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/InntektDto.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,8 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
import java.util.* | ||
|
||
data class InntektDto( | ||
val datoFom: Date, | ||
val inntekt: Double, | ||
) |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/OpptjeningsperiodeDto.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,12 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
import java.util.* | ||
|
||
data class OpptjeningsperiodeDto( | ||
val stillingsprosent: Int, | ||
val datoFom: Date, | ||
val datoTom: Date, | ||
val faktiskHovedlonn: Int, | ||
val stillingsuavhengigTilleggslonn: Int, | ||
val aldersgrense: Int, | ||
) |
11 changes: 11 additions & 0 deletions
11
...otlin/no/nav/tjenestepensjon/simulering/model/domain/pen/PensjonsbeholdningsperiodeDto.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,11 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
import java.util.* | ||
|
||
data class PensjonsbeholdningsperiodeDto ( | ||
val datoFom: Date, | ||
val pensjonsbeholdning: Double, | ||
val garantipensjonsbeholdning: Double, | ||
val garantitilleggsbeholdning: Double, | ||
) | ||
|
25 changes: 25 additions & 0 deletions
25
...nav/tjenestepensjon/simulering/model/domain/pen/SimulerOffentligTjenestepensjonRequest.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,25 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
import no.nav.tjenestepensjon.simulering.v2.models.domain.SivilstandCodeEnum | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class SimulerOffentligTjenestepensjonRequest( | ||
val fnr: String, | ||
val fodselsdato: String, | ||
val sisteTpnr: String?, | ||
val sprak: String?, | ||
val simulertAFPOffentlig: SimulertAFPOffentligDto?, | ||
val simulertAFPPrivat: SimulertAFPPrivatDto?, | ||
val sivilstandkode: SivilstandCodeEnum, | ||
val inntektListe: List<InntektDto> = emptyList(), | ||
val pensjonsbeholdningsperiodeListe: List<PensjonsbeholdningsperiodeDto> = emptyList(), | ||
val simuleringsperiodeListe: List<SimuleringsperiodeDto> = emptyList(), | ||
val simuleringsdataListe: List<SimuleringsdataDto> = emptyList(), | ||
val tpForholdListe: List<TpForholdDto>? = emptyList(), | ||
){ | ||
|
||
override fun toString(): String { | ||
return "SimulerOffentligTjenestepensjonRequest(fodselsdato='$fodselsdato', sisteTpnr=$sisteTpnr, sprak=$sprak, simulertAFPOffentlig=$simulertAFPOffentlig, simulertAFPPrivat=$simulertAFPPrivat, sivilstandkode=$sivilstandkode, inntektListe=$inntektListe, pensjonsbeholdningsperiodeListe=$pensjonsbeholdningsperiodeListe, simuleringsperiodeListe=$simuleringsperiodeListe, simuleringsdataListe=$simuleringsdataListe, tpForholdListe=$tpForholdListe)" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/SimuleringsdataDto.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,17 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
import java.util.* | ||
|
||
data class SimuleringsdataDto ( | ||
val datoFom: Date, | ||
val andvendtTrygdetid: Int, | ||
val poengArTom1991: Int, | ||
val poengArFom1992: Int, | ||
val uforegradVedOmregning: Int, | ||
val basisgp: Double, | ||
val basispt: Double, | ||
val basistp: Double, | ||
val delingstallUttak: Double, | ||
val forholdstallUttak: Double, | ||
val sluttpoengtall: Double, | ||
) |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/SimuleringsperiodeDto.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,10 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
import java.util.* | ||
|
||
data class SimuleringsperiodeDto ( | ||
val datoFom: Date, | ||
val folketrygdUttaksgrad: Int, | ||
val stillingsprosentOffentlig: Int, | ||
val simulerAFPOffentligEtterfulgtAvAlder: Boolean, | ||
) |
6 changes: 6 additions & 0 deletions
6
...main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/SimulertAFPOffentligDto.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,6 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
data class SimulertAFPOffentligDto ( | ||
val simulertAFPOffentligBrutto: Int, | ||
val tpi: Int = 0, | ||
) |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/SimulertAFPPrivatDto.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,6 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
data class SimulertAFPPrivatDto ( | ||
val afpOpptjeningTotalbelop: Int, | ||
val kompensasjonstillegg: Double, | ||
) |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/no/nav/tjenestepensjon/simulering/model/domain/pen/TpForholdDto.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,6 @@ | ||
package no.nav.tjenestepensjon.simulering.model.domain.pen | ||
|
||
data class TpForholdDto ( | ||
val tpnr: String, | ||
val opptjeningsperiodeListe: List<OpptjeningsperiodeDto> = emptyList(), | ||
) |
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
59 changes: 59 additions & 0 deletions
59
src/main/kotlin/no/nav/tjenestepensjon/simulering/v1/models/DtoToV1DomainMapper.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,59 @@ | ||
package no.nav.tjenestepensjon.simulering.v1.models | ||
|
||
import no.nav.tjenestepensjon.simulering.model.domain.FNR | ||
import no.nav.tjenestepensjon.simulering.model.domain.Pensjonsbeholdningsperiode | ||
import no.nav.tjenestepensjon.simulering.model.domain.pen.* | ||
import no.nav.tjenestepensjon.simulering.v1.models.domain.Inntekt | ||
import no.nav.tjenestepensjon.simulering.v1.models.domain.Simuleringsperiode | ||
import no.nav.tjenestepensjon.simulering.v1.models.request.SimulerPensjonRequestV1 | ||
import no.nav.tjenestepensjon.simulering.v1.models.request.SimulertAFPPrivat | ||
import java.time.LocalDate | ||
import java.time.ZoneId | ||
import java.util.Date | ||
|
||
object DtoToV1DomainMapper { | ||
|
||
fun SimulerOffentligTjenestepensjonRequest.toSimulerPensjonRequestV1() = SimulerPensjonRequestV1( | ||
fnr = FNR(fnr), | ||
sivilstandkode = this.sivilstandkode.toString(), | ||
sprak = this.sprak ?: "norsk", | ||
simuleringsperioder = simuleringsperiodeListe.map { it.toSimuleringsperiode() }, | ||
simulertAFPOffentlig = this.simulertAFPOffentlig?.simulertAFPOffentligBrutto, | ||
simulertAFPPrivat = this.simulertAFPPrivat?.toSimulertAFPPrivat(), | ||
pensjonsbeholdningsperioder = this.pensjonsbeholdningsperiodeListe.map { it.toPensjonsbeholdningsperiode() }, | ||
inntekter = this.inntektListe.map { it.toInntekt() } | ||
) | ||
|
||
private fun SimuleringsperiodeDto.toSimuleringsperiode() = | ||
Simuleringsperiode( | ||
datoFom = convertToLocalDate(datoFom), | ||
utg = this.folketrygdUttaksgrad, | ||
stillingsprosentOffentlig = this.stillingsprosentOffentlig, | ||
//Følgende felt er ikke med i v1 | ||
// poengArTom1991 = this.poengArTom1991, | ||
// poengArFom1992 = this.poengArFom1992, | ||
// sluttpoengtall = this.sluttpoengtall, | ||
// anvendtTrygdetid = this.anvendtTrygdetid, | ||
// forholdstall = this.forholdstall, | ||
// delingstall = this.delingstall, | ||
// uforegradVedOmregning = this.uforegradVedOmregning, | ||
// delytelser = this.delytelser, | ||
) | ||
|
||
private fun SimulertAFPPrivatDto.toSimulertAFPPrivat() = | ||
SimulertAFPPrivat(afpOpptjeningTotalbelop, kompensasjonstillegg) | ||
|
||
private fun PensjonsbeholdningsperiodeDto.toPensjonsbeholdningsperiode() = Pensjonsbeholdningsperiode( | ||
datoFom = LocalDate.from(datoFom.toInstant().atZone(ZoneId.systemDefault())), | ||
pensjonsbeholdning = this.pensjonsbeholdning.toInt(), | ||
garantipensjonsbeholdning = this.garantipensjonsbeholdning.toInt(), | ||
garantitilleggsbeholdning = this.garantitilleggsbeholdning.toInt(), | ||
) | ||
|
||
private fun InntektDto.toInntekt() = Inntekt(convertToLocalDate(datoFom), inntekt) | ||
|
||
private fun convertToLocalDate(dato: Date): LocalDate = | ||
LocalDate.from(dato.toInstant().atZone(ZoneId.systemDefault())) | ||
} | ||
|
||
|
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
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
86 changes: 86 additions & 0 deletions
86
src/main/kotlin/no/nav/tjenestepensjon/simulering/v2/models/DtoToV2DomainMapper.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,86 @@ | ||
package no.nav.tjenestepensjon.simulering.v2.models | ||
|
||
import no.nav.tjenestepensjon.simulering.model.domain.FNR | ||
import no.nav.tjenestepensjon.simulering.model.domain.Pensjonsbeholdningsperiode | ||
import no.nav.tjenestepensjon.simulering.model.domain.pen.* | ||
import no.nav.tjenestepensjon.simulering.v2.models.DtoToV2DomainMapper.convertToLocalDate | ||
import no.nav.tjenestepensjon.simulering.v2.models.domain.Opptjeningsperiode | ||
import no.nav.tjenestepensjon.simulering.v2.models.request.* | ||
import java.time.LocalDate | ||
import java.time.ZoneId | ||
import java.util.Date | ||
|
||
object DtoToV2DomainMapper { | ||
|
||
fun SimulerOffentligTjenestepensjonRequest.toSimulerPensjonRequestV2() = SimulerPensjonRequestV2( | ||
fnr = FNR(fnr), | ||
fodselsdato = this.fodselsdato, | ||
sisteTpnr = this.sisteTpnr!!, | ||
sprak = this.sprak ?: "norsk", | ||
simulertAFPOffentlig = this.simulertAFPOffentlig?.let { | ||
SimulertAFPOffentlig( | ||
it.simulertAFPOffentligBrutto, | ||
it.tpi | ||
) | ||
}, | ||
simulertAFPPrivat = this.simulertAFPPrivat?.toSimulertAFPPrivat(), | ||
sivilstandkode = this.sivilstandkode, | ||
inntektListe = this.inntektListe.map { it.toInntekt() }, | ||
pensjonsbeholdningsperiodeListe = this.pensjonsbeholdningsperiodeListe.map { it.toPensjonsbeholdningsperiode() }, | ||
simuleringsperiodeListe = simuleringsperiodeListe.map { it.toSimuleringsperiode() }, | ||
simuleringsdataListe = this.simuleringsdataListe.map { it.toSimuleringsdata() }, | ||
tpForholdListe = this.tpForholdListe?.map { it.toTpForhold() } ?: emptyList(), | ||
) | ||
|
||
private fun SimuleringsperiodeDto.toSimuleringsperiode() = | ||
Simuleringsperiode( | ||
datoFom = datoFom.convertToLocalDate(), | ||
folketrygdUttaksgrad = this.folketrygdUttaksgrad, | ||
stillingsprosentOffentlig = this.stillingsprosentOffentlig, | ||
simulerAFPOffentligEtterfulgtAvAlder = this.simulerAFPOffentligEtterfulgtAvAlder, | ||
) | ||
|
||
private fun SimulertAFPPrivatDto.toSimulertAFPPrivat() = | ||
SimulertAFPPrivat(afpOpptjeningTotalbelop, kompensasjonstillegg) | ||
|
||
private fun PensjonsbeholdningsperiodeDto.toPensjonsbeholdningsperiode() = Pensjonsbeholdningsperiode( | ||
datoFom = LocalDate.from(datoFom.toInstant().atZone(ZoneId.systemDefault())), | ||
pensjonsbeholdning = this.pensjonsbeholdning.toInt(), | ||
garantipensjonsbeholdning = this.garantipensjonsbeholdning.toInt(), | ||
garantitilleggsbeholdning = this.garantitilleggsbeholdning.toInt(), | ||
) | ||
|
||
private fun InntektDto.toInntekt() = Inntekt(datoFom.convertToLocalDate(), inntekt) | ||
|
||
fun Date.convertToLocalDate(): LocalDate = | ||
LocalDate.from(this.toInstant().atZone(ZoneId.systemDefault())) | ||
|
||
private fun SimuleringsdataDto.toSimuleringsdata() = Simuleringsdata( | ||
datoFom = datoFom.convertToLocalDate(), | ||
andvendtTrygdetid = this.andvendtTrygdetid, | ||
poengArTom1991 = poengArTom1991, | ||
poengArFom1992 = poengArFom1992, | ||
uforegradVedOmregning = uforegradVedOmregning, | ||
basisgp = this.basisgp, | ||
basispt = this.basispt, | ||
basistp = this.basistp, | ||
delingstallUttak = this.delingstallUttak, | ||
forholdstallUttak = this.forholdstallUttak, | ||
sluttpoengtall = this.sluttpoengtall, | ||
) | ||
|
||
private fun TpForholdDto.toTpForhold() = TpForhold(this.tpnr, this.opptjeningsperiodeListe.map { | ||
Opptjeningsperiode( | ||
datoFom = it.datoFom.convertToLocalDate(), | ||
datoTom = it.datoTom.convertToLocalDate(), | ||
stillingsprosent = it.stillingsprosent.toDouble(), | ||
aldersgrense = it.aldersgrense, | ||
faktiskHovedlonn = it.faktiskHovedlonn, | ||
stillingsuavhengigTilleggslonn = it.stillingsuavhengigTilleggslonn, | ||
) | ||
}) | ||
} | ||
|
||
|
||
|
||
|
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
Oops, something went wrong.