Skip to content

Commit eac170c

Browse files
committed
Lagre periode på inntekt_person_mapping
1 parent 9c25aec commit eac170c

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/db/PostgresInntektStore.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,25 @@ internal class PostgresInntektStore(
242242
)
243243
tx.run(
244244
queryOf(
245-
"INSERT INTO inntekt_V1_person_mapping(inntektId, aktørId, fnr, kontekstId, beregningsdato, kontekstType) VALUES (:inntektId, :aktorId, :fnr, :kontekstId, :beregningsdato, :kontekstType::kontekstTypeNavn)",
245+
"""
246+
INSERT INTO inntekt_V1_person_mapping(inntektId, aktørId, fnr, kontekstId, beregningsdato, kontekstType, periodeFraOgMed, periodeTilOgMed)
247+
VALUES (:inntektId, :aktorId, :fnr, :kontekstId, :beregningsdato, :kontekstType::kontekstTypeNavn, :periodeFraOgMed, :periodeTilOgMed)
248+
""".trimIndent(),
246249
mapOf(
247250
"inntektId" to inntektId.id,
248251
"aktorId" to command.inntektparametre.aktørId,
249252
"fnr" to command.inntektparametre.fødselsnummer,
250253
"kontekstId" to command.inntektparametre.regelkontekst.id,
251254
"kontekstType" to command.inntektparametre.regelkontekst.type,
252255
"beregningsdato" to command.inntektparametre.beregningsdato,
256+
"periodeFraOgMed" to
257+
command.inntektparametre.opptjeningsperiode.førsteMåned.let {
258+
LocalDate.of(it.year, it.month, 1)
259+
},
260+
"periodeTilOgMed" to
261+
command.inntektparametre.opptjeningsperiode.sisteAvsluttendeKalenderMåned.let {
262+
LocalDate.of(it.year, it.month, 1)
263+
},
253264
),
254265
).asUpdate,
255266
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE inntekt_v1_person_mapping
2+
ADD COLUMN periodeFraOgMed DATE,
3+
ADD COLUMN periodeTilOgMed DATE;

dp-inntekt-api/src/test/kotlin/no/nav/dagpenger/inntekt/db/PostgresTest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class PostgresTest {
2929
fun `Migration scripts are applied successfully`() {
3030
withCleanDb {
3131
val migrations = PostgresDataSourceBuilder.runMigration()
32-
assertEquals(16, migrations, "Wrong number of migrations")
32+
assertEquals(17, migrations, "Wrong number of migrations")
3333
}
3434
}
3535

@@ -45,7 +45,7 @@ internal class PostgresTest {
4545
fun `Migration of testdata `() {
4646
withCleanDb {
4747
val migrations = PostgresDataSourceBuilder.runMigration(locations = listOf("db/migration", "db/testdata"))
48-
assertEquals(21, migrations, "Wrong number of migrations")
48+
assertEquals(22, migrations, "Wrong number of migrations")
4949
}
5050
}
5151
}
@@ -474,7 +474,9 @@ internal class InntektsStorePropertyTest : StringSpec() {
474474
regelkontekst = RegelKontekst(kontekstId.next(it), "vedtak"),
475475
fødselsnummer = aktørId.next(it),
476476
beregningsdato =
477-
Arb.localDateTime(minYear = 2010, maxYear = LocalDate.now().year).next(it)
477+
Arb
478+
.localDateTime(minYear = 2010, maxYear = LocalDate.now().year)
479+
.next(it)
478480
.toLocalDate(),
479481
),
480482
inntekt =

0 commit comments

Comments
 (0)