@@ -21,14 +21,12 @@ import fi.espoo.evaka.serviceneed.ShiftCareType
21
21
import fi.espoo.evaka.serviceneed.insertServiceNeed
22
22
import fi.espoo.evaka.shared.ChildId
23
23
import fi.espoo.evaka.shared.DaycareId
24
- import fi.espoo.evaka.shared.EmployeeId
25
- import fi.espoo.evaka.shared.EvakaUserId
26
24
import fi.espoo.evaka.shared.IncomeStatementId
27
25
import fi.espoo.evaka.shared.PartnershipId
28
26
import fi.espoo.evaka.shared.PersonId
29
27
import fi.espoo.evaka.shared.async.AsyncJob
30
28
import fi.espoo.evaka.shared.async.AsyncJobRunner
31
- import fi.espoo.evaka.shared.auth.UserRole
29
+ import fi.espoo.evaka.shared.auth.AuthenticatedUser
32
30
import fi.espoo.evaka.shared.dev.DevCareArea
33
31
import fi.espoo.evaka.shared.dev.DevDaycare
34
32
import fi.espoo.evaka.shared.dev.DevEmployee
@@ -45,7 +43,6 @@ import fi.espoo.evaka.shared.domain.DateRange
45
43
import fi.espoo.evaka.shared.domain.HelsinkiDateTime
46
44
import fi.espoo.evaka.shared.domain.MockEvakaClock
47
45
import fi.espoo.evaka.shared.job.ScheduledJobs
48
- import fi.espoo.evaka.shared.security.upsertEmployeeUser
49
46
import fi.espoo.evaka.snDaycareContractDays15
50
47
import java.math.BigDecimal
51
48
import java.time.LocalDate
@@ -82,8 +79,6 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
82
79
private val fridgeHeadOfChildEmail = " fridge_hoc@example.com"
83
80
private lateinit var fridgeHeadOfChildId: PersonId
84
81
private lateinit var childId: ChildId
85
- private lateinit var employeeId: EmployeeId
86
- private lateinit var employeeEvakaUserId: EvakaUserId
87
82
private lateinit var daycareId: DaycareId
88
83
89
84
@BeforeEach
@@ -126,9 +121,6 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
126
121
confirmedBy = null ,
127
122
confirmedAt = null ,
128
123
)
129
- employeeId = tx.insert(DevEmployee (roles = setOf (UserRole .SERVICE_WORKER )))
130
- tx.upsertEmployeeUser(employeeId)
131
- employeeEvakaUserId = EvakaUserId (employeeId.raw)
132
124
}
133
125
}
134
126
@@ -140,7 +132,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
140
132
it.insert(
141
133
DevIncome (
142
134
personId = fridgeHeadOfChildId,
143
- modifiedBy = employeeEvakaUserId ,
135
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
144
136
validFrom = clock.today().minusMonths(1 ),
145
137
validTo = clock.today(),
146
138
)
@@ -149,7 +141,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
149
141
it.insert(
150
142
DevIncome (
151
143
personId = fridgeHeadOfChildId,
152
- modifiedBy = employeeEvakaUserId ,
144
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
153
145
validFrom = clock.today().plusDays(1 ),
154
146
validTo = clock.today().plusMonths(6 ),
155
147
)
@@ -165,7 +157,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
165
157
it.insert(
166
158
DevIncome (
167
159
personId = fridgeHeadOfChildId,
168
- modifiedBy = employeeEvakaUserId ,
160
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
169
161
validFrom = clock.today().minusMonths(1 ),
170
162
validTo = clock.today().plusWeeks(4 ),
171
163
)
@@ -180,18 +172,40 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
180
172
)
181
173
}
182
174
183
- private lateinit var fridgePartnerId: PersonId
175
+ @Test
176
+ fun `notification is not sent if placement unit is not invoiced by municipality` () {
177
+ db.transaction {
178
+ it.execute {
179
+ sql(
180
+ " UPDATE daycare SET invoiced_by_municipality = false WHERE id = ${bind(daycareId)} "
181
+ )
182
+ }
183
+
184
+ it.insert(
185
+ DevIncome (
186
+ personId = fridgeHeadOfChildId,
187
+ modifiedBy = AuthenticatedUser .SystemInternalUser .evakaUserId,
188
+ validFrom = clock.today().minusMonths(1 ),
189
+ validTo = clock.today().plusWeeks(4 ),
190
+ )
191
+ )
192
+ }
193
+
194
+ assertEquals(0 , getEmails().size)
195
+ assertEquals(0 , getIncomeNotifications(fridgeHeadOfChildId).size)
196
+ }
184
197
185
198
@Test
186
199
fun `fridge partner expiring income is notified 4 weeks beforehand` () {
200
+ val fridgePartner = DevPerson (email = " partner@example.com" )
201
+
187
202
db.transaction {
188
- fridgePartnerId =
189
- it.insert(DevPerson (email = " partner@example.com" ), DevPersonType .ADULT )
203
+ it.insert(fridgePartner, DevPersonType .ADULT )
190
204
191
205
it.insert(
192
206
DevIncome (
193
- personId = fridgePartnerId ,
194
- modifiedBy = employeeEvakaUserId ,
207
+ personId = fridgePartner.id ,
208
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
195
209
validFrom = clock.today().minusMonths(1 ),
196
210
validTo = clock.today().plusWeeks(4 ),
197
211
)
@@ -214,7 +228,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
214
228
partnershipId,
215
229
2 ,
216
230
1 ,
217
- fridgePartnerId ,
231
+ fridgePartner.id ,
218
232
clock.today(),
219
233
clock.today(),
220
234
clock.now(),
@@ -224,23 +238,23 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
224
238
225
239
assertEquals(1 , getEmails().size)
226
240
assertEquals(0 , getIncomeNotifications(fridgeHeadOfChildId).size)
227
- assertEquals(1 , getIncomeNotifications(fridgePartnerId ).size)
241
+ assertEquals(1 , getIncomeNotifications(fridgePartner.id ).size)
228
242
assertEquals(
229
243
IncomeNotificationType .INITIAL_EMAIL ,
230
- getIncomeNotifications(fridgePartnerId )[0 ].notificationType,
244
+ getIncomeNotifications(fridgePartner.id )[0 ].notificationType,
231
245
)
232
246
}
233
247
234
248
@Test
235
249
fun `fridge partner with partnership end date as null and expiring income is notified 4 weeks beforehand` () {
250
+ val fridgePartner = DevPerson (email = " partner@example.com" )
236
251
db.transaction {
237
- fridgePartnerId =
238
- it.insert(DevPerson (email = " partner@example.com" ), DevPersonType .ADULT )
252
+ it.insert(fridgePartner, DevPersonType .ADULT )
239
253
240
254
it.insert(
241
255
DevIncome (
242
- personId = fridgePartnerId ,
243
- modifiedBy = employeeEvakaUserId ,
256
+ personId = fridgePartner.id ,
257
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
244
258
validFrom = clock.today().minusMonths(1 ),
245
259
validTo = clock.today().plusWeeks(4 ),
246
260
)
@@ -263,7 +277,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
263
277
partnershipId,
264
278
2 ,
265
279
1 ,
266
- fridgePartnerId ,
280
+ fridgePartner.id ,
267
281
clock.today(),
268
282
null ,
269
283
clock.now(),
@@ -273,10 +287,10 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
273
287
274
288
assertEquals(1 , getEmails().size)
275
289
assertEquals(0 , getIncomeNotifications(fridgeHeadOfChildId).size)
276
- assertEquals(1 , getIncomeNotifications(fridgePartnerId ).size)
290
+ assertEquals(1 , getIncomeNotifications(fridgePartner.id ).size)
277
291
assertEquals(
278
292
IncomeNotificationType .INITIAL_EMAIL ,
279
- getIncomeNotifications(fridgePartnerId )[0 ].notificationType,
293
+ getIncomeNotifications(fridgePartner.id )[0 ].notificationType,
280
294
)
281
295
}
282
296
@@ -286,7 +300,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
286
300
it.insert(
287
301
DevIncome (
288
302
personId = fridgeHeadOfChildId,
289
- modifiedBy = employeeEvakaUserId ,
303
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
290
304
validFrom = clock.today().minusMonths(1 ),
291
305
validTo = clock.today().minusDays(2 ),
292
306
)
@@ -304,7 +318,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
304
318
it.insert(
305
319
DevIncome (
306
320
personId = fridgeHeadOfChildId,
307
- modifiedBy = employeeEvakaUserId ,
321
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
308
322
validFrom = incomeExpirationDate.minusMonths(1 ),
309
323
validTo = incomeExpirationDate,
310
324
)
@@ -326,12 +340,15 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
326
340
@Test
327
341
fun `expiring income is notified if there is a handled income statement reaching after expiration` () {
328
342
val incomeExpirationDate = clock.today().plusWeeks(4 )
343
+ val employee = DevEmployee ()
329
344
330
345
db.transaction {
346
+ it.insert(employee)
347
+
331
348
it.insert(
332
349
DevIncome (
333
350
personId = fridgeHeadOfChildId,
334
- modifiedBy = employeeEvakaUserId ,
351
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
335
352
validFrom = incomeExpirationDate.minusMonths(1 ),
336
353
validTo = incomeExpirationDate,
337
354
)
@@ -343,7 +360,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
343
360
personId = fridgeHeadOfChildId,
344
361
data = createGrossIncome(incomeExpirationDate.plusDays(1 )),
345
362
status = IncomeStatementStatus .HANDLED ,
346
- handlerId = employeeId ,
363
+ handlerId = employee.id ,
347
364
handledAt = clock.now(),
348
365
)
349
366
)
@@ -360,7 +377,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
360
377
it.insert(
361
378
DevIncome (
362
379
personId = fridgeHeadOfChildId,
363
- modifiedBy = employeeEvakaUserId ,
380
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
364
381
validFrom = incomeExpirationDate.minusMonths(1 ),
365
382
validTo = incomeExpirationDate,
366
383
)
@@ -386,7 +403,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
386
403
it.insert(
387
404
DevIncome (
388
405
personId = fridgeHeadOfChildId,
389
- modifiedBy = employeeEvakaUserId ,
406
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
390
407
validFrom = clock.today().minusMonths(1 ),
391
408
validTo = expirationDate,
392
409
)
@@ -423,7 +440,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
423
440
it.insert(
424
441
DevIncome (
425
442
personId = fridgeHeadOfChildId,
426
- modifiedBy = employeeEvakaUserId ,
443
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
427
444
validFrom = clock.today().minusMonths(1 ),
428
445
validTo = clock.today().plusDays(13 ),
429
446
)
@@ -445,7 +462,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
445
462
it.insert(
446
463
DevIncome (
447
464
personId = fridgeHeadOfChildId,
448
- modifiedBy = employeeEvakaUserId ,
465
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
449
466
validFrom = clock.today().minusMonths(1 ),
450
467
validTo = clock.today().plusWeeks(4 ),
451
468
)
@@ -486,7 +503,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
486
503
it.insert(
487
504
DevIncome (
488
505
personId = fridgeHeadOfChildId,
489
- modifiedBy = employeeEvakaUserId ,
506
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
490
507
validFrom = clock.today().minusMonths(1 ),
491
508
validTo = clock.today().plusDays(6 ),
492
509
)
@@ -537,7 +554,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
537
554
it.insert(
538
555
DevIncome (
539
556
personId = fridgeHeadOfChildId,
540
- modifiedBy = employeeEvakaUserId ,
557
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
541
558
validFrom = expirationDay.minusMonths(1 ),
542
559
validTo = expirationDay,
543
560
effect = IncomeEffect .INCOME ,
@@ -666,7 +683,7 @@ class OutdatedIncomeNotificationsIntegrationTest : FullApplicationTest(resetDbBe
666
683
tx.insert(
667
684
DevIncome (
668
685
personId = fridgeHeadOfChildId,
669
- modifiedBy = employeeEvakaUserId ,
686
+ modifiedBy = AuthenticatedUser . SystemInternalUser .evakaUserId ,
670
687
validFrom = clock.today().minusMonths(1 ),
671
688
validTo = clock.today().plusWeeks(4 ),
672
689
)
0 commit comments