-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
615 additions
and
358 deletions.
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
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
6 changes: 6 additions & 0 deletions
6
common/domain/src/main/kotlin/no/nav/su/se/bakover/common/domain/extensions/IntEx.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,6 @@ | ||
package no.nav.su.se.bakover.common.domain.extensions | ||
|
||
fun Int.toStringWithDecimals(decimalPlaces: Int): String { | ||
if (decimalPlaces <= 0) return this.toString() | ||
return "$this.${"0".repeat(decimalPlaces)}" | ||
} |
13 changes: 13 additions & 0 deletions
13
common/domain/src/test/kotlin/no/nav/su/se/bakover/common/domain/extensions/IntExKtTest.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,13 @@ | ||
package no.nav.su.se.bakover.common.domain.extensions | ||
|
||
import io.kotest.matchers.shouldBe | ||
import org.junit.jupiter.api.Test | ||
|
||
internal class IntExKtTest { | ||
@Test | ||
fun `toStringWithDecimals should return the integer as a string with the specified number of decimal places`() { | ||
42.toStringWithDecimals(2) shouldBe "42.00" | ||
42.toStringWithDecimals(0) shouldBe "42" | ||
42.toStringWithDecimals(5) shouldBe "42.00000" | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...pdrag/simulering/SimuleringSoapBuilder.kt → ...nfrastructure/soap/SoapEnvelopeBuilder.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
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
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
55 changes: 55 additions & 0 deletions
55
test-common/src/main/kotlin/tilbakekreving/TilbakekrevingSoapResponses.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,55 @@ | ||
package no.nav.su.se.bakover.test.tilbakekreving | ||
|
||
/** | ||
* Mottatt i preprod ved å sende en request til tilbakekreving med en ugyldig request (decimal på feil format) | ||
* Status 500. | ||
*/ | ||
fun tilbakekrevingSoapResponseConversionError() = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | ||
<SOAP-ENV:Body> | ||
<SOAP-ENV:Fault> | ||
<faultcode>SOAP-ENV:Server</faultcode> | ||
<faultstring>Conversion from SOAP failed</faultstring> | ||
<detail> | ||
<CICSFault xmlns="http://www.ibm.com/software/htp/cics/WSFault">DFHPI1009 08/02/2024 10:04:56 CICSQ1OS OSW8 85071 XML to data transformation failed. A conversion error (INVALID_CHARACTER) occurred when converting field belopTilbakekreves for WEBSERVICE tilbakekreving-v1-tjenestespesif.</CICSFault> | ||
</detail> | ||
</SOAP-ENV:Fault> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope> | ||
""".trimIndent() | ||
|
||
/** | ||
* Mottatt i preprod ved at vi allerede har sendt en request med samme vedtakId som har blitt godtatt. | ||
* Status 200. | ||
*/ | ||
fun tilbakekrevingSoapResponseVedtakIdFinnesIkke() = """ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | ||
<SOAP-ENV:Body> | ||
<tilbakekrevingsvedtakResponse xmlns="http://okonomi.nav.no/tilbakekrevingService/"> | ||
<mmel xmlns=""> | ||
<systemId xmlns="urn:no:nav:tilbakekreving:typer:v1">231-OPPD</systemId> | ||
<kodeMelding xmlns="urn:no:nav:tilbakekreving:typer:v1">B441012F</kodeMelding> | ||
<alvorlighetsgrad xmlns="urn:no:nav:tilbakekreving:typer:v1">08</alvorlighetsgrad> | ||
<beskrMelding xmlns="urn:no:nav:tilbakekreving:typer:v1">Oppgitt vedtak-id finnes ikke/har feil status: 0000625279</beskrMelding> | ||
<sqlKode xmlns="urn:no:nav:tilbakekreving:typer:v1" /> | ||
<sqlState xmlns="urn:no:nav:tilbakekreving:typer:v1" /> | ||
<sqlMelding xmlns="urn:no:nav:tilbakekreving:typer:v1" /> | ||
<mqCompletionKode xmlns="urn:no:nav:tilbakekreving:typer:v1" /> | ||
<mqReasonKode xmlns="urn:no:nav:tilbakekreving:typer:v1" /> | ||
<programId xmlns="urn:no:nav:tilbakekreving:typer:v1">K231B441</programId> | ||
<sectionNavn xmlns="urn:no:nav:tilbakekreving:typer:v1">CA10-VALIDER-INPUT</sectionNavn> | ||
</mmel> | ||
<tilbakekrevingsvedtak xmlns=""> | ||
<kodeAksjon xmlns="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1" /> | ||
<vedtakId xmlns="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1">0</vedtakId> | ||
<kodeHjemmel xmlns="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1" /> | ||
<enhetAnsvarlig xmlns="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1" /> | ||
<kontrollfelt xmlns="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1" /> | ||
<saksbehId xmlns="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1" /> | ||
</tilbakekrevingsvedtak> | ||
</tilbakekrevingsvedtakResponse> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope> | ||
""".trimIndent() |
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
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
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
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
104 changes: 104 additions & 0 deletions
104
...ure/src/main/kotlin/tilbakekreving/infrastructure/client/TilbakekrevingSoapBodyBuilder.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,104 @@ | ||
@file:Suppress("HttpUrlsUsage") | ||
|
||
package tilbakekreving.infrastructure.client | ||
|
||
import arrow.core.Either | ||
import no.nav.su.se.bakover.common.domain.extensions.toStringWithDecimals | ||
import no.nav.su.se.bakover.common.ident.NavIdentBruker | ||
import no.nav.su.se.bakover.common.sikkerLogg | ||
import org.slf4j.LoggerFactory | ||
import tilbakekreving.domain.vedtak.KunneIkkeSendeTilbakekrevingsvedtak | ||
import tilbakekreving.domain.vurdering.PeriodevurderingMedKrav | ||
import tilbakekreving.domain.vurdering.VurderingerMedKrav | ||
import tilbakekreving.infrastructure.client.dto.AksjonsKode | ||
import tilbakekreving.infrastructure.client.dto.Skyld | ||
import tilbakekreving.infrastructure.client.dto.TilbakekrevingsHjemmel | ||
import tilbakekreving.infrastructure.client.dto.Tilbakekrevingsresultat | ||
import tilbakekreving.infrastructure.client.dto.TilbakekrevingsÅrsak | ||
import kotlin.math.max | ||
|
||
private val log = LoggerFactory.getLogger("tilbakekreving.infrastructure.client.buildTilbakekrevingSoapRequest") | ||
|
||
/** | ||
* Se: https://confluence.adeo.no/display/OKSY/Detaljer+om+de+enkelte+ID-koder | ||
* Se: https://github.com/navikt/tjenestespesifikasjoner/blob/master/tilbakekreving-v1-tjenestespesifikasjon/src/main/wsdl/no/nav/tilbakekreving/tilbakekreving-v1-tjenestespesifikasjon.wsdl | ||
*/ | ||
internal fun buildTilbakekrevingSoapRequest( | ||
vurderingerMedKrav: VurderingerMedKrav, | ||
attestertAv: NavIdentBruker.Attestant, | ||
): Either<KunneIkkeSendeTilbakekrevingsvedtak, String> { | ||
return Either.catch { | ||
// TODO jah: Vurder om vi skal legge til datoVedtakFagsystem istedenfor å få dagens dato. | ||
""" | ||
<ns4:tilbakekrevingsvedtakRequest xmlns:ns2="urn:no:nav:tilbakekreving:typer:v1" | ||
xmlns:ns4="http://okonomi.nav.no/tilbakekrevingService/" | ||
xmlns:ns3="urn:no:nav:tilbakekreving:tilbakekrevingsvedtak:vedtak:v1"> | ||
<tilbakekrevingsvedtak> | ||
<ns3:kodeAksjon>${AksjonsKode.FATT_VEDTAK.nummer}</ns3:kodeAksjon> | ||
<ns3:vedtakId>${vurderingerMedKrav.eksternVedtakId}</ns3:vedtakId> | ||
<ns3:kodeHjemmel>${TilbakekrevingsHjemmel.T}</ns3:kodeHjemmel> | ||
<ns3:renterBeregnes>N</ns3:renterBeregnes> | ||
<ns3:enhetAnsvarlig>8020</ns3:enhetAnsvarlig> | ||
<ns3:kontrollfelt>${vurderingerMedKrav.eksternKontrollfelt}</ns3:kontrollfelt> | ||
<ns3:saksbehId>$attestertAv</ns3:saksbehId> | ||
${ | ||
vurderingerMedKrav.perioder.joinToString(separator = "\n") { periode -> | ||
""" | ||
<ns3:tilbakekrevingsperiode> | ||
<ns3:periode> | ||
<ns2:fom>${periode.periode.fraOgMed}</ns2:fom> | ||
<ns2:tom>${periode.periode.tilOgMed}</ns2:tom> | ||
</ns3:periode> | ||
<ns3:renterBeregnes>N</ns3:renterBeregnes> | ||
<ns3:belopRenter>0.00</ns3:belopRenter> | ||
<ns3:tilbakekrevingsbelop> | ||
<ns3:kodeKlasse>SUUFORE</ns3:kodeKlasse> | ||
<ns3:belopOpprUtbet>${periode.bruttoTidligereUtbetalt.toStringWithDecimals(2)}</ns3:belopOpprUtbet> | ||
<ns3:belopNy>${periode.bruttoNyUtbetaling.toStringWithDecimals(2)}</ns3:belopNy> | ||
<ns3:belopTilbakekreves>${periode.bruttoSkalTilbakekreve.toStringWithDecimals(2)}</ns3:belopTilbakekreves> | ||
<ns3:belopUinnkrevd>${periode.bruttoSkalIkkeTilbakekreve.toStringWithDecimals(2)}</ns3:belopUinnkrevd> | ||
<ns3:belopSkatt>${periode.skattSomGårTilReduksjon.toStringWithDecimals(2)}</ns3:belopSkatt> | ||
<ns3:kodeResultat>${ | ||
when (periode) { | ||
is PeriodevurderingMedKrav.SkalIkkeTilbakekreve -> Tilbakekrevingsresultat.INGEN_TILBAKEKREV.toString() | ||
is PeriodevurderingMedKrav.SkalTilbakekreve -> Tilbakekrevingsresultat.FULL_TILBAKEKREV.toString() | ||
} | ||
}</ns3:kodeResultat> | ||
<ns3:kodeAarsak>${TilbakekrevingsÅrsak.ANNET}</ns3:kodeAarsak> | ||
<ns3:kodeSkyld>${ | ||
when (periode) { | ||
is PeriodevurderingMedKrav.SkalIkkeTilbakekreve -> Skyld.IKKE_FORDELT.toString() | ||
is PeriodevurderingMedKrav.SkalTilbakekreve -> Skyld.BRUKER.toString() | ||
} | ||
}</ns3:kodeSkyld> | ||
</ns3:tilbakekrevingsbelop> | ||
<ns3:tilbakekrevingsbelop> | ||
<ns3:kodeKlasse>KL_KODE_FEIL_INNT</ns3:kodeKlasse> | ||
<ns3:belopOpprUtbet>0.00</ns3:belopOpprUtbet> | ||
<ns3:belopNy>${ | ||
max( | ||
periode.bruttoSkalTilbakekreve, | ||
periode.bruttoSkalIkkeTilbakekreve, | ||
).toStringWithDecimals(2) | ||
}</ns3:belopNy> | ||
<ns3:belopTilbakekreves>0.00</ns3:belopTilbakekreves> | ||
<ns3:belopUinnkrevd>0.00</ns3:belopUinnkrevd> | ||
</ns3:tilbakekrevingsbelop> | ||
</ns3:tilbakekrevingsperiode>""" | ||
} | ||
} | ||
</tilbakekrevingsvedtak> | ||
</ns4:tilbakekrevingsvedtakRequest> | ||
""".trimIndent() | ||
}.mapLeft { | ||
log.error( | ||
"Feil ved sending av tilbakekrevingsvedtak: Klarte ikke serialisere requesten som vi skulle sende til Tilbakekrevingsmodulen (OS). Se sikkerlogg for mer kontekst.", | ||
RuntimeException("Trigger stacktrace"), | ||
) | ||
sikkerLogg.error( | ||
"Feil ved sending av tilbakekrevingsvedtak: Klarte ikke serialisere requesten som vi skulle sende til Tilbakekrevingsmodulen (OS). vurderingerMedKrav: $vurderingerMedKrav, attestertAv: $attestertAv", | ||
it, | ||
) | ||
KunneIkkeSendeTilbakekrevingsvedtak | ||
} | ||
} |
Oops, something went wrong.