Skip to content

Commit

Permalink
Allow isodate format
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitenok committed Feb 20, 2024
1 parent 661dccc commit 21d3f41
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/kotlin/no/nav/syfo/api/maxdate/SykepengerMaxDateRest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,24 @@ fun Route.registerSykepengerMaxDateRestApi(
get("/api/v1/sykepenger/maxdate") {
val principal: BrukerPrincipal = call.authentication.principal()!!
val sykmeldtFnr = principal.fnr
val isoFormat = call.request.queryParameters["isoformat"]?.toBoolean() ?: false

try {
val sykepengerMaxDate = sykepengerMaxDateService.getSykepengerMaxDate(sykmeldtFnr)
val maxDate = sykepengerMaxDate?.let { formatDateForLetter(it.forelopig_beregnet_slutt) }
val utbetaltTom = sykepengerMaxDate?.let { formatDateForLetter(it.utbetalt_tom) }
val maxDate = sykepengerMaxDate?.let {
if (isoFormat) {
it.forelopig_beregnet_slutt.toString()
} else {
formatDateForLetter(it.forelopig_beregnet_slutt)
}
}
val utbetaltTom = sykepengerMaxDate?.let {
if (isoFormat) {
it.utbetalt_tom.toString()
} else {
formatDateForLetter(it.utbetalt_tom)
}
}
log.info("Fetched sykepengerMaxDate from database: ${sykepengerMaxDate?.forelopig_beregnet_slutt}")
call.respond(SykepengerMaxDateResponse(maxDate, utbetaltTom))
} catch (e: Exception) {
Expand Down

0 comments on commit 21d3f41

Please sign in to comment.