Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fjern fritekst lagring på behandling og flytt ut lagring av revurderi… #6426

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ class BehandlingDao(
"""
INSERT INTO behandling(id, sak_id, behandling_opprettet, sist_endret, status, behandlingstype,
soeknad_mottatt_dato, virkningstidspunkt, utlandstilknytning, bodd_eller_arbeidet_utlandet,
revurdering_aarsak, fritekst_aarsak, prosesstype, kilde, begrunnelse, relatert_behandling,
revurdering_aarsak, prosesstype, kilde, begrunnelse, relatert_behandling,
sende_brev, opphoer_fom, tidligere_familiepleier)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""".trimIndent(),
)

Expand All @@ -253,14 +253,13 @@ class BehandlingDao(
stmt.setJsonb(9, utlandstilknytning)
stmt.setString(10, objectMapper.writeValueAsString(boddEllerArbeidetUtlandet))
stmt.setString(11, revurderingsAarsak?.name)
stmt.setString(12, fritekstAarsak)
stmt.setString(13, prosesstype.toString())
stmt.setString(14, kilde.toString())
stmt.setString(15, begrunnelse)
stmt.setString(16, relatertBehandlingId)
stmt.setBoolean(17, sendeBrev)
stmt.setString(18, opphoerFraOgMed?.let { fom -> objectMapper.writeValueAsString(fom) })
stmt.setJsonb(19, tidligereFamiliepleier)
stmt.setString(12, prosesstype.toString())
stmt.setString(13, kilde.toString())
stmt.setString(14, begrunnelse)
stmt.setString(15, relatertBehandlingId)
stmt.setBoolean(16, sendeBrev)
stmt.setString(17, opphoerFraOgMed?.let { fom -> objectMapper.writeValueAsString(fom) })
stmt.setJsonb(18, tidligereFamiliepleier)
}
checkInternFeil(stmt.executeUpdate() == 1) {
"Kunne ikke opprette behandling for ${behandling.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ data class OpprettBehandling(
val utlandstilknytning: Utlandstilknytning? = null,
val boddEllerArbeidetUtlandet: BoddEllerArbeidetUtlandet? = null,
val revurderingsAarsak: Revurderingaarsak? = null,
val fritekstAarsak: String? = null,
val prosesstype: Prosesstype = Prosesstype.MANUELL,
val kilde: Vedtaksloesning,
val begrunnelse: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ManuellRevurderingService(
val paaGrunnAvHendelseUuid =
try {
paaGrunnAvHendelseId?.let { UUID.fromString(it) }
} catch (e: Exception) {
} catch (_: Exception) {
throw BadRequestException(
"$aarsak har en ugyldig hendelse id for sakid" +
" $sakId. " +
Expand All @@ -56,7 +56,7 @@ class ManuellRevurderingService(
val paaGrunnAvOppgaveUuid =
try {
paaGrunnAvOppgaveId?.let { UUID.fromString(it) }
} catch (e: Exception) {
} catch (_: Exception) {
throw BadRequestException("Ugyldig oppgaveId $paaGrunnAvOppgaveId (sakid=$sakId).")
}

Expand Down Expand Up @@ -127,21 +127,20 @@ class ManuellRevurderingService(
utlandstilknytning = forrigeBehandling.utlandstilknytning,
boddEllerArbeidetUtlandet = forrigeBehandling.boddEllerArbeidetUtlandet,
begrunnelse = begrunnelse ?: triggendeOppgave?.merknad,
fritekstAarsak = fritekstAarsak,
saksbehandlerIdent = saksbehandler.ident,
frist = triggendeOppgave?.frist,
paaGrunnAvOppgave = paaGrunnAvOppgave,
opphoerFraOgMed = opphoerFraOgMed,
).oppdater()
.also { revurdering ->
// Eller sjekke revurdering annen?
if (!fritekstAarsak.isNullOrEmpty()) {
revurderingService.lagreRevurderingsaarsakFritekst(
if (!fritekstAarsak.isNullOrEmpty() && revurdering.revurderingsaarsak!!.kanLagreFritekstFeltForManuellRevurdering()) {
revurderingService.lagreRevurderingsaarsakFritekstForRevurderingAnnenMedEllerUtenBrev(
fritekstAarsak,
revurdering.id,
revurdering,
saksbehandler.ident,
)
}

if (paaGrunnAvHendelse != null) {
grunnlagsendringshendelseDao.settBehandlingIdForTattMedIRevurdering(
paaGrunnAvHendelse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class OmgjoeringKlageRevurderingService(
utlandstilknytning = behandlingSomOmgjoeres.utlandstilknytning,
boddEllerArbeidetUtlandet = behandlingSomOmgjoeres.boddEllerArbeidetUtlandet,
begrunnelse = "Omgjøring på grunn av klage",
fritekstAarsak = omgjoeringsoppgave.merknad,
saksbehandlerIdent = saksbehandler.ident,
relatertBehandlingId = klagenViOmgjoerPaaGrunnAv.id.toString(),
).oppdater()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import no.nav.etterlatte.libs.common.behandling.TidligereFamiliepleier
import no.nav.etterlatte.libs.common.behandling.Utlandstilknytning
import no.nav.etterlatte.libs.common.behandling.Virkningstidspunkt
import no.nav.etterlatte.libs.common.feilhaandtering.IkkeTillattException
import no.nav.etterlatte.libs.common.feilhaandtering.InternfeilException
import no.nav.etterlatte.libs.common.feilhaandtering.UgyldigForespoerselException
import no.nav.etterlatte.libs.common.grunnlag.Grunnlagsopplysning
import no.nav.etterlatte.libs.common.oppgave.OppgaveKilde
Expand Down Expand Up @@ -155,7 +156,6 @@ class RevurderingService(
utlandstilknytning: Utlandstilknytning?,
boddEllerArbeidetUtlandet: BoddEllerArbeidetUtlandet?,
begrunnelse: String?,
fritekstAarsak: String? = null,
saksbehandlerIdent: String?,
relatertBehandlingId: String? = null,
frist: Tidspunkt? = null,
Expand All @@ -175,7 +175,6 @@ class RevurderingService(
kilde = kilde,
prosesstype = prosessType,
begrunnelse = begrunnelse,
fritekstAarsak = fritekstAarsak,
relatertBehandlingId = relatertBehandlingId,
sendeBrev = revurderingAarsak.skalSendeBrev,
opphoerFraOgMed = opphoerFraOgMed,
Expand Down Expand Up @@ -279,13 +278,19 @@ class RevurderingService(
}
}

fun lagreRevurderingsaarsakFritekst(
fun lagreRevurderingsaarsakFritekstForRevurderingAnnenMedEllerUtenBrev(
fritekstAarsak: String,
behandlingId: UUID,
revurdering: Revurdering,
saksbehandlerIdent: String,
) {
val revurderingInfo = RevurderingInfo.RevurderingAarsakAnnen(fritekstAarsak)
lagreRevurderingInfo(behandlingId, RevurderingInfoMedBegrunnelse(revurderingInfo, null), saksbehandlerIdent)
val revurderingInfo =
when (revurdering.revurderingsaarsak) {
Revurderingaarsak.ANNEN -> RevurderingInfo.RevurderingAarsakAnnen(fritekstAarsak)
Revurderingaarsak.ANNEN_UTEN_BREV -> RevurderingInfo.RevurderingAarsakAnnenUtenBrev(fritekstAarsak)
else -> throw FeilRevurderingAarsakForFritekstLagring(revurdering)
}

lagreRevurderingInfo(revurdering.id, RevurderingInfoMedBegrunnelse(revurderingInfo, null), saksbehandlerIdent)
}
}

Expand All @@ -306,3 +311,9 @@ data class RevurderingOgOppfoelging(

fun sakType() = revurdering.sak.sakType
}

class FeilRevurderingAarsakForFritekstLagring(
revurdering: Revurdering,
) : InternfeilException(
detail = "Prøvde å lagre revurdering info annen/annen uten brev med årsak ${revurdering.revurderingsaarsak} id: ${revurdering.id}",
)
1 change: 0 additions & 1 deletion apps/etterlatte-behandling/src/test/kotlin/TestHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ fun opprettBehandling(
soeknadMottattDato = soeknadMottattDato,
virkningstidspunkt = virkningstidspunkt,
revurderingsAarsak = revurderingAarsak,
fritekstAarsak = fritekstAarsak,
prosesstype = prosesstype,
kilde = kilde,
sendeBrev = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class AktivitetspliktAktivitetsgradDaoTest(
utlandstilknytning = null,
boddEllerArbeidetUtlandet = null,
revurderingsAarsak = null,
fritekstAarsak = null,
prosesstype = Prosesstype.MANUELL,
kilde = Vedtaksloesning.GJENNY,
begrunnelse = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class AktivitetspliktUnntakDaoTest(
utlandstilknytning = null,
boddEllerArbeidetUtlandet = null,
revurderingsAarsak = null,
fritekstAarsak = null,
prosesstype = Prosesstype.MANUELL,
kilde = Vedtaksloesning.GJENNY,
begrunnelse = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ class ManuellRevurderingServiceTest : BehandlingIntegrationTest() {
every { it.id } returns UUID.randomUUID()
every { it.utlandstilknytning } returns null
every { it.boddEllerArbeidetUtlandet } returns null
every { it.revurderingsaarsak() } returns Revurderingaarsak.REVURDERE_ETTER_OPPHOER
}
},
grunnlagService = mockk<GrunnlagService>().also { coEvery { it.hentPersongalleri(any()) } returns mockk() },
Expand Down Expand Up @@ -903,7 +904,6 @@ class ManuellRevurderingServiceTest : BehandlingIntegrationTest() {
any(),
any(),
any(),
any(),
opphoerFraOgMed = null,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ internal class GrunnlagsendringshendelseDaoTest(
soeknadMottattDato = null,
virkningstidspunkt = null,
revurderingsAarsak = Revurderingaarsak.SOESKENJUSTERING,
fritekstAarsak = null,
prosesstype = Prosesstype.MANUELL,
kilde = Vedtaksloesning.GJENNY,
sendeBrev = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ class AarligInntektsjusteringJobbServiceTest {
any(),
any(),
any(),
any(),
any(),
)
} returns
mockk {
Expand Down Expand Up @@ -214,7 +212,6 @@ class AarligInntektsjusteringJobbServiceTest {
utlandstilknytning = any(),
boddEllerArbeidetUtlandet = any(),
begrunnelse = any(),
fritekstAarsak = any(),
saksbehandlerIdent = any(),
relatertBehandlingId = any(),
frist = any(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ enum class Revurderingaarsak(
val erIkkeStoetta = listOf(AARLIG_INNTEKTSJUSTERING)
return kanBrukesIMiljo() && gyldigForSakType(sakType) && !erIkkeStoetta.contains(this)
}

fun kanLagreFritekstFeltForManuellRevurdering(): Boolean = this in listOf<Revurderingaarsak>(ANNEN, ANNEN_UTEN_BREV)
}

enum class GcpEnv(
Expand Down