@@ -16,6 +16,7 @@ import no.nav.mulighetsrommet.model.Organisasjonsnummer
16
16
import no.nav.mulighetsrommet.model.Periode
17
17
import no.nav.mulighetsrommet.model.Prismodell
18
18
import no.nav.mulighetsrommet.model.Tiltakskode
19
+ import no.nav.tiltak.okonomi.BestillingStatusType
19
20
import org.intellij.lang.annotations.Language
20
21
import java.util.*
21
22
@@ -29,8 +30,8 @@ class TilsagnQueries(private val session: Session) {
29
30
periode,
30
31
lopenummer,
31
32
bestillingsnummer,
33
+ bestilling_status,
32
34
kostnadssted,
33
- arrangor_id,
34
35
status,
35
36
type,
36
37
belop_gjenstaende,
@@ -42,8 +43,8 @@ class TilsagnQueries(private val session: Session) {
42
43
:periode::daterange,
43
44
:lopenummer,
44
45
:bestillingsnummer,
46
+ :bestilling_status,
45
47
:kostnadssted,
46
- :arrangor_id::uuid,
47
48
:status::tilsagn_status,
48
49
:type::tilsagn_type,
49
50
:belop_gjenstaende,
@@ -55,8 +56,8 @@ class TilsagnQueries(private val session: Session) {
55
56
periode = excluded.periode,
56
57
lopenummer = excluded.lopenummer,
57
58
bestillingsnummer = excluded.bestillingsnummer,
59
+ bestilling_status = excluded.bestilling_status,
58
60
kostnadssted = excluded.kostnadssted,
59
- arrangor_id = excluded.arrangor_id,
60
61
status = excluded.status,
61
62
type = excluded.type,
62
63
belop_gjenstaende = excluded.belop_gjenstaende,
@@ -71,8 +72,8 @@ class TilsagnQueries(private val session: Session) {
71
72
" lopenummer" to dbo.lopenummer,
72
73
" status" to TilsagnStatus .TIL_GODKJENNING .name,
73
74
" bestillingsnummer" to dbo.bestillingsnummer,
75
+ " bestilling_status" to dbo.bestillingStatus?.name,
74
76
" kostnadssted" to dbo.kostnadssted,
75
- " arrangor_id" to dbo.arrangorId,
76
77
" type" to dbo.type.name,
77
78
" belop_gjenstaende" to dbo.beregning.output.belop,
78
79
" belop_beregnet" to dbo.beregning.output.belop,
@@ -125,7 +126,7 @@ class TilsagnQueries(private val session: Session) {
125
126
execute(queryOf(query, params))
126
127
}
127
128
128
- fun setGjenstaendeBelop (id : UUID , belop : Int ) = with (session) {
129
+ fun setGjenstaendeBelop (id : UUID , belop : Int ) {
129
130
@Language(" PostgreSQL" )
130
131
val query = """
131
132
update tilsagn set
@@ -138,7 +139,7 @@ class TilsagnQueries(private val session: Session) {
138
139
" belop" to belop,
139
140
)
140
141
141
- execute(queryOf(query, params))
142
+ session. execute(queryOf(query, params))
142
143
}
143
144
144
145
fun getNextLopenummeByGjennomforing (gjennomforingId : UUID ): Int {
@@ -211,6 +212,15 @@ class TilsagnQueries(private val session: Session) {
211
212
session.execute(queryOf(query, mapOf (" id" to id, " status" to status.name)))
212
213
}
213
214
215
+ fun setBestillingStatus (bestillingsnummer : String , status : BestillingStatusType ) {
216
+ @Language(" PostgreSQL" )
217
+ val query = """
218
+ update tilsagn set bestilling_status = ? where bestillingsnummer = ?
219
+ """ .trimIndent()
220
+
221
+ session.execute(queryOf(query, status.name, bestillingsnummer))
222
+ }
223
+
214
224
private fun Row.toTilsagnDto (): Tilsagn {
215
225
val id = uuid(" id" )
216
226
@@ -230,7 +240,10 @@ class TilsagnQueries(private val session: Session) {
230
240
belopGjenstaende = int(" belop_gjenstaende" ),
231
241
periode = periode(" periode" ),
232
242
lopenummer = int(" lopenummer" ),
233
- bestillingsnummer = string(" bestillingsnummer" ),
243
+ bestilling = Tilsagn .Bestilling (
244
+ bestillingsnummer = string(" bestillingsnummer" ),
245
+ status = stringOrNull(" bestilling_status" )?.let { BestillingStatusType .valueOf(it) },
246
+ ),
234
247
kostnadssted = NavEnhetDbo (
235
248
enhetsnummer = string(" kostnadssted" ),
236
249
navn = string(" kostnadssted_navn" ),
0 commit comments