Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/endring-direkte-vergemaal
Browse files Browse the repository at this point in the history
  • Loading branch information
stigus authored Sep 16, 2024
2 parents 1e85219 + 965b071 commit 27cea61
Show file tree
Hide file tree
Showing 90 changed files with 194 additions and 283 deletions.
2 changes: 1 addition & 1 deletion apps/adresse-service/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.reactivecore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.reactivecore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
2 changes: 1 addition & 1 deletion apps/brreg-stub/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
4 changes: 2 additions & 2 deletions apps/bruker-service/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.reactivecore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand All @@ -27,7 +27,7 @@
<encoder class="no.nav.testnav.libs.reactivecore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
2 changes: 1 addition & 1 deletion apps/budpro-service/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
2 changes: 1 addition & 1 deletion apps/dolly-backend/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<rootCauseFirst>true</rootCauseFirst>
<maxDepthPerThrowable>256</maxDepthPerThrowable>

<maxLength>10280</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<exclude>^sun\.reflect\..*\.invoke</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export const initialPeriode = {
}

export const initialPensjonInntekt = {
fomAar: new Date().getFullYear() - 10,
fomAar: runningE2ETest() ? new Date().getFullYear() - 10 : null,
tomAar: runningE2ETest() ? new Date().getFullYear() : null,
belop: runningE2ETest() ? '12345' : '',
redusertMedGrunnbelop: true,
}

export const initialPensjonGenerertInntekt = {
generer: {
fomAar: new Date().getFullYear() - 10,
fomAar: null,
averageG: 1.5,
tillatInntektUnder1G: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ const DataVisning = ({ data, miljo }) => {
)?.label

const { vedtakData } = usePensjonVedtak(data?.fnr, miljo)
const vedtakAP = vedtakData?.find((vedtak) => vedtak?.sakType === 'AP')

return (
<>
<div className="person-visning_content">
<TitleValue
title="Vedtaksstatus"
value={
vedtakData?.[0]?.sisteOppdatering.includes('opprettet')
vedtakAP?.sisteOppdatering?.includes('opprettet')
? 'Iverksatt'
: vedtakData?.[0]?.sisteOppdatering
: vedtakAP?.sisteOppdatering
}
/>
<TitleValue title="Krav fremsatt dato" value={formatDate(data?.kravFremsattDato)} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Vis } from '@/components/bestillingsveileder/VisAttributt'
import Panel from '@/components/ui/panel/Panel'
import { erForsteEllerTest, panelError } from '@/components/ui/form/formUtils'
import { validation } from '@/components/fagsystem/pensjon/form/validation'
import { getAlder, validation } from '@/components/fagsystem/pensjon/form/validation'
import React, { useContext, useState } from 'react'
import StyledAlert from '@/components/ui/alert/StyledAlert'
import { BestillingsveilederContext } from '@/components/bestillingsveileder/BestillingsveilederContext'
Expand Down Expand Up @@ -33,24 +33,20 @@ export const PensjonForm = () => {
)
const { nyBestilling, nyBestillingFraMal } = opts?.is

function kalkulerIdentFyltSyttenAar() {
const curDate = new Date()
const alder =
formMethods.watch('pdldata.opprettNyPerson.foedtFoer') &&
formMethods.watch('pdldata.opprettNyPerson.foedtFoer') !== null
? curDate.getFullYear() -
// @ts-ignore
new Date(formMethods.watch('pdldata.opprettNyPerson.foedtFoer')).getFullYear()
: formMethods.watch('pdldata.opprettNyPerson.alder')
return alder && curDate.getFullYear() - alder + 17
const curDate = new Date()

const alder = formMethods.watch('pdldata.opprettNyPerson.foedtFoer')
? curDate.getFullYear() -
// @ts-ignore
new Date(formMethods.watch('pdldata.opprettNyPerson.foedtFoer')).getFullYear()
: getAlder(formMethods.watch(), opts?.personFoerLeggTil, opts?.importPersoner)

function kalkulerIdentGyldigAlder() {
const minAlder = alder && (curDate.getFullYear() - alder < 1997 ? 17 : 13)
return alder && curDate.getFullYear() - alder + minAlder
}

const syttenFraOgMedAar = kalkulerIdentFyltSyttenAar()
const minAar = new Date().getFullYear() - 17
const valgtAar =
inputType === inputValg.fyllInnInntekt
? formMethods.watch(`${pensjonPath}.fomAar`)
: formMethods.watch(`${pensjonGenererPath}.generer.fomAar`)
const gyldigFraOgMedAar = kalkulerIdentGyldigAlder()

return (
<Vis attributt={[pensjonPath, pensjonGenererPath]}>
Expand All @@ -61,14 +57,12 @@ export const PensjonForm = () => {
startOpen={erForsteEllerTest(formMethods.getValues(), [pensjonPath, pensjonGenererPath])}
informasjonstekst={hjelpetekst}
>
{!formMethods.getValues('pdldata.opprettNyPerson.alder') &&
valgtAar < minAar &&
(nyBestilling || nyBestillingFraMal) && (
<StyledAlert variant={'info'} size={'small'}>
Pensjonsgivende inntekt kan settes fra året personen fyller 17 år. For å sikre at
personen får gyldig alder kan denne settes ved å huke av for "Alder" på forrige side.
</StyledAlert>
)}
{!alder && (nyBestilling || nyBestillingFraMal) && (
<StyledAlert variant={'info'} size={'small'}>
Pensjonsgivende inntekt kan settes tidligst fra året personen fyller 13 år. For å sikre
at personen får gyldig alder kan denne settes ved å huke av for "Alder" på forrige side.
</StyledAlert>
)}

<ToggleGroup
size={'small'}
Expand Down Expand Up @@ -99,10 +93,10 @@ export const PensjonForm = () => {
</ToggleGroup.Item>
</ToggleGroup>
{inputType === inputValg.fyllInnInntekt && (
<FyllInnInntektForm syttenFraOgMedAar={syttenFraOgMedAar} />
<FyllInnInntektForm gyldigFraOgMedAar={gyldigFraOgMedAar} formMethods={formMethods} />
)}
{inputType === inputValg.generertInntekt && (
<GenerertInntektForm syttenFraOgMedAar={syttenFraOgMedAar} formMethods={formMethods} />
<GenerertInntektForm gyldigFraOgMedAar={gyldigFraOgMedAar} formMethods={formMethods} />
)}
</Panel>
</Vis>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ import { FormCheckbox } from '@/components/ui/form/inputs/checbox/Checkbox'
import React from 'react'
import { pensjonPath } from '@/components/fagsystem/pensjon/form/Form'

export const FyllInnInntektForm = ({ syttenFraOgMedAar }) => {
export const FyllInnInntektForm = ({ gyldigFraOgMedAar, formMethods }) => {
const visFomAar = formMethods.watch(`${pensjonPath}.tomAar`)
const visTomAar = formMethods.watch(`${pensjonPath}.fomAar`)

return (
<Kategori title="Pensjonsgivende inntekt" vis={pensjonPath}>
<div className="flexbox--flex-wrap">
<FormSelect
name={`${pensjonPath}.fomAar`}
label="Fra og med år"
options={getYearRangeOptions(syttenFraOgMedAar || 1968, new Date().getFullYear() - 1)}
options={getYearRangeOptions(
gyldigFraOgMedAar && gyldigFraOgMedAar < new Date().getFullYear()
? gyldigFraOgMedAar
: 1968,
visFomAar || new Date().getFullYear() - 1,
)}
size={'xsmall'}
isClearable={false}
/>

<FormSelect
name={`${pensjonPath}.tomAar`}
label="Til og med år"
options={getYearRangeOptions(1968, new Date().getFullYear() - 1)}
options={getYearRangeOptions(visTomAar || 1968, new Date().getFullYear() - 1)}
size={'xsmall'}
isClearable={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const StyledPanel = styled.div`
width: 790px;
`

export const GenerertInntektForm = ({ syttenFraOgMedAar, formMethods }) => {
export const GenerertInntektForm = ({ gyldigFraOgMedAar, formMethods }) => {
const formInntekter = formMethods.watch(`${pensjonGenererPath}.inntekter`)
const genererTOM = formMethods.watch(`${pensjonGenererPath}.generer.tomAar`)
const genererFOM = formMethods.watch(`${pensjonGenererPath}.generer.fomAar`)
Expand Down Expand Up @@ -78,7 +78,7 @@ export const GenerertInntektForm = ({ syttenFraOgMedAar, formMethods }) => {
name={`${pensjonGenererPath}.generer.fomAar`}
label="Fra og med år"
options={getYearRangeOptions(
syttenFraOgMedAar || 1968,
gyldigFraOgMedAar || 1968,
(genererTOM && genererTOM - 1) || new Date().getFullYear() - 1,
)}
size={'xsmall'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TjenestepensjonForm } from '@/components/fagsystem/tjenestepensjon/form
import { AlderspensjonForm } from '@/components/fagsystem/alderspensjon/form/Form'
import { UforetrygdForm } from '@/components/fagsystem/uforetrygd/form/Form'
import { PensjonsavtaleForm } from '@/components/fagsystem/pensjonsavtale/form/Form'
import { getYear } from 'date-fns'

function calculate_age(dob) {
const diff_ms = Date.now() - dob.getTime()
Expand All @@ -13,14 +14,18 @@ function calculate_age(dob) {
return Math.abs(age_dt.getUTCFullYear() - 1970)
}

const getAlder = (values, personFoerLeggTil, importPersoner) => {
export const getAlder = (values, personFoerLeggTil, importPersoner) => {
let alder = _.get(values, 'pdldata.opprettNyPerson.alder')
if (_.isNil(alder)) {
let foedselsdato = null
if (values?.pdldata?.person?.foedselsdato?.[0]?.foedselsdato) {
foedselsdato = values.pdldata.person.foedselsdato[0].foedselsdato
} else if (values?.pdldata?.person?.foedsel?.[0]?.foedselsdato) {
foedselsdato = values.pdldata.person.foedsel[0].foedselsdato
} else if (values?.pdldata?.person?.foedselsdato?.[0]?.foedselsaar) {
foedselsdato = new Date().setFullYear(values.pdldata.person.foedselsdato[0].foedselsaar)
} else if (values?.pdldata?.opprettNyPerson?.foedtFoer) {
foedselsdato = values.pdldata.opprettNyPerson.foedtFoer
} else if (personFoerLeggTil?.pdlforvalter?.person?.foedselsdato) {
const foedselsdatoer = personFoerLeggTil.pdlforvalter.person.foedselsdato
.map((foedsel) => foedsel.foedselsdato)
Expand Down Expand Up @@ -50,15 +55,14 @@ const getAlder = (values, personFoerLeggTil, importPersoner) => {
return alder
}

const invalidAlderFom = (inntektFom, values, personFoerLeggTil) => {
const invalidAlderFom = (inntektFom, values, personFoerLeggTil, minAlder) => {
const importPersoner = values.importPersoner

const alder = getAlder(values, personFoerLeggTil, importPersoner)
const foedtFoer = _.get(values, 'pdldata.opprettNyPerson.foedtFoer')
const foedtEtter = _.get(values, 'pdldata.opprettNyPerson.foedtEtter')

if (!_.isNil(alder) && alder !== '') {
if (new Date().getFullYear() - alder + 17 > inntektFom) {
if (new Date().getFullYear() - alder + minAlder > inntektFom) {
return true
}
} else if (!_.isNil(foedtFoer)) {
Expand All @@ -68,12 +72,12 @@ const invalidAlderFom = (inntektFom, values, personFoerLeggTil) => {
let year = foedtFoerDate.getFullYear()

year = day === 1 && month === 0 ? year - 1 : year
if (year + 17 > inntektFom) {
if (year + minAlder || 13 > inntektFom) {
return true
}
} else if (!_.isNil(foedtEtter) && _.isNil(foedtFoer)) {
const foedtEtterDate = new Date(foedtEtter)
if (foedtEtterDate.getFullYear() + 17 > inntektFom) {
if (foedtEtterDate.getFullYear() + minAlder || 13 > inntektFom) {
return true
}
}
Expand Down Expand Up @@ -136,15 +140,21 @@ const validFomDateTest = (val: Yup.NumberSchema<number, Yup.AnyObject>) => {
return val.test('gyldig-fom-aar', 'Feil', (value, context) => {
if (!value) return true
const inntektFom = value

const values = context.parent
const values = context.from?.[context.from.length - 1]?.value
const personFoerLeggTil = context?.options?.context?.personFoerLeggTil

if (invalidAlderFom(inntektFom, values, personFoerLeggTil)) {
return context.createError({ message: 'F.o.m kan tidligst være året personen fyller 17 år' })
const alder = getAlder(values, personFoerLeggTil, values.importPersoner)
const foedselsAar = alder && getYear(new Date()) - alder

const minAlder = foedselsAar && foedselsAar < 1997 ? 17 : 13

if (invalidAlderFom(inntektFom, values, personFoerLeggTil, minAlder)) {
return context.createError({
message: `F.o.m kan tidligst være året personen fyller ${minAlder.toString()} år`,
})
}

let inntektTom = values?.tomAar
let inntektTom = context.options.parent.tomAar
if (!_.isNil(inntektTom) && inntektFom > inntektTom) {
return context.createError({ message: 'F.o.m. dato må være før t.o.m. dato' })
}
Expand All @@ -158,7 +168,7 @@ const validTomDateTest = (val: Yup.NumberSchema<number, Yup.AnyObject>) => {
if (!value) return true
let inntektTom = value

const values = context.parent
const values = context.from?.[context.from.length - 1]?.value
const personFoerLeggTil = context?.options?.context?.personFoerLeggTil

if (invalidAlderTom(inntektTom, values, personFoerLeggTil)) {
Expand All @@ -171,7 +181,7 @@ const validTomDateTest = (val: Yup.NumberSchema<number, Yup.AnyObject>) => {
return context.createError({ message: 'T.o.m kan ikke være etter at person har dødd' })
}

const inntektFom = values?.fomAar
const inntektFom = context.options.parent.fomAar
if (!_.isNil(inntektFom) && inntektTom < inntektFom) {
return context.createError({ message: 'T.o.m. dato må være etter f.o.m. dato' })
}
Expand Down
Loading

0 comments on commit 27cea61

Please sign in to comment.