4
4
5
5
package fi.espoo.evaka.invoicing.service
6
6
7
- import fi.espoo.evaka.PureJdbiTest
7
+ import fi.espoo.evaka.FullApplicationTest
8
8
import fi.espoo.evaka.TestInvoiceProductProvider
9
9
import fi.espoo.evaka.invoicing.data.insertDraftInvoices
10
10
import fi.espoo.evaka.invoicing.domain.DraftInvoice
11
11
import fi.espoo.evaka.invoicing.domain.DraftInvoiceRow
12
- import fi.espoo.evaka.invoicing.integration.InvoiceIntegrationClient
12
+ import fi.espoo.evaka.invoicing.domain.InvoiceStatus
13
13
import fi.espoo.evaka.placement.PlacementType
14
- import fi.espoo.evaka.shared.FeatureConfig
15
14
import fi.espoo.evaka.shared.InvoiceCorrectionId
16
15
import fi.espoo.evaka.shared.auth.UserRole
17
- import fi.espoo.evaka.shared.config.defaultJsonMapperBuilder
18
- import fi.espoo.evaka.shared.config.testFeatureConfig
19
16
import fi.espoo.evaka.shared.dev.DevCareArea
20
17
import fi.espoo.evaka.shared.dev.DevDaycare
21
18
import fi.espoo.evaka.shared.dev.DevEmployee
@@ -24,27 +21,21 @@ import fi.espoo.evaka.shared.dev.DevPerson
24
21
import fi.espoo.evaka.shared.dev.DevPersonType
25
22
import fi.espoo.evaka.shared.dev.insert
26
23
import fi.espoo.evaka.shared.domain.FiniteDateRange
27
- import fi.espoo.evaka.shared.domain.RealEvakaClock
24
+ import fi.espoo.evaka.shared.domain.MockEvakaClock
28
25
import java.time.Month
29
26
import java.time.YearMonth
30
27
import kotlin.test.assertEquals
31
28
import org.junit.jupiter.api.BeforeEach
32
29
import org.junit.jupiter.api.Test
30
+ import org.springframework.beans.factory.annotation.Autowired
31
+
32
+ class InvoiceCorrectionsIntegrationTest : FullApplicationTest (resetDbBeforeEach = true ) {
33
+ @Autowired private lateinit var generator: InvoiceGenerator
34
+ @Autowired private lateinit var invoiceService: InvoiceService
33
35
34
- class InvoiceCorrectionsIntegrationTest : PureJdbiTest (resetDbBeforeEach = true ) {
35
36
private val productProvider: InvoiceProductProvider = TestInvoiceProductProvider ()
36
- private val featureConfig: FeatureConfig = testFeatureConfig
37
- private val draftInvoiceGenerator: DraftInvoiceGenerator =
38
- DraftInvoiceGenerator (productProvider, featureConfig)
39
- private val generator: InvoiceGenerator =
40
- InvoiceGenerator (draftInvoiceGenerator, featureConfig, DefaultInvoiceGenerationLogic )
41
- private val invoiceService =
42
- InvoiceService (
43
- InvoiceIntegrationClient .MockClient (defaultJsonMapperBuilder().build()),
44
- TestInvoiceProductProvider (),
45
- featureConfig,
46
- )
47
- private val clock = RealEvakaClock ()
37
+
38
+ private val clock = MockEvakaClock (2024 , 10 , 1 , 12 , 0 )
48
39
49
40
val employee = DevEmployee (roles = setOf (UserRole .FINANCE_ADMIN ))
50
41
val area = DevCareArea ()
@@ -415,7 +406,9 @@ class InvoiceCorrectionsIntegrationTest : PureJdbiTest(resetDbBeforeEach = true)
415
406
month : YearMonth ,
416
407
): List <DraftInvoice > =
417
408
db.read { tx ->
418
- generator.applyCorrections(tx, invoices, month, mapOf (daycare.id to area.id)).shuffled()
409
+ generator
410
+ .applyUnappliedCorrections(tx, month, invoices, mapOf (daycare.id to area.id))
411
+ .shuffled()
419
412
}
420
413
421
414
private fun createTestInvoice (total : Int , month : YearMonth ): DraftInvoice =
@@ -441,7 +434,7 @@ class InvoiceCorrectionsIntegrationTest : PureJdbiTest(resetDbBeforeEach = true)
441
434
442
435
private fun insertAndSendInvoice (invoice : DraftInvoice ) {
443
436
db.transaction { tx ->
444
- val invoiceId = tx.insertDraftInvoices(listOf (invoice)).single()
437
+ val invoiceId = tx.insertDraftInvoices(listOf (invoice), InvoiceStatus . DRAFT ).single()
445
438
invoiceService.sendInvoices(
446
439
tx,
447
440
employee.evakaUserId,
0 commit comments