diff --git a/bidrag-domene/src/main/kotlin/no/nav/bidrag/domene/enums/grunnlag/Grunnlagstype.kt b/bidrag-domene/src/main/kotlin/no/nav/bidrag/domene/enums/grunnlag/Grunnlagstype.kt index 82bbc344..29e4bc44 100644 --- a/bidrag-domene/src/main/kotlin/no/nav/bidrag/domene/enums/grunnlag/Grunnlagstype.kt +++ b/bidrag-domene/src/main/kotlin/no/nav/bidrag/domene/enums/grunnlag/Grunnlagstype.kt @@ -57,9 +57,9 @@ enum class Grunnlagstype { // Inntekt som er beregnet av bidrag-inntekt BEREGNET_INNTEKT, - INNHENTET_HUSSTANDSMEDLEM_PERIODE, - INNHENTET_SIVILSTAND_PERIODE, - INNHENTET_ARBEIDSFORHOLD_PERIODE, + INNHENTET_HUSSTANDSMEDLEM, + INNHENTET_SIVILSTAND, + INNHENTET_ARBEIDSFORHOLD, INNHENTET_INNTEKT_SKATTEGRUNNLAG_PERIODE, INNHENTET_INNTEKT_AORDNING_PERIODE, INNHENTET_INNTEKT_BARNETILLEGG_PERIODE, diff --git a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Felles.kt b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Felles.kt index 6556a253..27c63d6d 100644 --- a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Felles.kt +++ b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Felles.kt @@ -97,16 +97,16 @@ interface GrunnlagPeriodeInnhold : GrunnlagInnhold { val manueltRegistrert: Boolean } -interface InnhentetGrunnlagPeriodeInnhold : GrunnlagInnhold { - val periode: Datoperiode -} - -interface InnhentetGrunnlagInnhold : InnhentetGrunnlagPeriodeInnhold { +interface InnhentetGrunnlagInnhold : GrunnlagInnhold { @get:Schema(description = "Tidspunkt data hentet fra kilden") val hentetTidspunkt: LocalDateTime val grunnlag: T } +interface InnhentetGrunnlagPeriodeInnhold : InnhentetGrunnlagInnhold { + val periode: Datoperiode +} + @Schema(description = "Informasjon om en person som er inkludert i vedtaket") data class Person( val ident: Personident? = null, diff --git a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/GrunnlagExtensions.kt b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/GrunnlagExtensions.kt index 5c39ac4b..ef394b71 100644 --- a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/GrunnlagExtensions.kt +++ b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/GrunnlagExtensions.kt @@ -11,7 +11,9 @@ inline fun BaseGrunnlag.innholdTilObjekt(): T { inline fun List.innholdTilObjekt(): List = map(BaseGrunnlag::innholdTilObjekt) -fun List.hentAllePersoner(): List = filter { it.type.name.startsWith("PERSON_") } +fun List.hentAllePersoner(): List = filter { it.erPerson() } + +fun BaseGrunnlag.erPerson(): Boolean = type.name.startsWith("PERSON_") fun List.filtrerBasertPåFremmedReferanse( grunnlagType: Grunnlagstype? = null, diff --git a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Grunnlagreferanse.kt b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Grunnlagreferanse.kt index ec764ec6..70a2621e 100644 --- a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Grunnlagreferanse.kt +++ b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Grunnlagreferanse.kt @@ -3,43 +3,20 @@ package no.nav.bidrag.transport.behandling.felles.grunnlag import no.nav.bidrag.domene.enums.grunnlag.Grunnlagstype import no.nav.bidrag.domene.tid.ÅrMånedsperiode import no.nav.bidrag.transport.behandling.grunnlag.response.AinntektGrunnlagDto -import no.nav.bidrag.transport.behandling.grunnlag.response.ArbeidsforholdGrunnlagDto import no.nav.bidrag.transport.behandling.grunnlag.response.BarnetilleggGrunnlagDto import no.nav.bidrag.transport.behandling.grunnlag.response.BarnetilsynGrunnlagDto -import no.nav.bidrag.transport.behandling.grunnlag.response.BorISammeHusstandDto import no.nav.bidrag.transport.behandling.grunnlag.response.KontantstøtteGrunnlagDto -import no.nav.bidrag.transport.behandling.grunnlag.response.RelatertPersonGrunnlagDto -import no.nav.bidrag.transport.behandling.grunnlag.response.SivilstandGrunnlagDto import no.nav.bidrag.transport.behandling.grunnlag.response.SkattegrunnlagGrunnlagDto import no.nav.bidrag.transport.behandling.grunnlag.response.SmåbarnstilleggGrunnlagDto import no.nav.bidrag.transport.behandling.grunnlag.response.UtvidetBarnetrygdGrunnlagDto import no.nav.bidrag.transport.felles.toCompactString -import java.time.LocalDate fun Grunnlagstype.tilPersonreferanse( - fødseldato: String, + identifikator: String, id: Int, -) = "person_${this}_${fødseldato}_$id" - -fun RelatertPersonGrunnlagDto.tilGrunnlagsreferanse(index: Int) = - Grunnlagstype.PERSON_HUSSTANDSMEDLEM.tilPersonreferanse( - fødselsdato?.toCompactString() ?: LocalDate.MIN.toCompactString(), - index, - ) - -fun SivilstandGrunnlagDto.tilGrunnlagsreferanse( - referanseGjelder: Grunnlagsreferanse, - index: Int, -) = "innhentet_sivilstand_${referanseGjelder}_${type}_${gyldigFom.toCompactString()}_$index" - -fun BorISammeHusstandDto.tilGrunnlagsreferanse( - referanseGjelder: Grunnlagsreferanse, - referanseRelatertTil: Grunnlagsreferanse, -) = "innhentet_husstandsmedlem_${referanseGjelder}_${referanseRelatertTil}_${periodeFra.toCompactString()}" - -fun ArbeidsforholdGrunnlagDto.tilGrunnlagsreferanse(referanseGjelder: Grunnlagsreferanse) = - "innhentet_arbeidsforhold_${referanseGjelder}_${arbeidsgiverOrgnummer}_${startdato.toCompactString()}" +) = "person_${this}_${identifikator}_$id" +// Bidrag-grunnlag objekter til referanse fun SmåbarnstilleggGrunnlagDto.tilGrunnlagsreferanse(referanseGjelder: Grunnlagsreferanse) = "innhentet_småbarnstillegg_${referanseGjelder}_${periodeFra.toCompactString()}" @@ -68,6 +45,16 @@ fun SkattegrunnlagGrunnlagDto.tilGrunnlagsreferanse(referanseGjelder: Grunnlagsr fun AinntektGrunnlagDto.tilGrunnlagsreferanse(referanseGjelder: Grunnlagsreferanse) = "innhentet_ainntekt_${referanseGjelder}_${periodeFra.toCompactString()}" +fun opprettInnhentetHusstandsmedlemGrunnlagsreferanse( + referanseGjelder: Grunnlagsreferanse, + referanseRelatertTil: Grunnlagsreferanse, +) = "innhentet_husstandsmedlem_${referanseGjelder}_$referanseRelatertTil" + +fun opprettArbeidsforholdGrunnlagsreferanse(referanseGjelder: Grunnlagsreferanse) = "innhentet_arbeidsforhold_$referanseGjelder" + +fun opprettInnhentetSivilstandGrunnlagsreferanse(referanseGjelder: Grunnlagsreferanse) = "innhentet_sivilstand_$referanseGjelder" + +// Beregning fun opprettSluttberegningreferanse( barnreferanse: Grunnlagsreferanse, periode: ÅrMånedsperiode, diff --git a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Husstandsmedlem.kt b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Husstandsmedlem.kt index 81d2c7b6..0c58b0f7 100644 --- a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Husstandsmedlem.kt +++ b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Husstandsmedlem.kt @@ -4,10 +4,10 @@ import io.swagger.v3.oas.annotations.media.Schema import no.nav.bidrag.domene.enums.person.Bostatuskode import no.nav.bidrag.domene.tid.Datoperiode import no.nav.bidrag.domene.tid.ÅrMånedsperiode +import java.time.LocalDate import java.time.LocalDateTime data class InnhentetHusstandsmedlem( - override val periode: Datoperiode, override val grunnlag: HusstandsmedlemPDL, override val hentetTidspunkt: LocalDateTime, ) : InnhentetGrunnlagInnhold { @@ -15,6 +15,11 @@ data class InnhentetHusstandsmedlem( @Schema(description = "Referanse til person som er husstandsmedlem") val relatertPerson: Grunnlagsreferanse?, val erBarnAvBmBp: Boolean, + @Schema(description = "Navn på den relaterte personen, format , ) } @@ -22,5 +27,7 @@ data class InnhentetHusstandsmedlem( data class BostatusPeriode( override val periode: ÅrMånedsperiode, val bostatus: Bostatuskode, + @Schema(description = "Referanse til BM eller BP som bosstatus for personen som gjelder") + val relatertTilPart: Grunnlagsreferanse, override val manueltRegistrert: Boolean, ) : GrunnlagPeriodeInnhold diff --git a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/InntektInnhentet.kt b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/InntektInnhentet.kt index 33b3ea7f..07d1399f 100644 --- a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/InntektInnhentet.kt +++ b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/InntektInnhentet.kt @@ -10,10 +10,9 @@ import java.time.LocalDateTime import java.time.YearMonth data class InnhentetArbeidsforhold( - override val periode: Datoperiode, - override val grunnlag: Arbeidsforhold, + override val grunnlag: List, override val hentetTidspunkt: LocalDateTime, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagInnhold> { data class Arbeidsforhold( @Schema(description = "Startdato for arbeidsforholdet") val startdato: LocalDate?, @@ -74,7 +73,7 @@ data class InnhentetSkattegrunnlag( val år: Int = periode.fom.year, override val hentetTidspunkt: LocalDateTime, override val grunnlag: Skattegrunnlag, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class Skattegrunnlag( val skattegrunnlagListe: List, ) @@ -97,7 +96,7 @@ data class InnhentetBarnetillegg( override val periode: Datoperiode, override val hentetTidspunkt: LocalDateTime, override val grunnlag: Barnetillegg, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class Barnetillegg( @Schema(description = "Referansen barnet barnetillegget er rapportert for") val gjelderBarn: Grunnlagsreferanse, @@ -113,7 +112,7 @@ data class InnhentetAinntekt( override val periode: Datoperiode, override val hentetTidspunkt: LocalDateTime, override val grunnlag: AinntektInnhentet, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class AinntektInnhentet( val ainntektspostListe: List, ) @@ -136,7 +135,7 @@ data class InnhentetUtvidetBarnetrygd( override val periode: Datoperiode, override val hentetTidspunkt: LocalDateTime, override val grunnlag: UtvidetBarnetrygd, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class UtvidetBarnetrygd( @Schema(description = "Beløp") val beløp: BigDecimal, @@ -149,7 +148,7 @@ data class InnhentetSmåbarnstillegg( override val periode: Datoperiode, override val hentetTidspunkt: LocalDateTime, override val grunnlag: Småbarnstillegg, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class Småbarnstillegg( @Schema(description = "Beløp") val beløp: BigDecimal, @@ -162,7 +161,7 @@ data class InnhentetBarnetilsyn( override val periode: Datoperiode, override val hentetTidspunkt: LocalDateTime, override val grunnlag: Barnetilsyn, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class Barnetilsyn( val gjelderBarn: Grunnlagsreferanse, val beløp: Int?, @@ -175,7 +174,7 @@ data class InnhentetKontantstøtte( override val periode: Datoperiode, override val hentetTidspunkt: LocalDateTime, override val grunnlag: Kontantstøtte, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagPeriodeInnhold { data class Kontantstøtte( val gjelderBarn: Grunnlagsreferanse, val beløp: Int, diff --git a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Sivilstand.kt b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Sivilstand.kt index ed338fba..4cfc8146 100644 --- a/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Sivilstand.kt +++ b/bidrag-transport/src/main/kotlin/no/nav/bidrag/transport/behandling/felles/grunnlag/Sivilstand.kt @@ -3,17 +3,16 @@ package no.nav.bidrag.transport.behandling.felles.grunnlag import io.swagger.v3.oas.annotations.media.Schema import no.nav.bidrag.domene.enums.person.Sivilstandskode import no.nav.bidrag.domene.enums.person.SivilstandskodePDL -import no.nav.bidrag.domene.tid.Datoperiode import no.nav.bidrag.domene.tid.ÅrMånedsperiode import java.time.LocalDate import java.time.LocalDateTime data class InnhentetSivilstand( - override val periode: Datoperiode, - override val grunnlag: SivilstandPDL, + override val grunnlag: List, override val hentetTidspunkt: LocalDateTime, -) : InnhentetGrunnlagInnhold { +) : InnhentetGrunnlagInnhold> { data class SivilstandPDL( + val gyldigFom: LocalDate?, @Schema(description = "Type sivilstand fra PDL") val sivilstand: SivilstandskodePDL?, @Schema(description = "Dato NAV tidligst har fått bekreftet sivilstanden") @@ -22,6 +21,8 @@ data class InnhentetSivilstand( val master: String?, @Schema(description = "Angir om sivilstanden er historisk (true) eller aktiv (false)") val historisk: Boolean?, + @Schema(description = "Tidspunktet sivilstanden er registrert") + val registrert: LocalDateTime?, ) } diff --git a/bidrag-transport/src/test/kotlin/no/nav/bidrag/transport/behandling/beregning/felles/BeregninFellesTest.kt b/bidrag-transport/src/test/kotlin/no/nav/bidrag/transport/behandling/beregning/felles/BeregninFellesTest.kt index 51d89537..4c0319e6 100644 --- a/bidrag-transport/src/test/kotlin/no/nav/bidrag/transport/behandling/beregning/felles/BeregninFellesTest.kt +++ b/bidrag-transport/src/test/kotlin/no/nav/bidrag/transport/behandling/beregning/felles/BeregninFellesTest.kt @@ -105,6 +105,7 @@ class BeregninFellesTest { periode = ÅrMånedsperiode(LocalDate.parse("2020-01-01"), null), manueltRegistrert = false, bostatus = Bostatuskode.MED_FORELDER, + relatertTilPart = "person_bm_2", ), ), ),