Skip to content

Commit

Permalink
Fix seks g per mnd (#2663)
Browse files Browse the repository at this point in the history
* Bruker ikke perMnd fra grunnbeløp for å gjøre utreegning av seksGangerGrunnbeløpPerMåned da det kan bli feil utregning når beløpet er rundet ned. Gjør derfor utregning på grunnbeløp.

* Oppdatere perMnd i Grunnbeløp 24-25 i grunnbeløpsperioder til 10336 siden det skal rundes opp.
  • Loading branch information
gunnsteingarmo authored Aug 26, 2024
1 parent afb0e2d commit d956f77
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object Grunnbeløpsperioder {
Grunnbeløp(
periode = Månedsperiode(YearMonth.parse("2024-05"), YearMonth.from(LocalDate.MAX)),
grunnbeløp = 124_028.toBigDecimal(),
perMnd = 10_335.toBigDecimal(),
perMnd = 10_336.toBigDecimal(),
gjennomsnittPerÅr = 122_225.toBigDecimal(),
),
Grunnbeløp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import no.nav.familie.kontrakter.felles.erSammenhengende
import no.nav.familie.kontrakter.felles.harOverlappende
import org.springframework.stereotype.Service
import java.math.BigDecimal
import java.math.RoundingMode

@Service
class BeregningService {
Expand Down Expand Up @@ -84,9 +85,9 @@ class BeregningService {
fun grunnbeløpsperiodeDTO(grunnbeløpParameter: Grunnbeløp): GrunnbeløpDTO {
val periode = grunnbeløpParameter.periode
val grunnbeløp = grunnbeløpParameter.grunnbeløp
val grunnbeløpMåned = grunnbeløpParameter.perMnd
val seksGangerGrunnbeløp = 6.toBigDecimal() * grunnbeløp
val seksGangerGrunnbeløpPerMåned = 6.toBigDecimal() * grunnbeløpMåned
val grunnbeløpMåned = grunnbeløp.divide(BigDecimal(12), 10, RoundingMode.HALF_UP)
val seksGangerGrunnbeløp = grunnbeløp.multiply(BigDecimal(6)).setScale(0, RoundingMode.HALF_UP)
val seksGangerGrunnbeløpPerMåned = grunnbeløpMåned.multiply(BigDecimal(6)).setScale(0, RoundingMode.HALF_UP)
return GrunnbeløpDTO(
periode = periode,
grunnbeløp = grunnbeløp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package no.nav.familie.ef.sak.beregning
import no.nav.familie.ef.sak.infrastruktur.exception.ApiFeil
import no.nav.familie.kontrakter.felles.Månedsperiode
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.math.BigDecimal
Expand Down Expand Up @@ -416,4 +417,19 @@ internal class BeregningServiceTest {
)
}
}

@Test
fun `grunnbeløpsperiodeDTO skal returnere korrekt seks ganger grunnbeløp per måned`() {
val grunnbeløp =
Grunnbeløp(
periode = Månedsperiode(LocalDate.of(2024, 5, 1), LocalDate.of(2025, 4, 30)),
grunnbeløp = 124028.toBigDecimal(),
perMnd = 10336.toBigDecimal(),
)
val grunnbeløpsperiodeDTO = beregningService.grunnbeløpsperiodeDTO(grunnbeløp)

val korrektSeksGangerGrunnbeløpPerMåned = 62014.toBigDecimal()

Assertions.assertEquals(korrektSeksGangerGrunnbeløpPerMåned, grunnbeløpsperiodeDTO.seksGangerGrunnbeløpPerMåned)
}
}

0 comments on commit d956f77

Please sign in to comment.