diff --git a/src/main/kotlin/no/nav/klage/dokument/service/DokumentUnderArbeidService.kt b/src/main/kotlin/no/nav/klage/dokument/service/DokumentUnderArbeidService.kt index ada697666..5d6692ef3 100644 --- a/src/main/kotlin/no/nav/klage/dokument/service/DokumentUnderArbeidService.kt +++ b/src/main/kotlin/no/nav/klage/dokument/service/DokumentUnderArbeidService.kt @@ -2048,6 +2048,10 @@ class DokumentUnderArbeidService( type = behandling.type ) + if (svarbrevSettings == null) { + throw Exception("Fant ikke svarbrevinnstillinger for ytelse ${behandling.ytelse} og type ${behandling.type}") + } + if (svarbrevSettings.shouldSend) { logger.debug("Sender svarbrev for behandling {}", behandling.id) val receiverId = if (behandling.klager.prosessfullmektig != null) { diff --git a/src/main/kotlin/no/nav/klage/oppgave/service/SvarbrevSettingsService.kt b/src/main/kotlin/no/nav/klage/oppgave/service/SvarbrevSettingsService.kt index 26d7e1266..40ed6f602 100644 --- a/src/main/kotlin/no/nav/klage/oppgave/service/SvarbrevSettingsService.kt +++ b/src/main/kotlin/no/nav/klage/oppgave/service/SvarbrevSettingsService.kt @@ -43,8 +43,8 @@ class SvarbrevSettingsService( } else settings!!.toConsumerView() } - fun getSvarbrevSettingsForYtelseAndType(ytelse: Ytelse, type: Type): SvarbrevSettings { - return svarbrevSettingsRepository.findAll().find { it.ytelse == ytelse && it.type == type }!! + fun getSvarbrevSettingsForYtelseAndType(ytelse: Ytelse, type: Type): SvarbrevSettings? { + return svarbrevSettingsRepository.findAll().find { it.ytelse == ytelse && it.type == type } } fun updateSvarbrevSettings( diff --git a/src/main/resources/db/migration/V163__add_AFP_svarbrev_settings.sql b/src/main/resources/db/migration/V163__add_AFP_svarbrev_settings.sql new file mode 100644 index 000000000..fa1370252 --- /dev/null +++ b/src/main/resources/db/migration/V163__add_AFP_svarbrev_settings.sql @@ -0,0 +1,40 @@ +INSERT INTO klage.svarbrev_settings (id, ytelse_id, behandlingstid_units, custom_text, should_send, created, modified, + created_by, behandlingstid_unit_type, type_id, behandlingstid_unit_type_id) +values (gen_random_uuid(), '27', 12, null, false, now(), now(), 'SYSTEMBRUKER', 'WEEKS', '1', '1'); + +insert into klage.svarbrev_settings_history (id, svarbrev_settings_id, ytelse_id, behandlingstid_units, custom_text, + created, created_by, should_send, behandlingstid_unit_type, type_id, + behandlingstid_unit_type_id) +select gen_random_uuid(), + s.id, + s.ytelse_id, + s.behandlingstid_units, + s.custom_text, + s.modified, + s.created_by, + s.should_send, + s.behandlingstid_unit_type, + s.type_id, + s.behandlingstid_unit_type_id +from klage.svarbrev_settings s +WHERE type_id = '1' + AND ytelse_id = '27'; + +INSERT INTO klage.svarbrev_settings (id, ytelse_id, behandlingstid_units, custom_text, should_send, created, modified, + created_by, behandlingstid_unit_type, type_id, behandlingstid_unit_type_id) +values (gen_random_uuid(), '27', 12, null, false, now(), now(), 'SYSTEMBRUKER', 'WEEKS', '2', '1'); + +select gen_random_uuid(), + s.id, + s.ytelse_id, + s.behandlingstid_units, + s.custom_text, + s.modified, + s.created_by, + s.should_send, + s.behandlingstid_unit_type, + s.type_id, + s.behandlingstid_unit_type_id +from klage.svarbrev_settings s +WHERE type_id = '2' + AND ytelse_id = '27'; \ No newline at end of file