-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
413 additions
and
21 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
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/no/nav/bidrag/behandling/dto/v2/gebyr/GebyrValideringsfeilDto.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,32 @@ | ||
package no.nav.bidrag.behandling.dto.v2.gebyr | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import no.nav.bidrag.behandling.database.datamodell.Behandling | ||
import no.nav.bidrag.behandling.dto.v1.behandling.RolleDto | ||
import no.nav.bidrag.behandling.transformers.behandling.tilDto | ||
|
||
fun Behandling.validerGebyr() = | ||
roller | ||
.filter { it.harGebyrsøknad } | ||
.map { | ||
GebyrValideringsfeilDto( | ||
gjelder = it.tilDto(), | ||
måBestemmeGebyr = avslag != null && it.manueltOverstyrtGebyr?.ilagtGebyr == null, | ||
manglerBegrunnelse = | ||
if (it.manueltOverstyrtGebyr?.overstyrGebyr == true) { | ||
it.manueltOverstyrtGebyr?.begrunnelse.isNullOrEmpty() | ||
} else { | ||
false | ||
}, | ||
) | ||
}.filter { it.harFeil } | ||
|
||
data class GebyrValideringsfeilDto( | ||
val gjelder: RolleDto, | ||
val måBestemmeGebyr: Boolean, | ||
val manglerBegrunnelse: Boolean, | ||
) { | ||
@get:JsonIgnore | ||
val harFeil | ||
get() = manglerBegrunnelse || måBestemmeGebyr | ||
} |
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
72 changes: 72 additions & 0 deletions
72
src/test/kotlin/no/nav/bidrag/behandling/dto/v2/gebyr/GebyrValideringsfeilTest.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,72 @@ | ||
package no.nav.bidrag.behandling.dto.v2.gebyr | ||
|
||
import io.kotest.matchers.collections.shouldHaveSize | ||
import io.kotest.matchers.shouldBe | ||
import no.nav.bidrag.behandling.database.datamodell.RolleManueltOverstyrtGebyr | ||
import no.nav.bidrag.behandling.utils.testdata.opprettGyldigBehandlingForBeregningOgVedtak | ||
import no.nav.bidrag.domene.enums.behandling.TypeBehandling | ||
import no.nav.bidrag.domene.enums.beregning.Resultatkode | ||
import org.junit.jupiter.api.Test | ||
|
||
class GebyrValideringsfeilTest { | ||
@Test | ||
fun `skal feile validering hvis ingen begrunnelse for manuelt overstyrt gebyr`() { | ||
val behandling = opprettGyldigBehandlingForBeregningOgVedtak(true, typeBehandling = TypeBehandling.BIDRAG) | ||
behandling.bidragspliktig!!.harGebyrsøknad = false | ||
val bm = behandling.bidragsmottaker!! | ||
bm.harGebyrsøknad = true | ||
bm.manueltOverstyrtGebyr = RolleManueltOverstyrtGebyr(true, false, null) | ||
val resultat = behandling.validerGebyr() | ||
resultat.shouldHaveSize(1) | ||
resultat.first().manglerBegrunnelse shouldBe true | ||
resultat.first().måBestemmeGebyr shouldBe false | ||
} | ||
|
||
@Test | ||
fun `skal feile validering hvis gebyr ikke satt ved avslag`() { | ||
val behandling = opprettGyldigBehandlingForBeregningOgVedtak(true, typeBehandling = TypeBehandling.BIDRAG) | ||
behandling.avslag = Resultatkode.BIDRAGSPLIKTIG_ER_DØD | ||
behandling.bidragspliktig!!.harGebyrsøknad = false | ||
val bm = behandling.bidragsmottaker!! | ||
bm.harGebyrsøknad = true | ||
bm.manueltOverstyrtGebyr = RolleManueltOverstyrtGebyr(true, null, null) | ||
val resultat = behandling.validerGebyr() | ||
resultat.shouldHaveSize(1) | ||
resultat.first().manglerBegrunnelse shouldBe true | ||
resultat.first().måBestemmeGebyr shouldBe true | ||
} | ||
|
||
@Test | ||
fun `skal ikke feile validering hvis gebyr og begrunnelse er satt ved avslag`() { | ||
val behandling = opprettGyldigBehandlingForBeregningOgVedtak(true, typeBehandling = TypeBehandling.BIDRAG) | ||
behandling.avslag = Resultatkode.BIDRAGSPLIKTIG_ER_DØD | ||
behandling.bidragspliktig!!.harGebyrsøknad = false | ||
val bm = behandling.bidragsmottaker!! | ||
bm.harGebyrsøknad = true | ||
bm.manueltOverstyrtGebyr = RolleManueltOverstyrtGebyr(true, true, "Begrunnelse") | ||
val resultat = behandling.validerGebyr() | ||
resultat.shouldHaveSize(0) | ||
} | ||
|
||
@Test | ||
fun `skal ikke feile validering hvis gebyr og begrunnelse er satt`() { | ||
val behandling = opprettGyldigBehandlingForBeregningOgVedtak(true, typeBehandling = TypeBehandling.BIDRAG) | ||
behandling.bidragspliktig!!.harGebyrsøknad = false | ||
val bm = behandling.bidragsmottaker!! | ||
bm.harGebyrsøknad = true | ||
bm.manueltOverstyrtGebyr = RolleManueltOverstyrtGebyr(true, true, "Begrunnelse") | ||
val resultat = behandling.validerGebyr() | ||
resultat.shouldHaveSize(0) | ||
} | ||
|
||
@Test | ||
fun `skal ikke feile validering hvis ikke manuelt overstyrt`() { | ||
val behandling = opprettGyldigBehandlingForBeregningOgVedtak(true, typeBehandling = TypeBehandling.BIDRAG) | ||
behandling.bidragspliktig!!.harGebyrsøknad = false | ||
val bm = behandling.bidragsmottaker!! | ||
bm.harGebyrsøknad = true | ||
bm.manueltOverstyrtGebyr = RolleManueltOverstyrtGebyr(false, null, null) | ||
val resultat = behandling.validerGebyr() | ||
resultat.shouldHaveSize(0) | ||
} | ||
} |
Oops, something went wrong.