-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Årlig Inntektsjustering jobb (#6053)
* Inntektsjustering Jobb starter omregning * Legger til egendefingert hendelse type i testdata * Leser dato til yearmonth * Flyttet oppstartslogikk for årlig inntektsjustering til behandling
- Loading branch information
Showing
14 changed files
with
223 additions
and
54 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
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
99 changes: 99 additions & 0 deletions
99
...rlatte-behandling/src/main/kotlin/inntektsjustering/AarligInntektsjusteringJobbService.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,99 @@ | ||
package no.nav.etterlatte.inntektsjustering | ||
|
||
import no.nav.etterlatte.behandling.omregning.OmregningService | ||
import no.nav.etterlatte.kafka.JsonMessage | ||
import no.nav.etterlatte.kafka.KafkaProdusent | ||
import no.nav.etterlatte.libs.common.behandling.Revurderingaarsak | ||
import no.nav.etterlatte.libs.common.inntektsjustering.AarligInntektsjusteringRequest | ||
import no.nav.etterlatte.libs.common.logging.getCorrelationId | ||
import no.nav.etterlatte.libs.common.rapidsandrivers.CORRELATION_ID_KEY | ||
import no.nav.etterlatte.libs.common.rapidsandrivers.TEKNISK_TID_KEY | ||
import no.nav.etterlatte.libs.common.sak.KjoeringRequest | ||
import no.nav.etterlatte.libs.common.sak.KjoeringStatus | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
import no.nav.etterlatte.libs.common.tidspunkt.Tidspunkt | ||
import no.nav.etterlatte.rapidsandrivers.OmregningData | ||
import no.nav.etterlatte.rapidsandrivers.OmregningDataPacket | ||
import no.nav.etterlatte.rapidsandrivers.OmregningHendelseType | ||
import org.slf4j.LoggerFactory | ||
import java.time.Year | ||
import java.time.YearMonth | ||
|
||
class AarligInntektsjusteringJobbService( | ||
private val omregningService: OmregningService, | ||
private val rapid: KafkaProdusent<String, String>, | ||
) { | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
fun startAarligInntektsjustering(request: AarligInntektsjusteringRequest) { | ||
request.saker.forEach { sakId -> | ||
startEnkeltSak(request.kjoering, request.loependeFom, sakId) | ||
} | ||
} | ||
|
||
private fun startEnkeltSak( | ||
kjoering: String, | ||
loependeFom: YearMonth, | ||
sakId: SakId, | ||
) { | ||
try { | ||
logger.info("Årlig inntektsjusteringsjobb $kjoering for $sakId") | ||
if (!skalBehandlingOmregnes(loependeFom)) { | ||
// TODO Legge til en begrunnelse | ||
omregningService.oppdaterKjoering(KjoeringRequest(kjoering, KjoeringStatus.FERDIGSTILT, sakId)) | ||
} else if (kanIkkeKjoeresAutomatisk()) { | ||
// TODO Finnes det tilfeller av dette? | ||
} else { | ||
// TODO status KLAR_FOR_OMREGNING | ||
publiserKlarForOmregning(sakId, loependeFom) | ||
} | ||
} catch (e: Exception) { | ||
// TODO begrunnese! | ||
omregningService.oppdaterKjoering(KjoeringRequest(kjoering, KjoeringStatus.FEILA, sakId)) | ||
} | ||
} | ||
|
||
private fun kanIkkeKjoeresAutomatisk(): Boolean { | ||
// TODO | ||
return false | ||
} | ||
|
||
private fun publiserKlarForOmregning( | ||
sakId: SakId, | ||
loependeFom: YearMonth, | ||
) { | ||
val correlationId = getCorrelationId() | ||
rapid | ||
.publiser( | ||
"aarlig-inntektsjustering-$sakId", | ||
JsonMessage | ||
.newMessage( | ||
OmregningHendelseType.KLAR_FOR_OMREGNING.lagEventnameForType(), | ||
mapOf( | ||
CORRELATION_ID_KEY to correlationId, | ||
TEKNISK_TID_KEY to Tidspunkt.now(), | ||
OmregningDataPacket.KEY to | ||
OmregningData( | ||
kjoering = "Årlig inntektsjustering ${Year.now().plusYears(1)}", | ||
sakId = sakId, | ||
revurderingaarsak = Revurderingaarsak.INNTEKTSENDRING, // TODO egen årsak? | ||
fradato = loependeFom.atDay(1), | ||
).toPacket(), | ||
), | ||
).toJson(), | ||
).also { (partition, offset) -> | ||
logger.info( | ||
"Publiserte klar for omregningshendelse for $sakId på partition " + | ||
"$partition, offset $offset, correlationid: $correlationId", | ||
) | ||
} | ||
} | ||
|
||
private fun skalBehandlingOmregnes(loependeFom: YearMonth): Boolean { | ||
// TODO kall vedtakfor så om er innvilga / løpende | ||
|
||
// TODO kall berening for å se om det finnes inntekt fra 1.1 | ||
|
||
return true | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
apps/etterlatte-behandling/src/main/kotlin/inntektsjustering/AarligInntektsjusteringRoute.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,20 @@ | ||
package no.nav.etterlatte.inntektsjustering | ||
|
||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.server.application.call | ||
import io.ktor.server.request.receive | ||
import io.ktor.server.response.respond | ||
import io.ktor.server.routing.Route | ||
import io.ktor.server.routing.post | ||
import io.ktor.server.routing.route | ||
import no.nav.etterlatte.libs.common.inntektsjustering.AarligInntektsjusteringRequest | ||
|
||
internal fun Route.aarligInntektsjusteringRoute(service: AarligInntektsjusteringJobbService) { | ||
route("/inntektsjustering") { | ||
post("jobb") { | ||
val request = call.receive<AarligInntektsjusteringRequest>() | ||
service.startAarligInntektsjustering(request) | ||
call.respond(HttpStatusCode.OK) | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...atte-behandling/src/test/java/inntektsjustering/AarligInntektsjusteringJobbServiceTest.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,5 @@ | ||
package inntektsjustering | ||
|
||
class AarligInntektsjusteringJobbServiceTest { | ||
// TODO | ||
} |
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
Oops, something went wrong.