Skip to content

Commit

Permalink
Merge pull request #6357 from espoon-voltti/home-municipality-to-raw-…
Browse files Browse the repository at this point in the history
…report

Kotikunta-tieto raakaraportille
  • Loading branch information
tmkrepo authored Feb 10, 2025
2 parents 4ca63c9 + 4afef2b commit 0d1c320
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
3 changes: 2 additions & 1 deletion frontend/src/employee-frontend/components/reports/Raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ export default React.memo(function Raw() {
},
{ label: 'Poissa maksullisesta', key: 'absencePaid' },
{ label: 'Poissa maksuttomasta', key: 'absenceFree' },
{ label: 'Henkilöstömitoitus', key: 'staffDimensioning' }
{ label: 'Henkilöstömitoitus', key: 'staffDimensioning' },
{ label: 'Kotikunta', key: 'municipalityOfResidence' }
]}
filename={`${
i18n.reports.raw.title
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib-common/generated/api-types/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ export interface RawReportRow {
isWeekday: boolean
language: string | null
lastName: string
municipalityOfResidence: string
partDay: boolean
partWeek: boolean
placementType: PlacementType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,72 @@ class RawReportControllerTest : FullApplicationTest(resetDbBeforeEach = true) {
Tuple("Toka", false, null),
)
}

@Test
fun `municipality of residence is shown correctly`() {
val clock =
MockEvakaClock(HelsinkiDateTime.of(LocalDate.of(2024, 10, 23), LocalTime.of(8, 47)))

val user =
db.transaction { tx ->
val admin = DevEmployee(roles = setOf(UserRole.ADMIN))
tx.insert(admin)
admin.user
}

db.transaction { tx ->
tx.insertServiceNeedOption(snDefaultDaycare)
val areaId = tx.insert(DevCareArea())
val unitId = tx.insert(DevDaycare(areaId = areaId))

tx.insert(
DevPerson(
firstName = "Kotikunnallinen",
municipalityOfResidence = "Säkkijärvi",
),
DevPersonType.CHILD,
)
.also { childId ->
tx.insert(
DevPlacement(
childId = childId,
unitId = unitId,
startDate = clock.today(),
endDate = clock.today(),
)
)
}

tx.insert(
DevPerson(firstName = "Kotikunnaton", municipalityOfResidence = ""),
DevPersonType.CHILD,
)
.also { childId ->
tx.insert(
DevPlacement(
childId = childId,
unitId = unitId,
startDate = clock.today(),
endDate = clock.today(),
)
)
}
}

val rows =
rawReportController.getRawReport(
dbInstance(),
user,
clock,
clock.today(),
clock.today(),
)

assertThat(rows)
.extracting({ it.firstName }, { it.municipalityOfResidence })
.containsExactlyInAnyOrder(
Tuple("Kotikunnallinen", "Säkkijärvi"),
Tuple("Kotikunnaton", ""),
)
}
}
2 changes: 2 additions & 0 deletions service/src/main/kotlin/fi/espoo/evaka/reports/RawReport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ SELECT
p.language,
p.postal_code,
p.post_office,
p.municipality_of_residence,
pl.type as placement_type,
Expand Down Expand Up @@ -218,4 +219,5 @@ data class RawReportRow(
val staffDimensioning: Int,
val isWeekday: Boolean,
val isHoliday: Boolean,
val municipalityOfResidence: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ INSERT INTO person (
social_security_number, email, verified_email, phone, language, street_address,
postal_code, post_office, residence_code, nationalities, restricted_details_enabled,
restricted_details_end_date, invoicing_street_address, invoicing_postal_code, invoicing_post_office,
updated_from_vtj, oph_person_oid, duplicate_of, disabled_email_types
updated_from_vtj, oph_person_oid, duplicate_of, disabled_email_types, municipality_of_residence
) VALUES (
${bind(p.id)}, ${bind(p.dateOfBirth)}, ${bind(p.dateOfDeath)}, ${bind(p.firstName)}, ${bind(p.lastName)}, ${bind(p.preferredName)},
${bind(p.ssn)}, ${bind(p.email)}, ${bind(p.verifiedEmail)}, ${bind(p.phone)}, ${bind(p.language)}, ${bind(p.streetAddress)},
${bind(p.postalCode)}, ${bind(p.postOffice)}, ${bind(p.residenceCode)}, ${bind(p.nationalities)}, ${bind(p.restrictedDetailsEnabled)},
${bind(p.restrictedDetailsEndDate)}, ${bind(p.invoicingStreetAddress)}, ${bind(p.invoicingPostalCode)}, ${bind(p.invoicingPostOffice)},
${bind(p.updatedFromVtj)}, ${bind(p.ophPersonOid)}, ${bind(p.duplicateOf)}, ${bind(p.disabledEmailTypes)}
${bind(p.updatedFromVtj)}, ${bind(p.ophPersonOid)}, ${bind(p.duplicateOf)}, ${bind(p.disabledEmailTypes)}, ${bind(p.municipalityOfResidence)}
)
RETURNING id
"""
Expand Down

0 comments on commit 0d1c320

Please sign in to comment.