-
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
Avkorting feil etter varselbrevjobb #6444
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
76 changes: 76 additions & 0 deletions
76
apps/etterlatte-beregning/src/main/kotlin/avkorting/AvkortingReparerAarsoppgjoeret.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,76 @@ | ||
package no.nav.etterlatte.avkorting | ||
|
||
import no.nav.etterlatte.libs.common.feilhaandtering.InternfeilException | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
import no.nav.etterlatte.libs.common.vedtak.VedtakSammendragDto | ||
import no.nav.etterlatte.libs.common.vedtak.VedtakType | ||
import org.slf4j.LoggerFactory | ||
import java.time.YearMonth | ||
|
||
/* | ||
* Inntektsjobb for 2025 innførte en feil i alle behandlinger som ble gjort automatisk som kompanseres for her. | ||
* Alle behandlinger skal inneholde alle tidligere årsoppgjør men de automatiske behandlingene i jobben består kun av 2025. | ||
* Det medfører at revurdering tilbake til 2024 mangler inntekten for 2024 når forrige behandling/avkorting kopieres. | ||
* | ||
* For å reparere dette gjøres det ekstra håndtering for å flette forrige avkorting med forrige avkorting i 2024. | ||
* Denne må kjøre helt til alle saker har lagd en ny revurdering. | ||
* | ||
* Når alle saker har en ny revurdering hver (f.eks ved regulering eller etteroppgjør) | ||
* kan dette fjernes og kun kopiere forrige avkorting. | ||
* | ||
*/ | ||
class AvkortingReparerAarsoppgjoeret( | ||
val avkortingRepository: AvkortingRepository, | ||
) { | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
fun hentSisteAvkortingMedReparertAarsoppgjoer( | ||
forrigeAvkorting: Avkorting, | ||
virkningstidspunkt: YearMonth, | ||
sakId: SakId, | ||
alleVedtak: List<VedtakSammendragDto>, | ||
): Avkorting { | ||
if (YearMonth.now() > YearMonth.of(2025, 5)) { | ||
logger.warn("AvkortingReparerAarsoppgjoeret.kt har nå med sikkerhet blitt kjørt på alle saker etter regulering og kan fjernes!") | ||
} | ||
|
||
val alleAarMedAarsoppgjoer = avkortingRepository.hentAlleAarsoppgjoer(sakId).map { it.aar }.distinct() | ||
val alleAarNyAvkortng = forrigeAvkorting.aarsoppgjoer.map { it.aar } | ||
val manglerAar = alleAarMedAarsoppgjoer != alleAarNyAvkortng | ||
|
||
if (manglerAar) { | ||
val sisteAarsoppgjoer = forrigeAvkorting.aarsoppgjoer.maxBy { it.aar } | ||
if (sisteAarsoppgjoer.aar < virkningstidspunkt.year) { | ||
if (virkningstidspunkt != YearMonth.of(virkningstidspunkt.year, 1)) { | ||
throw FoersteRevurderingSenereEnnJanuar() | ||
} | ||
return forrigeAvkorting | ||
} | ||
|
||
val manglendeAar = | ||
when (alleAarNyAvkortng.contains(virkningstidspunkt.year)) { | ||
true -> virkningstidspunkt.year.minus(1) | ||
false -> virkningstidspunkt.year | ||
} | ||
|
||
val sisteBehandlingManglendeAar = alleVedtak.sisteLoependeVedtakForAar(manglendeAar).behandlingId | ||
val sisteAvkortingManglendeAar = | ||
avkortingRepository.hentAvkorting(sisteBehandlingManglendeAar) | ||
?: throw TidligereAvkortingFinnesIkkeException(sisteBehandlingManglendeAar) | ||
|
||
return sisteAvkortingManglendeAar.copy( | ||
aarsoppgjoer = sisteAvkortingManglendeAar.aarsoppgjoer + forrigeAvkorting.aarsoppgjoer, | ||
) | ||
} else { | ||
return forrigeAvkorting | ||
} | ||
} | ||
} | ||
|
||
fun List<VedtakSammendragDto>.sisteLoependeVedtakForAar(aar: Int) = | ||
filter { | ||
val vedtakAar = it.virkningstidspunkt?.year ?: throw InternfeilException("Vedtak mangler virk") | ||
it.vedtakType != VedtakType.OPPHOER && vedtakAar == aar | ||
}.maxBy { | ||
it.datoAttestert ?: throw InternfeilException("Iverksatt vedtak mangler dato attestert") | ||
} |
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.
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.
Burde denne være en
error
så vi fanger det opp i Slack?