-
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
12 changed files
with
222 additions
and
44 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
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
24 changes: 24 additions & 0 deletions
24
...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,24 @@ | ||
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 | ||
|
||
/** | ||
* @return Skatteperiode for stønadsperiode. Hvis stønadsperiode er null, returneres skatteperiode for de tre siste årene. | ||
*/ | ||
fun Stønadsperiode?.regnUtSkatteperiodeForStønadsperiode(clock: Clock): YearRange { | ||
val iÅr = Year.now(clock) | ||
val iForFjor = iÅr.minusYears(2) | ||
if (this == null) { | ||
return YearRange(iForFjor, iÅr) | ||
} | ||
|
||
return this | ||
.toYearRange() | ||
.krympTilØvreGrense(iÅr) | ||
.utvidNedreGrense(iForFjor) | ||
} |
89 changes: 89 additions & 0 deletions
89
...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,89 @@ | ||
package no.nav.su.se.bakover.domain.skatt | ||
|
||
import io.kotest.matchers.shouldBe | ||
import no.nav.su.se.bakover.common.extensions.januar | ||
import no.nav.su.se.bakover.common.tid.YearRange | ||
import no.nav.su.se.bakover.common.tid.periode.desember | ||
import no.nav.su.se.bakover.common.tid.periode.januar | ||
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.fixedClockAt | ||
import org.junit.jupiter.api.Test | ||
import java.time.Year | ||
|
||
internal class RegnUtSkatteperiodeForStønadsperiodeKtTest { | ||
private val jan24 = fixedClockAt(1.januar(2024)) | ||
|
||
@Test | ||
fun `stønadsperiode null`() { | ||
null.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2024)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 21`() { | ||
val stønadsperiode = Stønadsperiode.create(januar(2021)..desember(2021)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2021), Year.of(2021)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 21 og 22`() { | ||
val stønadsperiode = Stønadsperiode.create(juli(2021)..juni(2022)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2021), Year.of(2022)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 22`() { | ||
val stønadsperiode = Stønadsperiode.create(januar(2022)..desember(2022)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2022)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 22 og 23`() { | ||
val stønadsperiode = Stønadsperiode.create(juli(2022)..juni(2023)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2023)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 23`() { | ||
val stønadsperiode = Stønadsperiode.create(januar(2023)..desember(2023)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2023)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 23 og 24`() { | ||
val stønadsperiode = Stønadsperiode.create(juli(2023)..juni(2024)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2024)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 24`() { | ||
val stønadsperiode = Stønadsperiode.create(januar(2024)..desember(2024)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2024)), | ||
) | ||
} | ||
|
||
@Test | ||
fun `stønadsperiode 25`() { | ||
// Kun tenkt eksempel fram i tid (merk at dette skjer i jan 24). Dette skal ikke skje i praksis. | ||
val stønadsperiode = Stønadsperiode.create(januar(2025)..desember(2025)) | ||
stønadsperiode.regnUtSkatteperiodeForStønadsperiode(jan24).shouldBe( | ||
YearRange(Year.of(2022), Year.of(2024)), | ||
) | ||
} | ||
} |
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
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
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
Oops, something went wrong.