-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ny behandling etteroppgjoer #7079
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3d6a864
Egen side og endepunkt for forbehandling etteroppgjør
Bjodn 0c09c1b
Ny tabell og dao
Bjodn 8bc65af
Opprett etteroppgjoer i service
Bjodn eab5e47
Hent etteroppgjør behandling med tilgangsjekk
Bjodn a2f7838
Tilpasse modell frontend
Bjodn 05658ee
Gjenbruk av mapping til SakMedGraderingOgSkjermet fra db
Bjodn d31821b
Fikse feilende unittester
Bjodn ef32698
Tilbakemelding QA
Bjodn 05b2a8b
Fjerner prefiks interface frontend
Bjodn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
74 changes: 74 additions & 0 deletions
74
apps/etterlatte-behandling/src/main/kotlin/behandling/etteroppgjoer/EtteroppgjoerDao.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,74 @@ | ||
package no.nav.etterlatte.behandling.etteroppgjoer | ||
|
||
import no.nav.etterlatte.common.ConnectionAutoclosing | ||
import no.nav.etterlatte.libs.common.Enhetsnummer | ||
import no.nav.etterlatte.libs.common.feilhaandtering.krev | ||
import no.nav.etterlatte.libs.common.sak.Sak | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
import no.nav.etterlatte.libs.common.tidspunkt.getTidspunkt | ||
import no.nav.etterlatte.libs.common.tidspunkt.setTidspunkt | ||
import no.nav.etterlatte.libs.database.setSakId | ||
import no.nav.etterlatte.libs.database.singleOrNull | ||
import java.sql.ResultSet | ||
import java.util.UUID | ||
|
||
class EtteroppgjoerDao( | ||
private val connectionAutoclosing: ConnectionAutoclosing, | ||
) { | ||
fun hentEtteroppgjoer(behandlingId: UUID): EtteroppgjoerBehandling? = | ||
connectionAutoclosing.hentConnection { | ||
with(it) { | ||
val statement = | ||
prepareStatement( | ||
""" | ||
SELECT t.id, t.sak_id, s.saktype, s.fnr, s.enhet, t.opprettet, t.status | ||
FROM etteroppgjoer_behandling t INNER JOIN sak s on t.sak_id = s.id | ||
WHERE t.id = ? | ||
""".trimIndent(), | ||
) | ||
statement.setObject(1, behandlingId) | ||
statement.executeQuery().singleOrNull { toEtteroppgjoer() } | ||
} | ||
} | ||
|
||
fun lagreEtteroppgjoer(etteroppgjoer: EtteroppgjoerBehandling) = | ||
connectionAutoclosing.hentConnection { | ||
with(it) { | ||
val statement = | ||
prepareStatement( | ||
""" | ||
INSERT INTO etteroppgjoer_behandling( | ||
id, status, sak_id, opprettet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mangler vi aar fra EtteroppgjoerBehandling? |
||
) | ||
VALUES (?, ?, ?, ?) | ||
ON CONFLICT (id) DO UPDATE SET | ||
status = excluded.status | ||
""".trimIndent(), | ||
) | ||
statement.setObject(1, etteroppgjoer.id) | ||
statement.setString(2, etteroppgjoer.status) | ||
statement.setSakId(3, etteroppgjoer.sak.id) | ||
statement.setTidspunkt(4, etteroppgjoer.opprettet) | ||
statement.executeUpdate().also { | ||
krev(it == 1) { | ||
"Kunne ikke lagre forbehandling etteroppgjør for sakid ${etteroppgjoer.sak.id}" | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun ResultSet.toEtteroppgjoer(): EtteroppgjoerBehandling = | ||
EtteroppgjoerBehandling( | ||
id = getString("id").let { UUID.fromString(it) }, | ||
sak = | ||
Sak( | ||
id = SakId(getLong("sak_id")), | ||
sakType = enumValueOf(getString("saktype")), | ||
ident = getString("fnr"), | ||
enhet = Enhetsnummer(getString("enhet")), | ||
), | ||
opprettet = getTidspunkt("opprettet"), | ||
status = getString("status"), | ||
aar = 2024, | ||
) | ||
} |
70 changes: 70 additions & 0 deletions
70
apps/etterlatte-behandling/src/main/kotlin/behandling/etteroppgjoer/EtteroppgjoerRoutes.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,70 @@ | ||
package no.nav.etterlatte.behandling.etteroppgjoer | ||
|
||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.server.application.call | ||
import io.ktor.server.response.respond | ||
import io.ktor.server.routing.Route | ||
import io.ktor.server.routing.get | ||
import io.ktor.server.routing.post | ||
import io.ktor.server.routing.route | ||
import no.nav.etterlatte.libs.common.sak.Sak | ||
import no.nav.etterlatte.libs.common.tidspunkt.Tidspunkt | ||
import no.nav.etterlatte.libs.ktor.route.ETTEROPPGJOER_CALL_PARAMETER | ||
import no.nav.etterlatte.libs.ktor.route.SAKID_CALL_PARAMETER | ||
import no.nav.etterlatte.libs.ktor.route.etteroppgjoerId | ||
import no.nav.etterlatte.libs.ktor.route.sakId | ||
import no.nav.etterlatte.tilgangsstyring.kunSkrivetilgang | ||
import java.util.UUID | ||
|
||
fun Route.etteroppgjoerRoutes(service: EtteroppgjoerService) { | ||
route("/api/etteroppgjoer/{$ETTEROPPGJOER_CALL_PARAMETER}") { | ||
get { | ||
kunSkrivetilgang { | ||
val etteroppgjoer = service.hentEtteroppgjoer(etteroppgjoerId) | ||
call.respond(etteroppgjoer) | ||
} | ||
} | ||
} | ||
|
||
route("/etteroppgjoer/{$SAKID_CALL_PARAMETER}") { | ||
post { | ||
kunSkrivetilgang { | ||
service.opprettEtteroppgjoer(sakId) | ||
call.respond(HttpStatusCode.OK) | ||
} | ||
} | ||
} | ||
} | ||
|
||
data class Etteroppgjoer( | ||
val behandling: EtteroppgjoerBehandling, | ||
val opplysninger: EtteroppgjoerOpplysninger, | ||
) | ||
|
||
data class EtteroppgjoerBehandling( | ||
val id: UUID, | ||
// val referanse: String, TODO en referanse/id til en hendelse el. | ||
val status: String, // TODO enum | ||
val sak: Sak, | ||
val aar: Int, | ||
val opprettet: Tidspunkt, | ||
) | ||
|
||
data class EtteroppgjoerOpplysninger( | ||
val skatt: OpplysnignerSkatt, | ||
val ainntekt: AInntekt, | ||
// TODO.. | ||
) | ||
|
||
data class OpplysnignerSkatt( | ||
val aarsinntekt: Int, | ||
) | ||
|
||
data class AInntekt( | ||
val inntektsmaaneder: List<AInntektMaaned>, | ||
) | ||
|
||
data class AInntektMaaned( | ||
val maaned: String, | ||
val summertBeloep: Int, | ||
) |
71 changes: 71 additions & 0 deletions
71
apps/etterlatte-behandling/src/main/kotlin/behandling/etteroppgjoer/EtteroppgjoerService.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,71 @@ | ||
package no.nav.etterlatte.behandling.etteroppgjoer | ||
|
||
import io.ktor.server.plugins.NotFoundException | ||
import no.nav.etterlatte.inTransaction | ||
import no.nav.etterlatte.libs.common.feilhaandtering.IkkeFunnetException | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
import no.nav.etterlatte.libs.common.tidspunkt.Tidspunkt | ||
import no.nav.etterlatte.sak.SakLesDao | ||
import java.util.UUID | ||
|
||
class EtteroppgjoerService( | ||
private val dao: EtteroppgjoerDao, | ||
private val sakDao: SakLesDao, | ||
) { | ||
fun hentEtteroppgjoer(behandlingId: UUID): Etteroppgjoer { | ||
val etteroppgjoerBehandling = | ||
inTransaction { | ||
dao.hentEtteroppgjoer(behandlingId) | ||
} ?: throw IkkeFunnetException( | ||
code = "MANGLER_FORBEHANDLING_ETTEROPPGJOER", | ||
detail = "Fant ikke forbehandling etteroppgjør $behandlingId", | ||
) | ||
|
||
// TODO egen tabell? I beregning? | ||
val opplysninger = | ||
EtteroppgjoerOpplysninger( | ||
skatt = | ||
OpplysnignerSkatt( | ||
aarsinntekt = 200000, | ||
), | ||
ainntekt = | ||
AInntekt( | ||
inntektsmaaneder = | ||
listOf( | ||
AInntektMaaned( | ||
maaned = "Januar", | ||
summertBeloep = 150000, | ||
), | ||
AInntektMaaned( | ||
maaned = "Januar", | ||
summertBeloep = 150000, | ||
), | ||
), | ||
), | ||
) | ||
|
||
return Etteroppgjoer( | ||
behandling = etteroppgjoerBehandling, | ||
opplysninger = opplysninger, | ||
) | ||
} | ||
|
||
fun opprettEtteroppgjoer(sakId: SakId) { | ||
inTransaction { | ||
val sak = sakDao.hentSak(sakId) ?: throw NotFoundException("Fant ikke sak med id=$sakId") | ||
|
||
// TODO skal opplysninger mottas eller hentes her? | ||
|
||
val ny = | ||
EtteroppgjoerBehandling( | ||
id = UUID.randomUUID(), | ||
status = "opprettet", | ||
sak = sak, | ||
aar = 2024, | ||
opprettet = Tidspunkt.now(), | ||
) | ||
|
||
dao.lagreEtteroppgjoer(ny) | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mangler vi aar fra EtteroppgjoerBehandling?