-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gjør utregn av skatteperiode smartere
- Loading branch information
Showing
5 changed files
with
86 additions
and
20 deletions.
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
19 changes: 19 additions & 0 deletions
19
...src/main/kotlin/no/nav/su/se/bakover/domain/skatt/RegnUtSkatteperiodeForStønadsperiode.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,19 @@ | ||
package no.nav.su.se.bakover.domain.skatt | ||
|
||
import no.nav.su.se.bakover.common.tid.YearRange | ||
import no.nav.su.se.bakover.common.tid.krympTilØvreGrense | ||
import no.nav.su.se.bakover.common.tid.utvidNedreGrense | ||
import no.nav.su.se.bakover.domain.søknadsbehandling.stønadsperiode.Stønadsperiode | ||
import java.time.Clock | ||
import java.time.Year | ||
|
||
fun Stønadsperiode?.regnUtSkatteperiodeForStønadsperiode(clock: Clock): YearRange { | ||
val iÅr = Year.now(clock) | ||
val iForFjor = iÅr.minusYears(2) | ||
|
||
return this | ||
?.toYearRange() | ||
?.krympTilØvreGrense(iÅr) | ||
?.utvidNedreGrense(iForFjor) | ||
?: YearRange(iForFjor, iÅr) | ||
} |
31 changes: 31 additions & 0 deletions
31
...st/kotlin/no/nav/su/se/bakover/domain/skatt/RegnUtSkatteperiodeForStønadsperiodeKtTest.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,31 @@ | ||
package no.nav.su.se.bakover.domain.skatt | ||
|
||
import io.kotest.matchers.shouldBe | ||
import no.nav.su.se.bakover.common.tid.YearRange | ||
import no.nav.su.se.bakover.common.tid.periode.juli | ||
import no.nav.su.se.bakover.common.tid.periode.juni | ||
import no.nav.su.se.bakover.domain.søknadsbehandling.stønadsperiode.Stønadsperiode | ||
import no.nav.su.se.bakover.test.fixedClock | ||
import org.junit.jupiter.api.Test | ||
import java.time.Year | ||
|
||
internal class RegnUtSkatteperiodeForStønadsperiodeKtTest { | ||
@Test | ||
fun `should return range from two years ago to this year when stønadsperiode is null`() { | ||
val expected = YearRange(Year.of(2022), Year.of(2024)) | ||
val actual = null.regnUtSkatteperiodeForStønadsperiode(fixedClock) | ||
|
||
actual shouldBe expected | ||
} | ||
|
||
@Test | ||
fun `should return same range as stønadsperiode when it's within bounds`() { | ||
val stønadsperiode = | ||
Stønadsperiode.create(juli(2023)..juni(2024)) | ||
val expected = YearRange(Year.of(2023), Year.of(2024)) | ||
val actual = stønadsperiode.regnUtSkatteperiodeForStønadsperiode(fixedClock) | ||
|
||
actual shouldBe expected | ||
} | ||
|
||
} |
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