Skip to content

Commit

Permalink
Rename getLastDate -> getLastInclusiveDate
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikpe committed Feb 26, 2025
1 parent e9ab578 commit 84e008e
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ data class Periode(
}

operator fun contains(periode: Periode): Boolean {
return periode.start in this && periode.getLastDate() in this
return periode.start in this && periode.getLastInclusiveDate() in this
}

fun getDurationInDays(): Long {
return ChronoUnit.DAYS.between(start, slutt)
}

fun getLastDate(): LocalDate {
fun getLastInclusiveDate(): LocalDate {
return slutt.minusDays(1)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PeriodeTest : FunSpec({
test("should get last date") {
val period = Periode(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 31))

period.getLastDate() shouldBe LocalDate.of(2021, 1, 30)
period.getLastInclusiveDate() shouldBe LocalDate.of(2021, 1, 30)
}

test("should check if date is in period") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ suspend fun toArrFlateUtbetaling(
gjennomforing = utbetaling.gjennomforing,
arrangor = utbetaling.arrangor,
periodeStart = utbetaling.periode.start,
periodeSlutt = utbetaling.periode.getLastDate(),
periodeSlutt = utbetaling.periode.getLastInclusiveDate(),
beregning = Beregning.Forhandsgodkjent(
antallManedsverk = antallManedsverk,
belop = beregning.output.belop,
Expand All @@ -319,7 +319,7 @@ suspend fun toArrFlateUtbetaling(
gjennomforing = utbetaling.gjennomforing,
arrangor = utbetaling.arrangor,
periodeStart = utbetaling.periode.start,
periodeSlutt = utbetaling.periode.getLastDate(),
periodeSlutt = utbetaling.periode.getLastInclusiveDate(),
beregning = Beregning.Fri(
belop = beregning.output.belop,
digest = beregning.getDigest(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class ArrFlateUtbetalingKompakt(
gjennomforing = utbetaling.gjennomforing,
arrangor = utbetaling.arrangor,
periodeStart = utbetaling.periode.start,
periodeSlutt = utbetaling.periode.getLastDate(),
periodeSlutt = utbetaling.periode.getLastInclusiveDate(),
belop = utbetaling.beregning.output.belop,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class GjennomforingService(
"Registrerte stengt hos arrangør i perioden",
periode.start.formaterDatoTilEuropeiskDatoformat(),
"-",
periode.getLastDate().formaterDatoTilEuropeiskDatoformat(),
periode.getLastInclusiveDate().formaterDatoTilEuropeiskDatoformat(),
).joinToString(separator = " ")
logEndring(operation, dto, bruker)
dto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fun Route.tilsagnRoutes() {
val satser = ForhandsgodkjenteSatser.satser(tiltakstype).map {
AvtaltSats(
periodeStart = it.periode.start,
periodeSlutt = it.periode.getLastDate(),
periodeSlutt = it.periode.getLastInclusiveDate(),
pris = it.belop,
valuta = "NOK",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object TilsagnValidator {
}

val errors = buildList {
if (next.periode.start.year != next.periode.getLastDate().year) {
if (next.periode.start.year != next.periode.getLastInclusiveDate().year) {
add(
FieldError.of(
TilsagnRequest::periodeSlutt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TilsagnQueries(private val session: Session) {
val params = mapOf(
"gjennomforing_id" to gjennomforingId,
"periode_start" to periode.start,
"periode_slutt" to periode.getLastDate(),
"periode_slutt" to periode.getLastInclusiveDate(),
)

return session.list(queryOf(query, params)) { it.toTilsagnDto() }
Expand All @@ -179,7 +179,7 @@ class TilsagnQueries(private val session: Session) {
val params = mapOf(
"gjennomforing_id" to gjennomforingId,
"periode_start" to periode.start,
"periode_slutt" to periode.getLastDate(),
"periode_slutt" to periode.getLastInclusiveDate(),
)

return session.list(queryOf(query, params)) { it.toArrangorflateTilsagn() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import no.nav.mulighetsrommet.api.tilsagn.model.Besluttelse
import no.nav.mulighetsrommet.api.utbetaling.model.*
import no.nav.mulighetsrommet.model.Kid
import no.nav.mulighetsrommet.model.Kontonummer
import no.nav.mulighetsrommet.model.Periode
import no.nav.mulighetsrommet.serializers.LocalDateSerializer
import no.nav.mulighetsrommet.serializers.LocalDateTimeSerializer
import no.nav.mulighetsrommet.serializers.UUIDSerializer
Expand Down Expand Up @@ -210,7 +209,7 @@ data class UtbetalingKompakt(
status = utbetaling.status,
beregning = Beregning(
periodeStart = utbetaling.periode.start,
periodeSlutt = utbetaling.periode.getLastDate(),
periodeSlutt = utbetaling.periode.getLastInclusiveDate(),
belop = utbetaling.beregning.output.belop,
),
godkjentAvArrangorTidspunkt = utbetaling.godkjentAvArrangorTidspunkt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class TilsagnQueriesTest : FunSpec({
navn = TiltakstypeFixtures.AFT.navn,
),
periodeStart = periodeMedTilsagn.start,
periodeSlutt = periodeMedTilsagn.getLastDate(),
periodeSlutt = periodeMedTilsagn.getLastInclusiveDate(),
arrangor = ArrangorflateTilsagn.Arrangor(
navn = ArrangorFixtures.underenhet1.navn,
id = ArrangorFixtures.underenhet1.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class TilsagnServiceTest : FunSpec({
gjennomforingId = Tilsagn1.gjennomforingId,
type = Tilsagn1.type,
periodeStart = Tilsagn1.periode.start,
periodeSlutt = Tilsagn1.periode.getLastDate(),
periodeSlutt = Tilsagn1.periode.getLastInclusiveDate(),
kostnadssted = Tilsagn1.kostnadssted,
beregning = Tilsagn1.beregning.input,
),
Expand Down Expand Up @@ -384,7 +384,7 @@ class TilsagnServiceTest : FunSpec({
gjennomforingId = Tilsagn1.gjennomforingId,
type = Tilsagn1.type,
periodeStart = Tilsagn1.periode.start,
periodeSlutt = Tilsagn1.periode.getLastDate(),
periodeSlutt = Tilsagn1.periode.getLastInclusiveDate(),
kostnadssted = Tilsagn1.kostnadssted,
beregning = Tilsagn1.beregning.input,
),
Expand All @@ -407,7 +407,7 @@ class TilsagnServiceTest : FunSpec({
gjennomforingId = Tilsagn1.gjennomforingId,
type = Tilsagn1.type,
periodeStart = Tilsagn1.periode.start,
periodeSlutt = Tilsagn1.periode.getLastDate(),
periodeSlutt = Tilsagn1.periode.getLastInclusiveDate(),
kostnadssted = Tilsagn1.kostnadssted,
beregning = TilsagnBeregningFri.Input(belop = 7),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private fun toOebsBestillingMelding(
antall = linje.belop,
periode = linje.periode.start.monthValue.toString().padStart(2, '0'),
startDato = linje.periode.start,
sluttDato = linje.periode.getLastDate(),
sluttDato = linje.periode.getLastInclusiveDate(),
)
}

Expand All @@ -165,7 +165,7 @@ private fun toOebsBestillingMelding(
saksbehandler = bestilling.behandletAv.part,
bdmGodkjenner = bestilling.behandletAv.part,
startDato = bestilling.periode.start,
sluttDato = bestilling.periode.getLastDate(),
sluttDato = bestilling.periode.getLastInclusiveDate(),
bestillingsLinjer = linjer,
statsregnskapsKonto = kontering.statligRegnskapskonto,
artsKonto = kontering.statligArtskonto,
Expand Down

0 comments on commit 84e008e

Please sign in to comment.