Skip to content

Henting og visning av Pensjonsytelse #3822

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

Merged
merged 2 commits into from
Apr 3, 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
953 changes: 484 additions & 469 deletions apps/dolly-frontend/src/main/js/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/dolly-frontend/src/main/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dolly",
"version": "3.1.3",
"version": "3.1.4",
"type": "module",
"description": "",
"main": "index.js",
Expand Down Expand Up @@ -121,4 +121,4 @@
"__tests__/mocks"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Panel from '@/components/ui/panel/Panel'
import { erForsteEllerTest, panelError } from '@/components/ui/form/formUtils'
import { FormDollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import { initialMocksvar } from '@/components/fagsystem/afpOffentlig/initialValues'
import { useMuligeDirektekall, useTpOrdning } from '@/utils/hooks/usePensjon'
import { useMuligeDirektekall, useTpOrdningKodeverk } from '@/utils/hooks/usePensjon'
import { FormSelect } from '@/components/ui/form/inputs/select/Select'
import React from 'react'
import { SelectOptionsManager as Options } from '@/service/SelectOptions'
Expand All @@ -22,7 +22,7 @@ export const AfpOffentligForm = () => {
return null
}

const { tpOrdningData } = useTpOrdning()
const { tpOrdningData } = useTpOrdningKodeverk()
const { direktekallData } = useMuligeDirektekall()

const valgteDirektekall = formMethods.watch(`${afpOffentligPath}.direktekall`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import { formatDate, showLabel } from '@/utils/DataFormatter'
import { useTpOrdning } from '@/utils/hooks/usePensjon'
import { useTpOrdningKodeverk } from '@/utils/hooks/usePensjon'
import {
AfpOffentligTypes,
BeloepTypes,
Expand Down Expand Up @@ -37,7 +37,7 @@ export const sjekkManglerAfpOffentligData = (afpOffentligData: Array<MiljoDataTy
}

export const showTpNavn = (tpId: string) => {
const { tpOrdningData } = useTpOrdning()
const { tpOrdningData } = useTpOrdningKodeverk()
const tpOrdning = tpOrdningData?.find((tpOrdning: any) => tpOrdning.value === tpId)
if (tpOrdning) {
return tpOrdning.label
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react'
import SubOverskrift from '@/components/ui/subOverskrift/SubOverskrift'
import { TitleValue } from '@/components/ui/titleValue/TitleValue'
import Loading from '@/components/ui/loading/Loading'
import { DollyFieldArray } from '@/components/ui/form/fieldArray/DollyFieldArray'
import { ErrorBoundary } from '@/components/ui/appError/ErrorBoundary'
import { Alert } from '@navikt/ds-react'
import { MiljoTabs } from '@/components/ui/miljoTabs/MiljoTabs'
import { useBestilteMiljoer } from '@/utils/hooks/useBestilling'
import { formatDate, showLabel } from '@/utils/DataFormatter'
import { sjekkManglerTpData } from '@/components/fagsystem/tjenestepensjon/visning/TpVisning'

const TpYtelseVisning = ({ data }) => {
if (!data) return null

return (
<DollyFieldArray data={data} nested>
{(ytelse, idx) => (
<div className="person-visning_content" key={idx}>
<TitleValue title="Type" value={showLabel('tjenestepensjonYtelseType', ytelse?.type)} />
<TitleValue title="Dato innmeldt" value={formatDate(ytelse?.datoInnmeldtYtelseFom)} />
<TitleValue
title="Dato iverksatt f.o.m"
value={formatDate(ytelse?.datoYtelseIverksattFom)}
/>
<TitleValue
title="Dato iverksatt t.o.m"
value={formatDate(ytelse?.datoYtelseIverksattTom)}
/>
</div>
)}
</DollyFieldArray>
)
}

export const TpYtelse = ({ data, loading, bestillingIdListe, tilgjengeligMiljoe }) => {
const { bestilteMiljoer } = useBestilteMiljoer(bestillingIdListe, 'TP_FORVALTER')

if (loading) {
return <Loading label="Laster pensjonsytelser" />
}
if (!data) {
return null
}

const manglerFagsystemdata = sjekkManglerTpData(data)

const miljoerMedData = data?.map((miljoData) => miljoData.data?.length > 0 && miljoData.miljo)
const errorMiljoer = bestilteMiljoer.filter((miljo) => !miljoerMedData?.includes(miljo))

const forsteMiljo = data.find((miljoData) => miljoData?.data?.length > 0)?.miljo

const filteredData =
tilgjengeligMiljoe && data.filter((item) => tilgjengeligMiljoe.includes(item.miljo))

return (
<ErrorBoundary>
<SubOverskrift label="Pensjonsytelser" iconKind="pensjon" isWarning={manglerFagsystemdata} />
{manglerFagsystemdata ? (
<Alert variant={'warning'} size={'small'} inline style={{ marginBottom: '20px' }}>
Fant ikke tjenestepensjon-ytelser på person
</Alert>
) : (
<MiljoTabs
bestilteMiljoer={bestilteMiljoer}
errorMiljoer={errorMiljoer}
forsteMiljo={forsteMiljo}
data={filteredData || data}
>
<TpYtelseVisning />
</MiljoTabs>
)}
</ErrorBoundary>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
useInstData,
usePensjonsavtaleData,
usePoppData,
useTpData,
useTpDataForhold,
useTpDataYtelse,
useTransaksjonIdData,
} from '@/utils/hooks/useFagsystemer'
import {
Expand Down Expand Up @@ -62,6 +63,7 @@ import {
harUdistubBestilling,
harUforetrygdBestilling,
harYrkesskaderBestilling,
hentTpYtelseOrdning,
} from '@/utils/SjekkBestillingFagsystem'
import {
AlderspensjonVisning,
Expand Down Expand Up @@ -110,6 +112,7 @@ import DokarkivVisning from '@/components/fagsystem/dokarkiv/visning/Visning'
import HistarkVisning from '@/components/fagsystem/histark/visning/Visning'
import { useArbeidssoekerregistrering } from '@/utils/hooks/useArbeidssoekerregisteret'
import { ArbeidssoekerregisteretVisning } from '@/components/fagsystem/arbeidssoekerregisteret/visning/ArbeidssoekerregisteretVisning'
import { TpYtelse } from '@/components/fagsystem/tjenestepensjon/visning/TpYtelse'

const getIdenttype = (ident) => {
if (parseInt(ident.charAt(0)) > 3) {
Expand Down Expand Up @@ -179,11 +182,16 @@ export default ({
harUdistubBestilling(bestillingerFagsystemer) || ident?.master === 'PDL',
)

const { loading: loadingTpData, tpData } = useTpData(
const { loading: loadingTpDataForhold, tpDataForhold } = useTpDataForhold(
ident.ident,
harTpBestilling(bestillingerFagsystemer),
)

const { loading: loadingTpDataYtelse, tpDataYtelse } = useTpDataYtelse(
ident.ident,
hentTpYtelseOrdning(bestillingerFagsystemer),
)

const { loading: loadingPensjonsavtaleData, pensjonsavtaleData } = usePensjonsavtaleData(
ident.ident,
harPensjonavtaleBestilling(bestillingerFagsystemer),
Expand Down Expand Up @@ -307,7 +315,7 @@ export default ({
if (poppData && sjekkManglerPensjonData(poppData)) {
return true
}
if (tpData && sjekkManglerTpData(tpData)) {
if (tpDataForhold && sjekkManglerTpData(tpDataForhold)) {
return true
}
if (apData && sjekkManglerApData(apData)) {
Expand Down Expand Up @@ -522,8 +530,14 @@ export default ({
tilgjengeligMiljoe={tilgjengeligMiljoe}
/>
<TpVisning
data={tpData}
loading={loadingTpData}
data={tpDataForhold}
loading={loadingTpDataForhold}
bestillingIdListe={bestillingIdListe}
tilgjengeligMiljoe={tilgjengeligMiljoe}
/>
<TpYtelse
data={tpDataYtelse}
loading={loadingTpDataYtelse}
bestillingIdListe={bestillingIdListe}
tilgjengeligMiljoe={tilgjengeligMiljoe}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ export const harTpBestilling = (bestillingerFagsystemer) => {
return tp
}

export const hentTpYtelseOrdning = (bestillingerFagsystemer) => {
let tpOrdning = null
bestillingerFagsystemer?.forEach((i) => {
const tp = i?.pensjonforvalter?.tp
if (tp?.length > 0) {
tp.forEach((j) => {
if (j?.ytelser?.length > 0) {
tpOrdning = j.ordning
}
})
}
})
return tpOrdning
}

export const harPoppBestilling = (bestillingerFagsystemer) => {
let popp = false
bestillingerFagsystemer?.forEach((i) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const tpForholdUrl = (ident, miljoer) =>
miljo: miljo,
}))

const tpYtelseUrl = (miljoer, ordningNr) =>
miljoer?.map((miljo) => ({
url: `/testnav-pensjon-testdata-facade-proxy/api/v1/tp/ytelse?ordning=${ordningNr}&miljo=${miljo}`,
miljo: miljo,
}))

const instUrl = (ident, miljoer) =>
miljoer?.map((miljo) => ({
url: `/testnav-inst-proxy/api/v1/institusjonsopphold/person?environments=${miljo}`,
Expand Down Expand Up @@ -121,7 +127,7 @@ export const usePensjonsavtaleData = (ident, harPensjonsavtaleBestilling) => {
}
}

export const useTpData = (ident, harTpBestilling) => {
export const useTpDataForhold = (ident, harTpBestilling) => {
const { pensjonEnvironments } = usePensjonEnvironments()

const { data, isLoading, error } = useSWR<any, Error>(
Expand All @@ -133,7 +139,25 @@ export const useTpData = (ident, harTpBestilling) => {
)

return {
tpData: data?.sort((a, b) => a.miljo.localeCompare(b.miljo)),
tpDataForhold: data?.sort((a, b) => a.miljo.localeCompare(b.miljo)),
loading: isLoading,
error: error,
}
}

export const useTpDataYtelse = (ident, ordningNr) => {
const { pensjonEnvironments } = usePensjonEnvironments()

const { data, isLoading, error } = useSWR<any, Error>(
[
ordningNr ? tpYtelseUrl(pensjonEnvironments, ordningNr) : null,
{ 'Nav-Call-Id': 'dolly', 'Nav-Consumer-Id': 'dolly', Authorization: 'dolly', fnr: ident },
],
([url, headers]) => multiFetcherPensjon(url, headers),
)

return {
tpDataYtelse: data?.sort((a, b) => a.miljo.localeCompare(b.miljo)),
loading: isLoading,
error: error,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const usePensjonFacadeGenerer = (body: any) => {
}
}

export const useTpOrdning = () => {
export const useTpOrdningKodeverk = () => {
const { data, isLoading, error } = useSWR<any, Error>(tpOrdningUrl, fetcher)

const options = data?.map((tpOrdning: any) => ({
Expand Down