Skip to content

Commit

Permalink
Slår sammen sammenhengende perioder for husstandsmedlemmer før lagring
Browse files Browse the repository at this point in the history
  • Loading branch information
rinnan17 committed Nov 24, 2023
1 parent 262dc0e commit aef9faf
Show file tree
Hide file tree
Showing 98 changed files with 989 additions and 974 deletions.
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
<com.squareup.okhttp3.version>4.12.0</com.squareup.okhttp3.version>
<aordningen-inntektsinformasjon-v1.version>1.7</aordningen-inntektsinformasjon-v1.version>
<bidrag-behandling-felles.version>0.0.85</bidrag-behandling-felles.version>
<bidrag-domain.version>20230621111817_df046e8</bidrag-domain.version>
<!-- <bidrag-behandling-felles-dto.version>0.0.95</bidrag-behandling-felles-dto.version>-->
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -117,11 +115,6 @@
<artifactId>bidrag-transport</artifactId>
<version>${bidrag-transport.version}</version>
</dependency>
<dependency>
<groupId>no.nav.bidrag</groupId>
<artifactId>bidrag-domain</artifactId>
<version>${bidrag-domain.version}</version>
</dependency>
<dependency>
<groupId>no.nav.bidrag</groupId>
<artifactId>bidrag-tilgangskontroll</artifactId>
Expand Down
22 changes: 11 additions & 11 deletions src/main/kotlin/no/nav/bidrag/grunnlag/BidragGrunnlagConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ const val LIVE_PROFILE = "live"
@Configuration
@OpenAPIDefinition(
info = Info(title = "bidrag-grunnlag", version = "v1"),
security = [SecurityRequirement(name = "bearer-key")]
security = [SecurityRequirement(name = "bearer-key")],
)
@EnableJwtTokenValidation
@SecurityScheme(
bearerFormat = "JWT",
name = "bearer-key",
scheme = "bearer",
type = SecuritySchemeType.HTTP
type = SecuritySchemeType.HTTP,
)
@Import(CorrelationIdFilter::class, UserMdcFilter::class, DefaultCorsFilter::class)
class BidragGrunnlagConfig {
Expand Down Expand Up @@ -71,7 +71,7 @@ class BidragGrunnlagConfig {
@Value("\${FAMILIEBASAK_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): FamilieBaSakConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -84,7 +84,7 @@ class BidragGrunnlagConfig {
@Value("\${FAMILIEEFSAK_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): FamilieEfSakConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -97,7 +97,7 @@ class BidragGrunnlagConfig {
@Value("\${INNTEKTSKOMPONENTEN_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): InntektskomponentenConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -110,7 +110,7 @@ class BidragGrunnlagConfig {
@Value("\${SIGRUN_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): SigrunConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -123,7 +123,7 @@ class BidragGrunnlagConfig {
@Value("\${PENSJON_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): PensjonConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -136,7 +136,7 @@ class BidragGrunnlagConfig {
@Value("\${BIDRAGPERSON_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): BidragPersonConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -149,7 +149,7 @@ class BidragGrunnlagConfig {
@Value("\${FAMILIEKSSAK_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): FamilieKsSakConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -162,7 +162,7 @@ class BidragGrunnlagConfig {
@Value("\${AAREG_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
securityTokenService: SecurityTokenService,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): ArbeidsforholdConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand All @@ -174,7 +174,7 @@ class BidragGrunnlagConfig {
fun enhetsregisterConsumer(
@Value("\${EREG_URL}") url: String,
restTemplate: HttpHeaderRestTemplate,
exceptionLogger: ExceptionLogger
exceptionLogger: ExceptionLogger,
): EnhetsregisterConsumer {
LOGGER.info("Url satt i config: $url")
restTemplate.uriTemplateHandler = RootUriTemplateHandler(url)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/AinntektBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class AinntektBo(
val brukTil: LocalDateTime? = null,

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime = LocalDateTime.now()
val hentetTidspunkt: LocalDateTime = LocalDateTime.now(),

) : IPeriod

Expand All @@ -45,6 +45,6 @@ fun AinntektBo.toAinntektEntity() = with(::Ainntekt) {
when (parameter.name) {
else -> propertiesByName[parameter.name]?.get(this@toAinntektEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/AinntektspostBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data class AinntektspostBo(
val etterbetalingsperiodeFra: LocalDate?,

@Schema(description = "Til-dato etterbetaling")
val etterbetalingsperiodeTil: LocalDate?
val etterbetalingsperiodeTil: LocalDate?,
)

fun AinntektspostBo.toAinntektspostEntity() = with(::Ainntektspost) {
Expand All @@ -53,6 +53,6 @@ fun AinntektspostBo.toAinntektspostEntity() = with(::Ainntektspost) {
Ainntektspost::inntektspostId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toAinntektspostEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/BarnetilleggBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data class BarnetilleggBo(
val barnType: String = "",

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime = LocalDateTime.now()
val hentetTidspunkt: LocalDateTime = LocalDateTime.now(),
)

fun BarnetilleggBo.toBarnetilleggEntity() = with(::Barnetillegg) {
Expand All @@ -54,6 +54,6 @@ fun BarnetilleggBo.toBarnetilleggEntity() = with(::Barnetillegg) {
Barnetillegg::barnetilleggId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toBarnetilleggEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/BarnetilsynBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data class BarnetilsynBo(
val skolealder: Skolealder?,

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime = LocalDateTime.now()
val hentetTidspunkt: LocalDateTime = LocalDateTime.now(),
)

fun BarnetilsynBo.toBarnetilsynEntity() = with(::Barnetilsyn) {
Expand All @@ -55,6 +55,6 @@ fun BarnetilsynBo.toBarnetilsynEntity() = with(::Barnetilsyn) {
Barnetilsyn::barnetilsynId.name -> 0
else -> propertiesByName[parameters.name]?.get(this@toBarnetilsynEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/GrunnlagspakkeBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data class GrunnlagspakkeBo(
val gyldigTil: LocalDate?,

@Schema(description = "Til hvilket formål skal grunnlagspakken benyttes. Bidrag, Forskudd, Særtilskudd")
val formaal: String
val formaal: String,
)

fun GrunnlagspakkeBo.toGrunnlagspakkeEntity() = with(::Grunnlagspakke) {
Expand All @@ -32,6 +32,6 @@ fun GrunnlagspakkeBo.toGrunnlagspakkeEntity() = with(::Grunnlagspakke) {
Grunnlagspakke::grunnlagspakkeId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toGrunnlagspakkeEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/KontantstotteBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data class KontantstotteBo(
val belop: Int,

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime = LocalDateTime.now()
val hentetTidspunkt: LocalDateTime = LocalDateTime.now(),

)

Expand All @@ -48,6 +48,6 @@ fun KontantstotteBo.toKontantstotteEntity() = with(::Kontantstotte) {
Kontantstotte::kontantstotteId.name -> 0
else -> propertiesByName[parameters.name]?.get(this@toKontantstotteEntity)
}
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class OvergangsstønadBo(
val belop: Int,

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime = LocalDateTime.now()
val hentetTidspunkt: LocalDateTime = LocalDateTime.now(),

)

Expand All @@ -45,6 +45,6 @@ fun OvergangsstønadBo.toOvergangsstønadEntity() = with(::Overgangsstonad) {
Overgangsstonad::overgangsstonadId.name -> 0
else -> propertiesByName[parameters.name]?.get(this@toOvergangsstønadEntity)
}
}
},
)
}
2 changes: 1 addition & 1 deletion src/main/kotlin/no/nav/bidrag/grunnlag/bo/PersonBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ data class PersonBo(
var navn: String?,
var fodselsdato: LocalDate?,
val husstandsmedlemPeriodeFra: LocalDate? = null,
val husstandsmedlemPeriodeTil: LocalDate? = null
val husstandsmedlemPeriodeTil: LocalDate? = null,
)
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/RelatertPersonBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data class RelatertPersonBo(
val brukTil: LocalDateTime? = null,

@Schema(description = "Opprettet tidspunkt")
val hentetTidspunkt: LocalDateTime
val hentetTidspunkt: LocalDateTime,
)

fun RelatertPersonBo.toRelatertPersonEntity() = with(::RelatertPerson) {
Expand All @@ -53,6 +53,6 @@ fun RelatertPersonBo.toRelatertPersonEntity() = with(::RelatertPerson) {
RelatertPerson::relatertPersonId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toRelatertPersonEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/SivilstandBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class SivilstandBo(
val brukTil: LocalDateTime? = null,

@Schema(description = "Opprettet tidspunkt")
val hentetTidspunkt: LocalDateTime
val hentetTidspunkt: LocalDateTime,

)

Expand All @@ -45,6 +45,6 @@ fun SivilstandBo.toSivilstandEntity() = with(::Sivilstand) {
Sivilstand::sivilstandId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toSivilstandEntity)
}
}
},
)
}
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/bidrag/grunnlag/bo/SkattegrunnlagBo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class SkattegrunnlagBo(
val brukTil: LocalDateTime? = null,

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime = LocalDateTime.MAX
val hentetTidspunkt: LocalDateTime = LocalDateTime.MAX,
) : IPeriod

fun SkattegrunnlagBo.toSkattegrunnlagEntity() = with(::Skattegrunnlag) {
Expand All @@ -44,6 +44,6 @@ fun SkattegrunnlagBo.toSkattegrunnlagEntity() = with(::Skattegrunnlag) {
when (parameter.name) {
else -> propertiesByName[parameter.name]?.get(this@toSkattegrunnlagEntity)
}
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data class SkattegrunnlagspostBo(
val inntektType: String,

@Schema(description = "Belop")
val belop: BigDecimal
val belop: BigDecimal,
)

fun SkattegrunnlagspostBo.toSkattegrunnlagspostEntity() = with(::Skattegrunnlagspost) {
Expand All @@ -28,6 +28,6 @@ fun SkattegrunnlagspostBo.toSkattegrunnlagspostEntity() = with(::Skattegrunnlags
Skattegrunnlagspost::skattegrunnlagspostId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toSkattegrunnlagspostEntity)
}
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data class UtvidetBarnetrygdOgSmaabarnstilleggBo(
val deltBosted: Boolean,

@Schema(description = "Hentet tidspunkt")
val hentetTidspunkt: LocalDateTime
val hentetTidspunkt: LocalDateTime,
)

fun UtvidetBarnetrygdOgSmaabarnstilleggBo.toUtvidetBarnetrygdOgSmaabarnstilleggEntity() = with(::UtvidetBarnetrygdOgSmaabarnstillegg) {
Expand All @@ -54,6 +54,6 @@ fun UtvidetBarnetrygdOgSmaabarnstilleggBo.toUtvidetBarnetrygdOgSmaabarnstilleggE
UtvidetBarnetrygdOgSmaabarnstillegg::ubstId.name -> 0
else -> propertiesByName[parameter.name]?.get(this@toUtvidetBarnetrygdOgSmaabarnstilleggEntity)
}
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class AbstractPeriodComparator<T : PeriodComparable<*, *>> {
fun comparePeriodEntities(
requestedPeriod: IPeriod,
newEntities: List<T>,
existingEntities: List<T>
existingEntities: List<T>,
): ComparatorResult<T> {
val expiredEntities = mutableListOf<T>()
val updatedEntities = mutableListOf<T>()
Expand All @@ -39,8 +39,8 @@ abstract class AbstractPeriodComparator<T : PeriodComparable<*, *>> {
} else {
SECURE_LOGGER.debug(
"Ny og eksisterende entitet er ulike. Ny: ${
toJsonString(newEntity)
}, Eksisterende: ${toJsonString(existingEntityWithEqualPeriod)}."
toJsonString(newEntity)
}, Eksisterende: ${toJsonString(existingEntityWithEqualPeriod)}.",
)
expiredEntities.add(existingEntityWithEqualPeriod)
updatedEntities.add(newEntity)
Expand All @@ -67,11 +67,11 @@ abstract class AbstractPeriodComparator<T : PeriodComparable<*, *>> {

private fun findEntityWithEqualPeriod(
periodEntity: T,
periodEntities: List<T>
periodEntities: List<T>,
): T? {
return periodEntities.find { t ->
t.periodEntity.periodeFra.isEqual(periodEntity.periodEntity.periodeFra) && t.periodEntity.periodeTil.isEqual(
periodEntity.periodEntity.periodeTil
periodEntity.periodEntity.periodeTil,
)
}
}
Expand All @@ -80,7 +80,7 @@ abstract class AbstractPeriodComparator<T : PeriodComparable<*, *>> {
existingEntities: List<T>,
newEntities: List<T>,
requestedPeriod: IPeriod,
expiredEntities: MutableList<T>
expiredEntities: MutableList<T>,
): List<T> {
val filteredEntities = mutableListOf<T>()
existingEntities.forEach() { existingEntity ->
Expand Down Expand Up @@ -112,7 +112,7 @@ open class PeriodComparable<PeriodEntity : IPeriod, Child>(val periodEntity: Per
class ComparatorResult<T : PeriodComparable<*, *>>(
val expiredEntities: List<T>,
val updatedEntities: List<T>,
val equalEntities: List<T>
val equalEntities: List<T>,
)

fun LocalDate.isAfterOrEqual(startDate: LocalDate): Boolean {
Expand Down
Loading

0 comments on commit aef9faf

Please sign in to comment.