-
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.
La til initiell støtte for 'feilretting'(kun for Stopp periode)
- Loading branch information
1 parent
27fce72
commit f79f6d0
Showing
11 changed files
with
148 additions
and
16 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...opp-perioder/src/main/kotlin/no/nav/paw/arbeidssokerregisteret/application/Feilretting.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,66 @@ | ||
package no.nav.paw.arbeidssokerregisteret.application | ||
|
||
import no.nav.paw.arbeidssoekerregisteret.api.startstopp.models.Feilretting.FeilType | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.vo.AvviksType | ||
import no.nav.paw.arbeidssokerregisteret.intern.v1.vo.TidspunktFraKilde | ||
import no.nav.paw.arbeidssoekerregisteret.api.startstopp.models.Feilretting as ApiFeilretting | ||
import java.time.Instant | ||
|
||
sealed interface Feilretting | ||
|
||
data class Feilregistrering( | ||
val melding: String? = null | ||
): Feilretting | ||
|
||
data class FeilTidspunkt( | ||
val melding: String?, | ||
val tidspunkt: Instant | ||
): Feilretting | ||
|
||
data class UgyldigFeilretting(val grunn: String) : Feilretting | ||
|
||
val Feilretting?.tidspunkt: Instant? get() = when (this) { | ||
is FeilTidspunkt -> tidspunkt | ||
else -> null | ||
} | ||
|
||
val Feilretting?.aarsak get() = when (this) { | ||
is Feilregistrering -> "Feilregistrering${this.melding?.let { ": $it" } ?: ""}" | ||
is FeilTidspunkt -> "FeilTidspunkt${this.melding?.let { ": $it" } ?: ""}" | ||
else -> null | ||
} | ||
|
||
val Feilretting?.tidspunktFraKilde get() = when (this) { | ||
is FeilTidspunkt -> TidspunktFraKilde( | ||
tidspunkt = tidspunkt, | ||
avviksType = AvviksType.RETTING | ||
) | ||
is Feilregistrering -> TidspunktFraKilde( | ||
tidspunkt = Instant.now(), | ||
avviksType = AvviksType.RETTING | ||
) | ||
else -> null | ||
} | ||
|
||
fun feilretting(apiObj: ApiFeilretting?): Feilretting? { | ||
if (apiObj == null) return null | ||
when (apiObj.feilType) { | ||
FeilType.FeilTidspunkt -> { | ||
if (apiObj.tidspunkt == null) { | ||
return UgyldigFeilretting("FeilTidspunkt må ha tidspunkt") | ||
} | ||
return FeilTidspunkt(apiObj.melding, apiObj.tidspunkt) | ||
} | ||
FeilType.Feilregistrering -> { | ||
when { | ||
apiObj.tidspunkt != null -> { | ||
return UgyldigFeilretting("Feilregistrering kan ikke ha tidspunkt") | ||
} | ||
else -> { | ||
return Feilregistrering(apiObj.melding) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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
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