Skip to content

Commit cc616f9

Browse files
authored
Merge pull request #1368 from navikt/more_varslet_frist_functionality
More varslet frist functionality
2 parents cea58ab + 1ac0b77 commit cc616f9

18 files changed

+520
-156
lines changed

src/main/kotlin/no/nav/klage/dokument/service/DokumentUnderArbeidService.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -2190,7 +2190,7 @@ class DokumentUnderArbeidService(
21902190
systemContext = true
21912191
)
21922192

2193-
behandlingService.setVarsletFrist(
2193+
behandlingService.setOpprinneligVarsletFrist(
21942194
behandlingstidUnitType = svarbrevSettings.behandlingstidUnitType,
21952195
behandlingstidUnits = svarbrevSettings.behandlingstidUnits,
21962196
behandling = behandling,
@@ -2311,9 +2311,9 @@ class DokumentUnderArbeidService(
23112311
},
23122312
ytelse = behandling.ytelse,
23132313
fullmektigFritekst = forlengetBehandlingstidDraft.fullmektigFritekst,
2314-
behandlingstidUnits = forlengetBehandlingstidDraft.behandlingstid.varsletBehandlingstidUnits,
2315-
behandlingstidUnitType = forlengetBehandlingstidDraft.behandlingstid.varsletBehandlingstidUnitType,
2316-
behandlingstidDate = forlengetBehandlingstidDraft.behandlingstid.varsletFrist,
2314+
behandlingstidUnits = forlengetBehandlingstidDraft.varsletBehandlingstidUnits,
2315+
behandlingstidUnitType = forlengetBehandlingstidDraft.varsletBehandlingstidUnitType,
2316+
behandlingstidDate = forlengetBehandlingstidDraft.varsletFrist,
23172317
avsenderEnhetId = Enhet.E4291.navn,
23182318
type = behandling.type,
23192319
mottattKlageinstans = behandling.mottattKlageinstans.toLocalDate(),

src/main/kotlin/no/nav/klage/oppgave/api/controller/ForlengetBehandlingstidDraftController.kt

+26
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,32 @@ class ForlengetBehandlingstidDraftController(
165165
return forlengetBehandlingstidDraftService.setPreviousBehandlingstidInfo(behandlingId = behandlingId, input = input)
166166
}
167167

168+
@PutMapping("/reason-no-letter")
169+
fun setReasonNoLetter(
170+
@PathVariable behandlingId: UUID,
171+
@RequestBody input: ForlengetBehandlingstidReasonNoLetterInput
172+
): ForlengetBehandlingstidDraftView {
173+
logMethodDetails(
174+
methodName = ::setReasonNoLetter.name,
175+
innloggetIdent = tokenUtil.getIdent(),
176+
logger = logger,
177+
)
178+
return forlengetBehandlingstidDraftService.setReasonNoLetter(behandlingId = behandlingId, input = input)
179+
}
180+
181+
@PutMapping("/do-not-send-letter")
182+
fun setDoNotSendLetter(
183+
@PathVariable behandlingId: UUID,
184+
@RequestBody input: ForlengetBehandlingstidDoNotSendLetterInput
185+
): ForlengetBehandlingstidDraftView {
186+
logMethodDetails(
187+
methodName = ::setDoNotSendLetter.name,
188+
innloggetIdent = tokenUtil.getIdent(),
189+
logger = logger,
190+
)
191+
return forlengetBehandlingstidDraftService.setDoNotSendLetter(behandlingId = behandlingId, input = input)
192+
}
193+
168194
@PutMapping("/receivers")
169195
fun setReceivers(
170196
@PathVariable behandlingId: UUID,

src/main/kotlin/no/nav/klage/oppgave/api/mapper/BehandlingMapper.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class BehandlingMapper(
120120
varsletFrist = klagebehandling.varsletBehandlingstid?.varsletFrist,
121121
gosysOppgaveId = klagebehandling.gosysOppgaveId,
122122
tilbakekreving = klagebehandling.tilbakekreving,
123+
timesPreviouslyExtended = klagebehandling.getTimesPreviouslyExtended(),
123124
)
124125
}
125126

@@ -190,6 +191,7 @@ class BehandlingMapper(
190191
gosysOppgaveId = omgjoeringskravbehandling.gosysOppgaveId,
191192
kommentarFraVedtaksinstans = null,
192193
tilbakekreving = omgjoeringskravbehandling.tilbakekreving,
194+
timesPreviouslyExtended = omgjoeringskravbehandling.getTimesPreviouslyExtended(),
193195
)
194196
}
195197

@@ -305,6 +307,7 @@ class BehandlingMapper(
305307
varsletFrist = ankebehandling.varsletBehandlingstid?.varsletFrist,
306308
gosysOppgaveId = ankebehandling.gosysOppgaveId,
307309
tilbakekreving = ankebehandling.tilbakekreving,
310+
timesPreviouslyExtended = ankebehandling.getTimesPreviouslyExtended(),
308311
)
309312
}
310313

@@ -371,6 +374,7 @@ class BehandlingMapper(
371374
varsletFrist = null,
372375
gosysOppgaveId = ankeITrygderettenbehandling.gosysOppgaveId,
373376
tilbakekreving = ankeITrygderettenbehandling.tilbakekreving,
377+
timesPreviouslyExtended = ankeITrygderettenbehandling.getTimesPreviouslyExtended(),
374378
)
375379
}
376380

@@ -444,6 +448,7 @@ class BehandlingMapper(
444448
kjennelseMottatt = behandlingEtterTrygderettenOpphevet.kjennelseMottatt,
445449
gosysOppgaveId = behandlingEtterTrygderettenOpphevet.gosysOppgaveId,
446450
tilbakekreving = behandlingEtterTrygderettenOpphevet.tilbakekreving,
451+
timesPreviouslyExtended = behandlingEtterTrygderettenOpphevet.getTimesPreviouslyExtended(),
447452
)
448453
}
449454

@@ -808,7 +813,8 @@ class BehandlingMapper(
808813
datoSendtTilTR = if (behandling is AnkeITrygderettenbehandling) behandling.sendtTilTrygderetten.toLocalDate() else null,
809814
varsletFrist = if (behandling is BehandlingWithVarsletBehandlingstid) {
810815
behandling.varsletBehandlingstid?.varsletFrist
811-
} else null
816+
} else null,
817+
timesPreviouslyExtended = behandling.getTimesPreviouslyExtended(),
812818
)
813819
}
814820

src/main/kotlin/no/nav/klage/oppgave/api/view/BehandlingDetaljerView.kt

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ data class BehandlingDetaljerView(
4949
val varsletFrist: LocalDate?,
5050
val gosysOppgaveId: Long?,
5151
val tilbakekreving: Boolean,
52+
val timesPreviouslyExtended: Int,
5253
) {
5354
data class CombinedMedunderskriverAndROLView(
5455
val employee: SaksbehandlerView?,

src/main/kotlin/no/nav/klage/oppgave/api/view/ForlengetBehandlingstid.kt

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ data class ForlengetBehandlingstidReasonInput(val reason: String?)
1313

1414
data class ForlengetBehandlingstidPreviousBehandlingstidInfoInput(val previousBehandlingstidInfo: String?)
1515

16+
data class ForlengetBehandlingstidReasonNoLetterInput(val reasonNoLetter: String?)
17+
18+
data class ForlengetBehandlingstidDoNotSendLetterInput(val doNotSendLetter: Boolean)
19+
1620
data class ForlengetBehandlingstidVarsletBehandlingstidUnitsInput(val varsletBehandlingstidUnits: Int)
1721

1822
data class ForlengetBehandlingstidVarsletBehandlingstidUnitTypeIdInput(val varsletBehandlingstidUnitTypeId: String)
@@ -26,7 +30,10 @@ data class ForlengetBehandlingstidDraftView(
2630
val reason: String?,
2731
val previousBehandlingstidInfo: String?,
2832
val behandlingstid: ForlengetBehandlingstidVarsletBehandlingstidView,
33+
val reasonNoLetter: String?,
34+
val doNotSendLetter: Boolean,
2935
val receivers: List<DokumentView.Mottaker>,
36+
val timesPreviouslyExtended: Int,
3037
)
3138

3239
data class ForlengetBehandlingstidVarsletBehandlingstidView(

src/main/kotlin/no/nav/klage/oppgave/api/view/History.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ data class VarsletBehandlingstidEvent(
1717
val varsletFrist: LocalDate?,
1818
)
1919

20+
data class ForlengetBehandlingstidEvent(
21+
val mottakere: List<Part>?,
22+
val varsletBehandlingstidUnits: Int?,
23+
val varsletBehandlingstidUnitTypeId: String?,
24+
val varsletFrist: LocalDate?,
25+
val doNotSendLetter: Boolean,
26+
val reasonNoLetter: String?,
27+
)
28+
2029
data class MedunderskriverEvent(
2130
val medunderskriver: SaksbehandlerView?,
2231
//nullable b/c possible missing history initially
@@ -92,6 +101,7 @@ data class HistoryResponse(
92101
val ferdigstilt: List<WithPrevious<FerdigstiltEvent>>,
93102
val feilregistrert: List<WithPrevious<FeilregistrertEvent>>,
94103
val varsletBehandlingstid: List<WithPrevious<VarsletBehandlingstidEvent>>,
104+
val forlengetBehandlingstid: List<WithPrevious<ForlengetBehandlingstidEvent>>,
95105
)
96106

97107
enum class HistoryEventType {
@@ -103,5 +113,6 @@ enum class HistoryEventType {
103113
SATT_PAA_VENT,
104114
FERDIGSTILT,
105115
FEILREGISTRERT,
106-
VARSLET_BEHANDLINGSTID
116+
VARSLET_BEHANDLINGSTID,
117+
FORLENGET_BEHANDLINGSTID,
107118
}

src/main/kotlin/no/nav/klage/oppgave/api/view/OppgaveView.kt

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ data class OppgaveView(
2626
val previousSaksbehandler: SaksbehandlerView?,
2727
val datoSendtTilTR: LocalDate?,
2828
val varsletFrist: LocalDate?,
29+
val timesPreviouslyExtended: Int,
2930
) {
3031

3132
data class SattPaaVent(

src/main/kotlin/no/nav/klage/oppgave/domain/kafka/InternalBehandlingEvent.kt

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ data class VarsletFristEvent(
152152
override val actor: Employee,
153153
override val timestamp: LocalDateTime,
154154
val varsletFrist: LocalDate,
155+
val timesPreviouslyExtended: Int,
155156
) : BaseEvent(actor = actor, timestamp = timestamp)
156157

157158
data class DocumentsChangedEvent(

src/main/kotlin/no/nav/klage/oppgave/domain/klage/Behandling.kt

+6
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ sealed class Behandling(
279279
Type.OMGJOERINGSKRAV
280280
)
281281
}
282+
283+
fun getTimesPreviouslyExtended(): Int {
284+
return varsletBehandlingstidHistorikk.count {
285+
it.varsletBehandlingstid?.varselType == VarsletBehandlingstid.VarselType.FORLENGET
286+
}
287+
}
282288
}
283289

284290
enum class BehandlingRole {

src/main/kotlin/no/nav/klage/oppgave/domain/klage/ForlengetBehandlingstidDraft.kt

+13-14
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package no.nav.klage.oppgave.domain.klage
22

33
import jakarta.persistence.*
44
import no.nav.klage.kodeverk.TimeUnitType
5+
import no.nav.klage.kodeverk.TimeUnitTypeConverter
56
import org.hibernate.annotations.BatchSize
67
import org.hibernate.annotations.Fetch
78
import org.hibernate.annotations.FetchMode
89
import org.hibernate.envers.NotAudited
10+
import java.time.LocalDate
911
import java.time.LocalDateTime
1012
import java.util.*
1113

@@ -26,20 +28,17 @@ class ForlengetBehandlingstidDraft(
2628
var reason: String? = null,
2729
@Column(name = "previous_behandlingstid_info")
2830
var previousBehandlingstidInfo: String? = null,
29-
@Embedded
30-
@AttributeOverrides(
31-
value = [
32-
AttributeOverride(name = "varsletFrist", column = Column(name = "behandlingstid_date")),
33-
AttributeOverride(name = "varsletBehandlingstidUnits", column = Column(name = "behandlingstid_units")),
34-
AttributeOverride(
35-
name = "varsletBehandlingstidUnitType",
36-
column = Column(name = "behandlingstid_unit_type_id")
37-
),
38-
]
39-
)
40-
val behandlingstid: VarsletBehandlingstid = VarsletBehandlingstid(
41-
varsletBehandlingstidUnitType = TimeUnitType.WEEKS,
42-
),
31+
@Column(name = "behandlingstid_date")
32+
var varsletFrist: LocalDate? = null,
33+
@Column(name = "behandlingstid_units")
34+
var varsletBehandlingstidUnits: Int? = null,
35+
@Column(name = "behandlingstid_unit_type_id")
36+
@Convert(converter = TimeUnitTypeConverter::class)
37+
var varsletBehandlingstidUnitType: TimeUnitType = TimeUnitType.WEEKS,
38+
@Column(name = "reason_no_letter")
39+
var reasonNoLetter: String? = null,
40+
@Column(name = "do_not_send_letter")
41+
var doNotSendLetter: Boolean = false,
4342
@OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, fetch = FetchType.LAZY)
4443
@JoinColumn(name = "forlenget_behandlingstid_draft_id", referencedColumnName = "id", nullable = false)
4544
@Fetch(FetchMode.SELECT)

src/main/kotlin/no/nav/klage/oppgave/domain/klage/VarsletBehandlingstid.kt

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package no.nav.klage.oppgave.domain.klage
22

3-
import jakarta.persistence.Column
4-
import jakarta.persistence.Convert
5-
import jakarta.persistence.Embeddable
3+
import jakarta.persistence.*
64
import no.nav.klage.kodeverk.TimeUnitType
75
import no.nav.klage.kodeverk.TimeUnitTypeConverter
86
import java.time.LocalDate
@@ -16,4 +14,16 @@ data class VarsletBehandlingstid(
1614
@Column(name = "varslet_behandlingstid_unit_type_id")
1715
@Convert(converter = TimeUnitTypeConverter::class)
1816
var varsletBehandlingstidUnitType: TimeUnitType? = null,
19-
)
17+
@Column(name = "varslet_reason_no_letter")
18+
var reasonNoLetter: String?,
19+
@Column(name = "varslet_varsel_type")
20+
@Enumerated(EnumType.STRING)
21+
val varselType: VarselType,
22+
@Column(name = "varslet_do_not_send_letter")
23+
var doNotSendLetter: Boolean,
24+
) {
25+
enum class VarselType {
26+
OPPRINNELIG,
27+
FORLENGET,
28+
}
29+
}

src/main/kotlin/no/nav/klage/oppgave/service/BehandlingService.kt

+37-19
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ class BehandlingService(
774774
return behandling.modified
775775
}
776776

777-
fun setVarsletFrist(
777+
fun setOpprinneligVarsletFrist(
778778
behandlingstidUnitType: TimeUnitType,
779779
behandlingstidUnits: Int,
780780
behandling: Behandling,
@@ -784,7 +784,7 @@ class BehandlingService(
784784
//TODO differentiate between mottatt and now.
785785
val varsletFrist = findDateBasedOnTimeUnitTypeAndUnits(
786786
timeUnitType = behandlingstidUnitType,
787-
units = behandlingstidUnits.toLong(),
787+
units = behandlingstidUnits,
788788
fromDate = behandling.mottattKlageinstans.toLocalDate()
789789
)
790790

@@ -794,7 +794,10 @@ class BehandlingService(
794794
behandlingstidUnits = behandlingstidUnits,
795795
behandlingstidUnitType = behandlingstidUnitType,
796796
behandling = behandling,
797-
mottakere = mottakere
797+
mottakere = mottakere,
798+
varselType = VarsletBehandlingstid.VarselType.OPPRINNELIG,
799+
doNotSendLetter = false,
800+
reasonNoLetter = null,
798801
)
799802
}
800803

@@ -804,14 +807,20 @@ class BehandlingService(
804807
behandlingstidUnits: Int?,
805808
behandlingstidUnitType: TimeUnitType?,
806809
behandling: Behandling,
807-
mottakere: List<Mottaker>
810+
mottakere: List<Mottaker>,
811+
varselType: VarsletBehandlingstid.VarselType,
812+
doNotSendLetter: Boolean,
813+
reasonNoLetter: String?,
808814
): LocalDateTime {
809815
val saksbehandlerIdent = if (systemUserContext) systembrukerIdent else tokenUtil.getIdent()
810816

811817
val varsletBehandlingstid = VarsletBehandlingstid(
812818
varsletFrist = varsletFrist,
813819
varsletBehandlingstidUnits = if (behandlingstidUnitType != null) behandlingstidUnits else null,
814820
varsletBehandlingstidUnitType = if (behandlingstidUnits != null) behandlingstidUnitType else null,
821+
varselType = varselType,
822+
doNotSendLetter = doNotSendLetter,
823+
reasonNoLetter = reasonNoLetter,
815824
)
816825

817826
if (behandling is BehandlingWithVarsletBehandlingstid) {
@@ -836,6 +845,7 @@ class BehandlingService(
836845
),
837846
timestamp = behandling.modified,
838847
varsletFrist = varsletFrist,
848+
timesPreviouslyExtended = behandling.getTimesPreviouslyExtended(),
839849
)
840850
),
841851
behandlingId = behandling.id,
@@ -846,29 +856,33 @@ class BehandlingService(
846856
}
847857

848858
fun setForlengetBehandlingstid(
849-
newVarsletBehandlingstid: VarsletBehandlingstid,
859+
varsletFrist: LocalDate?,
860+
varsletBehandlingstidUnits: Int?,
861+
varsletBehandlingstidUnitType: TimeUnitType,
850862
behandling: Behandling,
851863
systemUserContext: Boolean,
852864
mottakere: List<Mottaker>,
865+
doNotSendLetter: Boolean,
866+
reasonNoLetter: String?,
853867
): LocalDateTime {
854-
val varsletFrist =
855-
if (newVarsletBehandlingstid.varsletFrist != null) {
856-
newVarsletBehandlingstid.varsletFrist
857-
} else {
858-
findDateBasedOnTimeUnitTypeAndUnits(
859-
timeUnitType = newVarsletBehandlingstid.varsletBehandlingstidUnitType!!,
860-
units = newVarsletBehandlingstid.varsletBehandlingstidUnits!!.toLong(),
868+
val newVarsletFrist =
869+
(varsletFrist
870+
?: findDateBasedOnTimeUnitTypeAndUnits(
871+
timeUnitType = varsletBehandlingstidUnitType,
872+
units = varsletBehandlingstidUnits!!,
861873
fromDate = LocalDate.now(),
862-
)
863-
}!!
874+
))
864875

865876
return privateSetVarsletFrist(
866877
systemUserContext = systemUserContext,
867-
varsletFrist = varsletFrist,
868-
behandlingstidUnits = newVarsletBehandlingstid.varsletBehandlingstidUnits,
869-
behandlingstidUnitType = newVarsletBehandlingstid.varsletBehandlingstidUnitType,
878+
varsletFrist = newVarsletFrist,
879+
behandlingstidUnits = varsletBehandlingstidUnits,
880+
behandlingstidUnitType = varsletBehandlingstidUnitType,
870881
behandling = behandling,
871-
mottakere = mottakere
882+
mottakere = mottakere,
883+
varselType = VarsletBehandlingstid.VarselType.FORLENGET,
884+
doNotSendLetter = doNotSendLetter,
885+
reasonNoLetter = reasonNoLetter,
872886
)
873887
}
874888

@@ -2363,7 +2377,11 @@ class BehandlingService(
23632377
varsletBehandlingstid = historyService.createVarsletBehandlingstidHistory(
23642378
varsletBehandlingstidHistorikk = behandling.varsletBehandlingstidHistorikk,
23652379
behandlingCreated = behandling.created,
2366-
)
2380+
),
2381+
forlengetBehandlingstid = historyService.createForlengetBehandlingstidHistory(
2382+
varsletBehandlingstidHistorikk = behandling.varsletBehandlingstidHistorikk,
2383+
behandlingCreated = behandling.created,
2384+
),
23672385
)
23682386
}
23692387

0 commit comments

Comments
 (0)