Skip to content

Commit c5d99b8

Browse files
authored
Merge pull request #6314 from espoon-voltti/payment-unit-cost-center
Lisätään maksatusaineistoon yksikön kustannuspaikka
2 parents 2286081 + aaab3ca commit c5d99b8

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

frontend/src/lib-common/generated/api-types/invoicing.ts

+1
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ export type PaymentStatus =
819819
export interface PaymentUnit {
820820
businessId: string | null
821821
careType: CareType[]
822+
costCenter: string | null
822823
iban: string | null
823824
id: DaycareId
824825
name: string

service/src/integrationTest/kotlin/fi/espoo/evaka/invoicing/PaymentsIntegrationTest.kt

+7
Original file line numberDiff line numberDiff line change
@@ -266,19 +266,22 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
266266
assertEquals(PaymentStatus.DRAFT, payment.status)
267267
assertEquals(testDaycare.id, payment.unit.id)
268268
assertEquals(testDaycare.name, payment.unit.name)
269+
assertEquals(testDaycare.costCenter, payment.unit.costCenter)
269270
assertEquals(134850 - 28800, payment.amount)
270271
}
271272
payments[1].let { payment ->
272273
assertEquals(PaymentStatus.CONFIRMED, payment.status)
273274
assertEquals(testVoucherDaycare.id, payment.unit.id)
274275
assertEquals(87000 - 28800, payment.amount)
275276
assertEquals(testVoucherDaycare.name, payment.unit.name)
277+
assertEquals(testVoucherDaycare.costCenter, payment.unit.costCenter)
276278
}
277279
payments.last().let { payment ->
278280
assertEquals(PaymentStatus.CONFIRMED, payment.status)
279281
assertEquals(testVoucherDaycare2.id, payment.unit.id)
280282
assertEquals(35000 - 28800, payment.amount)
281283
assertEquals(testVoucherDaycare2.name, payment.unit.name)
284+
assertEquals(testVoucherDaycare2.costCenter, payment.unit.costCenter)
282285
}
283286

284287
// assert that sending details remain unset
@@ -345,12 +348,14 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
345348
assertEquals(DateRange(janFirst, janLast), payment.period)
346349
assertEquals(testDaycare.id, payment.unit.id)
347350
assertEquals(testDaycare.name, payment.unit.name)
351+
assertEquals(testDaycare.costCenter, payment.unit.costCenter)
348352
assertEquals(134850 - 28800, payment.amount)
349353
}
350354
payments.last().let { payment ->
351355
assertEquals(testVoucherDaycare.id, payment.unit.id)
352356
assertEquals(87000 - 28800, payment.amount)
353357
assertEquals(testVoucherDaycare.name, payment.unit.name)
358+
assertEquals(testVoucherDaycare.costCenter, payment.unit.costCenter)
354359
}
355360

356361
// assert that status is set and sending details remain unset
@@ -406,6 +411,7 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
406411
assertEquals(PaymentStatus.CONFIRMED, payment.status)
407412
assertEquals(DateRange(janFirst, janLast), payment.period)
408413
assertEquals(testDaycare.id, payment.unit.id)
414+
assertEquals(testDaycare.costCenter, payment.unit.costCenter)
409415
assertEquals(134850 - 28800, payment.amount)
410416
}
411417
payments.last().let { payment ->
@@ -421,6 +427,7 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
421427
assertEquals(testVoucherDaycare.businessId, payment.unit.businessId)
422428
assertEquals(testVoucherDaycare.iban, payment.unit.iban)
423429
assertEquals(testVoucherDaycare.providerId, payment.unit.providerId)
430+
assertEquals(testVoucherDaycare.costCenter, payment.unit.costCenter)
424431
}
425432
}
426433

service/src/main/kotlin/fi/espoo/evaka/invoicing/data/PaymentQueries.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun Database.Read.readPaymentsByIdsWithFreshUnitData(ids: List<PaymentId>): List
4242
"""
4343
SELECT
4444
p.id, p.created, p.updated, p.unit_id,
45-
d.name AS unit_name, d.business_id AS unit_business_id, d.iban AS unit_iban, d.provider_id AS unit_provider_id, d.type as unit_care_type,
45+
d.name AS unit_name, d.business_id AS unit_business_id, d.iban AS unit_iban, d.provider_id AS unit_provider_id, d.type as unit_care_type, d.cost_center as unit_cost_center,
4646
p.period, p.number, p.amount, p.status, p.payment_date, p.due_date, p.sent_at, p.sent_by
4747
FROM payment p
4848
JOIN daycare d ON d.id = p.unit_id
@@ -61,7 +61,7 @@ SELECT
6161
p.id, p.created, p.updated,
6262
p.unit_id, p.unit_name, p.unit_business_id, p.unit_iban, p.unit_provider_id,
6363
p.period, p.number, p.amount, p.status, p.payment_date, p.due_date, p.sent_at, p.sent_by,
64-
d.type as unit_care_type
64+
d.type as unit_care_type, d.cost_center as unit_cost_center
6565
FROM payment p
6666
JOIN daycare d ON d.id = p.unit_id
6767
ORDER BY period DESC, unit_name
@@ -113,6 +113,7 @@ SELECT
113113
CASE WHEN p.status = 'SENT' THEN unit_iban ELSE d.iban END AS unit_iban,
114114
CASE WHEN p.status = 'SENT' THEN unit_provider_id ELSE d.provider_id END AS unit_provider_id,
115115
d.type AS unit_care_type,
116+
d.cost_center as unit_cost_center,
116117
p.period, p.number, p.amount, p.status, p.payment_date, p.due_date, p.sent_at, p.sent_by,
117118
count(*) OVER () AS count
118119
FROM payment p

service/src/main/kotlin/fi/espoo/evaka/invoicing/domain/Payments.kt

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ data class PaymentUnit(
114114
val iban: String?,
115115
val providerId: String?,
116116
val careType: Set<CareType>,
117+
val costCenter: String?,
117118
)
118119

119120
data class Payment(

0 commit comments

Comments
 (0)