Skip to content
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

EY-4956 Oppdater kommentar framtidig tt #6859

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,65 +155,58 @@ export const TrygdetidPerioder = ({
</Button>
</div>
)}
{kanLeggeTilNyPeriode && faktiskTrygdetid && (
<>
{kanHenteTrygdetidFraPesys && (
<>
{mapResult(sjekkOmAvodedHarTTIPesysStatus, {
initial: null,
pending: <Spinner label="Sjekker om avdøede har trygdetidsgrunnlag i Pesys" />,
error: () => <Alert variant="warning">Kunne ikke sjekke trygdetidsgrunnag i Pesys</Alert>,
success: (harTrygdetidsgrunnlagIPesys) => {
return (
<>
{harTrygdetidsgrunnlagIPesys && (
{kanLeggeTilNyPeriode &&
faktiskTrygdetid &&
kanHenteTrygdetidFraPesys &&
mapResult(sjekkOmAvodedHarTTIPesysStatus, {
initial: null,
pending: <Spinner label="Sjekker om avdøede har trygdetidsgrunnlag i Pesys" />,
error: () => <Alert variant="warning">Kunne ikke sjekke trygdetidsgrunnag i Pesys</Alert>,
success: (harTrygdetidsgrunnlagIPesys) => {
return (
<>
{harTrygdetidsgrunnlagIPesys && (
<>
<Box maxWidth="fit-content">
<Heading size="small">Legg inn trygdetidsgrunnlag</Heading>
<BodyShort>Avdøed har trygdetidsgrunnlag registrert på uføretrygd eller alderspensjon.</BodyShort>
{isSuccess(hentTTPesysStatus) && !isSuccess(slettTrygdetidsgrunnlagStatus) && (
<>
<Box maxWidth="fit-content">
<Heading size="small">Legg inn trygdetidsgrunnlag</Heading>
<BodyShort>
Avdøed har trygdetidsgrunnlag registrert på uføretrygd eller alderspensjon.
</BodyShort>
{isSuccess(hentTTPesysStatus) && !isSuccess(slettTrygdetidsgrunnlagStatus) && (
<>
{mapFailure(slettTrygdetidsgrunnlagStatus, (error) => (
<ApiErrorAlert>Kunne ikke ferdigstille oppgave: {error.detail}</ApiErrorAlert>
))}

<Button
variant="secondary"
size="small"
onClick={tilbakestillTrygdetider}
loading={isPending(hentTTPesysStatus)}
>
Tilbakestill trygdetidsgrunnlag
</Button>
</>
)}

{(!isSuccess(hentTTPesysStatus) || isSuccess(slettTrygdetidsgrunnlagStatus)) && (
<Button
size="small"
onClick={oppdaterTrygdetidMedPesysData}
loading={isPending(hentTTPesysStatus)}
>
Legg inn
</Button>
)}
</Box>
{isFailure(hentTTPesysStatus) && (
<Alert variant="warning">Kunne ikke hente trygdetid fra Pesys</Alert>
)}
{isPending(hentTTPesysStatus) && <Spinner label="Henter trygdetid i Pesys" />}
{mapFailure(slettTrygdetidsgrunnlagStatus, (error) => (
<ApiErrorAlert>Kunne ikke ferdigstille oppgave: {error.detail}</ApiErrorAlert>
))}

<Button
variant="secondary"
size="small"
onClick={tilbakestillTrygdetider}
loading={isPending(hentTTPesysStatus)}
>
Tilbakestill trygdetidsgrunnlag
</Button>
</>
)}
</>
)
},
})}
</>
)}
</>
)}

{(!isSuccess(hentTTPesysStatus) || isSuccess(slettTrygdetidsgrunnlagStatus)) && (
<Button
size="small"
onClick={oppdaterTrygdetidMedPesysData}
loading={isPending(hentTTPesysStatus)}
>
Legg inn
</Button>
)}
</Box>
{isFailure(hentTTPesysStatus) && (
<Alert variant="warning">Kunne ikke hente trygdetid fra Pesys</Alert>
)}
{isPending(hentTTPesysStatus) && <Spinner label="Henter trygdetid i Pesys" />}
</>
)}
</>
)
},
})}
</VStack>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ private fun TrygdetidPeriodePesys.fraPesystilVanlig(): TrygdetidPeriode =
til = til,
)

private const val AUTOMATISK_FREMTIDIG_BEGRUNNELSE = "Automatisk beregnet fremtidig trygdetid"

class TrygdetidServiceImpl(
private val trygdetidRepository: TrygdetidRepository,
private val behandlingKlient: BehandlingKlient,
Expand Down Expand Up @@ -472,7 +474,7 @@ class TrygdetidServiceImpl(
Grunnlagsopplysning.automatiskSaksbehandler.ident,
Tidspunkt.now(),
),
begrunnelse = "Automatisk beregnet fremtidig trygdetid",
begrunnelse = AUTOMATISK_FREMTIDIG_BEGRUNNELSE,
poengInnAar = false,
poengUtAar = false,
prorata = false,
Expand Down Expand Up @@ -507,10 +509,17 @@ class TrygdetidServiceImpl(
brukerTokenInfo: BrukerTokenInfo,
): Trygdetid =
kanOppdatereTrygdetid(behandlingId, brukerTokenInfo) {
// Hvis vi oppdaterer en trygdetid som har automatisk begrunnelse, fjern automatisk begrunnelse
val trygdetidGrunnlagForOppdatering =
when (trygdetidGrunnlag.begrunnelse) {
AUTOMATISK_FREMTIDIG_BEGRUNNELSE -> trygdetidGrunnlag.copy(begrunnelse = null)
else -> trygdetidGrunnlag
}

lagreTrygdetidGrunnlagForTrygdetidMedIdIBehandling(
behandlingId,
trygdetidId,
trygdetidGrunnlag,
trygdetidGrunnlagForOppdatering,
brukerTokenInfo,
)
}
Expand Down
Loading