Skip to content

Commit

Permalink
Merge branch 'main' into ordered_documents
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvind-wedoe committed Sep 18, 2023
2 parents 3cca654 + e921444 commit 85576b0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class BehandlingController(

@PostMapping("/{behandlingId}/fullfoer")
fun fullfoerBehandling(
@PathVariable("behandlingId") behandlingId: UUID
@PathVariable("behandlingId") behandlingId: UUID,
@RequestParam(value = "nybehandling", required = false) nyBehandling: Boolean = false
): BehandlingFullfoertView {
logKlagebehandlingMethodDetails(
::fullfoerBehandling.name,
Expand All @@ -89,8 +90,9 @@ class BehandlingController(
)

val klagebehandling = behandlingService.ferdigstillBehandling(
behandlingId,
innloggetSaksbehandlerService.getInnloggetIdent()
behandlingId = behandlingId,
innloggetIdent = innloggetSaksbehandlerService.getInnloggetIdent(),
nyBehandling = nyBehandling,
)
return behandlingMapper.mapToBehandlingFullfoertView(klagebehandling)
}
Expand Down Expand Up @@ -216,7 +218,7 @@ class BehandlingController(
logger
)

behandlingService.validateBehandlingBeforeFinalize(behandlingId)
behandlingService.validateBehandlingBeforeFinalize(behandlingId, false)
return ValidationPassedResponse()
}

Expand Down
25 changes: 20 additions & 5 deletions src/main/kotlin/no/nav/klage/oppgave/service/BehandlingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class BehandlingService(

fun ferdigstillBehandling(
behandlingId: UUID,
innloggetIdent: String
innloggetIdent: String,
nyBehandling: Boolean
): Behandling {
val behandling = getBehandlingForUpdate(
behandlingId = behandlingId
Expand All @@ -86,7 +87,11 @@ class BehandlingService(
if (behandling.avsluttetAvSaksbehandler != null) throw BehandlingFinalizedException("Behandlingen er avsluttet")

//Forretningsmessige krav før vedtak kan ferdigstilles
validateBehandlingBeforeFinalize(behandlingId)
validateBehandlingBeforeFinalize(behandlingId = behandlingId, nyBehandling = nyBehandling)

if (nyBehandling) {
return setNyAnkebehandlingKA(behandlingId, innloggetIdent)
}

//Her settes en markør som så brukes async i kallet klagebehandlingRepository.findByAvsluttetIsNullAndAvsluttetAvSaksbehandlerIsNotNull
return markerBehandlingSomAvsluttetAvSaksbehandler(behandling, innloggetIdent)
Expand All @@ -101,12 +106,22 @@ class BehandlingService(
return behandling
}

fun validateBehandlingBeforeFinalize(behandlingId: UUID) {
fun validateBehandlingBeforeFinalize(behandlingId: UUID, nyBehandling: Boolean) {
val behandling = getBehandling(behandlingId)
val dokumentValidationErrors = mutableListOf<InvalidProperty>()
val behandlingValidationErrors = mutableListOf<InvalidProperty>()
val sectionList = mutableListOf<ValidationSection>()

if (nyBehandling) {
if (behandling is AnkeITrygderettenbehandling) {
if (behandling.utfall != Utfall.OPPHEVET) {
throw IllegalOperation("Ny ankebehandling kan kun opprettes hvis utfall er 'Opphevet'.")
}
} else {
throw IllegalOperation("Ny ankebehandling kan kun brukes på en Anke i trygderetten-sak.")
}
}

val unfinishedDocuments =
dokumentUnderArbeidRepository.findByBehandlingIdAndMarkertFerdigIsNull(behandling.id)

Expand Down Expand Up @@ -582,7 +597,7 @@ class BehandlingService(
fun setNyAnkebehandlingKA(
behandlingId: UUID,
utfoerendeSaksbehandlerIdent: String
): LocalDateTime {
): Behandling {
val behandling = getBehandlingForUpdate(behandlingId = behandlingId)

if (behandling is AnkeITrygderettenbehandling) {
Expand All @@ -597,7 +612,7 @@ class BehandlingService(
)
)

return behandling.modified
return behandling
} else throw IllegalOperation("Dette feltet kan bare settes i ankesaker i Trygderetten")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ class BehandlingServiceTest {

assertThrows<BehandlingFinalizedException> {
behandlingService.ferdigstillBehandling(
behandling.id,
SAKSBEHANDLER_IDENT
behandlingId = behandling.id,
innloggetIdent = SAKSBEHANDLER_IDENT,
nyBehandling = false,
)
}
}
Expand Down Expand Up @@ -341,7 +342,7 @@ class BehandlingServiceTest {
)

assertThrows<SectionedValidationErrorWithDetailsException> {
behandlingService.validateBehandlingBeforeFinalize(behandling.id)
behandlingService.validateBehandlingBeforeFinalize(behandling.id, nyBehandling = false,)
}
}

Expand All @@ -350,7 +351,7 @@ class BehandlingServiceTest {
val behandling = simpleInsert(fullfoert = false, utfall = false)

assertThrows<SectionedValidationErrorWithDetailsException> {
behandlingService.validateBehandlingBeforeFinalize(behandling.id)
behandlingService.validateBehandlingBeforeFinalize(behandling.id, nyBehandling = false,)
}
}

Expand All @@ -360,7 +361,7 @@ class BehandlingServiceTest {
simpleInsert(fullfoert = false, utfall = true, hjemler = false)

assertThrows<SectionedValidationErrorWithDetailsException> {
behandlingService.validateBehandlingBeforeFinalize(behandling.id)
behandlingService.validateBehandlingBeforeFinalize(behandling.id, nyBehandling = false,)
}
}

Expand All @@ -373,7 +374,7 @@ class BehandlingServiceTest {
trukket = true
)

behandlingService.validateBehandlingBeforeFinalize(behandling.id)
behandlingService.validateBehandlingBeforeFinalize(behandling.id, nyBehandling = false,)
}
}

Expand Down

0 comments on commit 85576b0

Please sign in to comment.