Skip to content

Commit

Permalink
Create merkantil task when unable to assign behandling after creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvind-wedoe committed Dec 10, 2024
1 parent cd0a183 commit 724ca23
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ExternalMottakFacade(
val behandling = mottakService.createMottakForKlageAnkeV3(oversendtKlageAnke)

if (oversendtKlageAnke.saksbehandlerIdent != null) {
setSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent)
tryToSetSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent)
}

tryToSendSvarbrev(behandling, hindreAutomatiskSvarbrev = oversendtKlageAnke.hindreAutomatiskSvarbrev == true)
Expand All @@ -49,7 +49,7 @@ class ExternalMottakFacade(
val behandling = mottakService.createMottakForKlageAnkeV3(oversendtKlageAnke)

if (oversendtKlageAnke.saksbehandlerIdent != null) {
setSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent)
tryToSetSaksbehandler(behandling = behandling, saksbehandlerIdent = oversendtKlageAnke.saksbehandlerIdent)
}

tryToSendSvarbrev(behandling, hindreAutomatiskSvarbrev = oversendtKlageAnke.hindreAutomatiskSvarbrev == true)
Expand All @@ -74,6 +74,23 @@ class ExternalMottakFacade(
}
}

private fun tryToSetSaksbehandler(
behandling: Behandling,
saksbehandlerIdent: String
) {
try {
setSaksbehandler(
behandling = behandling,
saksbehandlerIdent = saksbehandlerIdent,
)
} catch (e: Exception) {
mottakService.createTaskForMerkantil(
behandlingId = behandling.id,
reason = "Klarte ikke å tildele behandling ${behandling.id} til saksbehandlerIdent $saksbehandlerIdent. Feilmelding: ${e.message}"
)
}
}

private fun setSaksbehandler(behandling: Behandling, saksbehandlerIdent: String) {
logger.debug("Preparing to set saksbehandler. Getting enhet for saksbehandler $saksbehandlerIdent")
val enhetForSaksbehandler = try {
Expand Down

0 comments on commit 724ca23

Please sign in to comment.