Skip to content

Commit

Permalink
Added aromi customer id to raw report
Browse files Browse the repository at this point in the history
  • Loading branch information
tmkrepo committed Feb 26, 2025
1 parent 7122165 commit 6222d01
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 7 deletions.
6 changes: 4 additions & 2 deletions frontend/src/e2e-test/dev-api/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ export class Fixture {
startDate: LocalDate.of(2020, 1, 1),
endDate: null,
jamixCustomerNumber: null,
...initial
...initial,
aromiCustomerId: initial.aromiCustomerId ?? null
})
}

Expand Down Expand Up @@ -3144,7 +3145,8 @@ export const testDaycareGroup: DevDaycareGroup = {
name: 'Kosmiset vakiot',
startDate: LocalDate.of(2000, 1, 1),
endDate: null,
jamixCustomerNumber: null
jamixCustomerNumber: null,
aromiCustomerId: null
}

/**
Expand Down
1 change: 1 addition & 0 deletions frontend/src/e2e-test/generated/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export interface DevDaycareAssistance {
* Generated from fi.espoo.evaka.shared.dev.DevDaycareGroup
*/
export interface DevDaycareGroup {
aromiCustomerId: string | null
daycareId: DaycareId
endDate: LocalDate | null
id: GroupId
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/employee-frontend/components/reports/Raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ export default React.memo(function Raw() {
{ label: 'Poissa maksullisesta', key: 'absencePaid' },
{ label: 'Poissa maksuttomasta', key: 'absenceFree' },
{ label: 'Henkilöstömitoitus', key: 'staffDimensioning' },
{ label: 'Kotikunta', key: 'municipalityOfResidence' }
{ label: 'Kotikunta', key: 'municipalityOfResidence' },
{
label: 'Ryhmäkohtainen Aromin asiakastunniste',
key: 'aromiCustomerId'
}
]}
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 @@ -794,6 +794,7 @@ export interface RawReportRow {
absenceFree: AbsenceType | null
absencePaid: AbsenceType | null
age: number
aromiCustomerId: string | null
assistanceNeedVoucherCoefficient: number | null
backupGroupId: GroupId | null
backupUnitId: DaycareId | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import fi.espoo.evaka.FullApplicationTest
import fi.espoo.evaka.shared.auth.UserRole
import fi.espoo.evaka.shared.dev.DevCareArea
import fi.espoo.evaka.shared.dev.DevDaycare
import fi.espoo.evaka.shared.dev.DevDaycareGroup
import fi.espoo.evaka.shared.dev.DevDaycareGroupPlacement
import fi.espoo.evaka.shared.dev.DevEmployee
import fi.espoo.evaka.shared.dev.DevPerson
import fi.espoo.evaka.shared.dev.DevPersonType
Expand Down Expand Up @@ -163,4 +165,92 @@ class RawReportControllerTest : FullApplicationTest(resetDbBeforeEach = true) {
Tuple("Kotikunnaton", ""),
)
}

@Test
fun `aromi customer id 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
}
val testArea = DevCareArea()
val testUnit = DevDaycare(areaId = testArea.id)
val aromiGroup =
DevDaycareGroup(
daycareId = testUnit.id,
name = "Aromi group",
aromiCustomerId = "DAYCARE_PK",
)
db.transaction { tx ->
tx.insertServiceNeedOption(snDefaultDaycare)
tx.insert(testArea)
tx.insert(testUnit)

val nonAromiGroupId =
tx.insert(DevDaycareGroup(daycareId = testUnit.id, name = "Non-Aromi group"))

tx.insert(aromiGroup)

tx.insert(DevPerson(firstName = "Anselmi"), DevPersonType.CHILD).also { childId ->
val aromiPlacementId =
tx.insert(
DevPlacement(
childId = childId,
unitId = testUnit.id,
startDate = clock.today().minusYears(1),
endDate = clock.today().plusYears(1),
)
)
tx.insert(
DevDaycareGroupPlacement(
daycarePlacementId = aromiPlacementId,
daycareGroupId = aromiGroup.id,
startDate = clock.today().minusYears(1),
endDate = clock.today().plusYears(1),
)
)
}

tx.insert(DevPerson(firstName = "Benselmi"), DevPersonType.CHILD).also { childId ->
val nonAromiPlacementId =
tx.insert(
DevPlacement(
childId = childId,
unitId = testUnit.id,
startDate = clock.today().minusYears(1),
endDate = clock.today().plusYears(1),
)
)

tx.insert(
DevDaycareGroupPlacement(
daycarePlacementId = nonAromiPlacementId,
daycareGroupId = nonAromiGroupId,
startDate = clock.today().minusYears(1),
endDate = clock.today().plusYears(1),
)
)
}
}

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

assertThat(rows)
.extracting({ it.firstName }, { it.aromiCustomerId })
.containsExactlyInAnyOrder(
Tuple("Anselmi", aromiGroup.aromiCustomerId),
Tuple("Benselmi", null),
)
}
}
3 changes: 2 additions & 1 deletion service/src/main/kotlin/fi/espoo/evaka/reports/RawReport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ SELECT
coalesce(sn.part_week, false) AS part_week,
coalesce(sn.shift_care, 'NONE') = 'FULL' AS shift_care,
coalesce(sno.daycare_hours_per_week, 0.0) AS hours_per_week,
dg.aromi_customer_id,
(
an IS NOT NULL
OR EXISTS(SELECT FROM assistance_action aa WHERE aa.child_id = pl.child_id AND t::date BETWEEN aa.start_date AND aa.end_date)
Expand Down Expand Up @@ -220,4 +220,5 @@ data class RawReportRow(
val isWeekday: Boolean,
val isHoliday: Boolean,
val municipalityOfResidence: String,
val aromiCustomerId: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ fun Database.Transaction.insert(row: DevDaycareGroup): GroupId =
createUpdate {
sql(
"""
INSERT INTO daycare_group (id, daycare_id, name, start_date, end_date, jamix_customer_number)
VALUES (${bind(row.id)}, ${bind(row.daycareId)}, ${bind(row.name)}, ${bind(row.startDate)}, ${bind(row.endDate)}, ${bind(row.jamixCustomerNumber)})
INSERT INTO daycare_group (id, daycare_id, name, start_date, end_date, jamix_customer_number, aromi_customer_id)
VALUES (${bind(row.id)}, ${bind(row.daycareId)}, ${bind(row.name)}, ${bind(row.startDate)}, ${bind(row.endDate)}, ${bind(row.jamixCustomerNumber)}, ${bind(row.aromiCustomerId)})
"""
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ data class DevDaycareGroup(
val startDate: LocalDate = LocalDate.of(2019, 1, 1),
val endDate: LocalDate? = null,
val jamixCustomerNumber: Int? = null,
val aromiCustomerNumber: String? = null,
val aromiCustomerId: String? = null,
)

data class DevDaycareGroupPlacement(
Expand Down

0 comments on commit 6222d01

Please sign in to comment.