Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lisätään maksatusaineistoon yksikön kustannuspaikka #6314

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/lib-common/generated/api-types/invoicing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ export type PaymentStatus =
export interface PaymentUnit {
businessId: string | null
careType: CareType[]
costCenter: string | null
iban: string | null
id: DaycareId
name: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,22 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
assertEquals(PaymentStatus.DRAFT, payment.status)
assertEquals(testDaycare.id, payment.unit.id)
assertEquals(testDaycare.name, payment.unit.name)
assertEquals(testDaycare.costCenter, payment.unit.costCenter)
assertEquals(134850 - 28800, payment.amount)
}
payments[1].let { payment ->
assertEquals(PaymentStatus.CONFIRMED, payment.status)
assertEquals(testVoucherDaycare.id, payment.unit.id)
assertEquals(87000 - 28800, payment.amount)
assertEquals(testVoucherDaycare.name, payment.unit.name)
assertEquals(testVoucherDaycare.costCenter, payment.unit.costCenter)
}
payments.last().let { payment ->
assertEquals(PaymentStatus.CONFIRMED, payment.status)
assertEquals(testVoucherDaycare2.id, payment.unit.id)
assertEquals(35000 - 28800, payment.amount)
assertEquals(testVoucherDaycare2.name, payment.unit.name)
assertEquals(testVoucherDaycare2.costCenter, payment.unit.costCenter)
}

// assert that sending details remain unset
Expand Down Expand Up @@ -345,12 +348,14 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
assertEquals(DateRange(janFirst, janLast), payment.period)
assertEquals(testDaycare.id, payment.unit.id)
assertEquals(testDaycare.name, payment.unit.name)
assertEquals(testDaycare.costCenter, payment.unit.costCenter)
assertEquals(134850 - 28800, payment.amount)
}
payments.last().let { payment ->
assertEquals(testVoucherDaycare.id, payment.unit.id)
assertEquals(87000 - 28800, payment.amount)
assertEquals(testVoucherDaycare.name, payment.unit.name)
assertEquals(testVoucherDaycare.costCenter, payment.unit.costCenter)
}

// assert that status is set and sending details remain unset
Expand Down Expand Up @@ -406,6 +411,7 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
assertEquals(PaymentStatus.CONFIRMED, payment.status)
assertEquals(DateRange(janFirst, janLast), payment.period)
assertEquals(testDaycare.id, payment.unit.id)
assertEquals(testDaycare.costCenter, payment.unit.costCenter)
assertEquals(134850 - 28800, payment.amount)
}
payments.last().let { payment ->
Expand All @@ -421,6 +427,7 @@ class PaymentsIntegrationTest : FullApplicationTest(resetDbBeforeEach = true) {
assertEquals(testVoucherDaycare.businessId, payment.unit.businessId)
assertEquals(testVoucherDaycare.iban, payment.unit.iban)
assertEquals(testVoucherDaycare.providerId, payment.unit.providerId)
assertEquals(testVoucherDaycare.costCenter, payment.unit.costCenter)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun Database.Read.readPaymentsByIdsWithFreshUnitData(ids: List<PaymentId>): List
"""
SELECT
p.id, p.created, p.updated, p.unit_id,
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.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,
p.period, p.number, p.amount, p.status, p.payment_date, p.due_date, p.sent_at, p.sent_by
FROM payment p
JOIN daycare d ON d.id = p.unit_id
Expand All @@ -61,7 +61,7 @@ SELECT
p.id, p.created, p.updated,
p.unit_id, p.unit_name, p.unit_business_id, p.unit_iban, p.unit_provider_id,
p.period, p.number, p.amount, p.status, p.payment_date, p.due_date, p.sent_at, p.sent_by,
d.type as unit_care_type
d.type as unit_care_type, d.cost_center as unit_cost_center
FROM payment p
JOIN daycare d ON d.id = p.unit_id
ORDER BY period DESC, unit_name
Expand Down Expand Up @@ -113,6 +113,7 @@ SELECT
CASE WHEN p.status = 'SENT' THEN unit_iban ELSE d.iban END AS unit_iban,
CASE WHEN p.status = 'SENT' THEN unit_provider_id ELSE d.provider_id END AS unit_provider_id,
d.type AS unit_care_type,
d.cost_center as unit_cost_center,
p.period, p.number, p.amount, p.status, p.payment_date, p.due_date, p.sent_at, p.sent_by,
count(*) OVER () AS count
FROM payment p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ data class PaymentUnit(
val iban: String?,
val providerId: String?,
val careType: Set<CareType>,
val costCenter: String?,
)

data class Payment(
Expand Down