Skip to content

Commit d8a9a2f

Browse files
Merge pull request #6975 from espoon-voltti/realization-report-fix
Korjataan päiväkohtaiset lapsen tule- ja lähtöajat raportti
2 parents 8948a69 + e55393e commit d8a9a2f

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

service/src/integrationTest/kotlin/fi/espoo/evaka/reports/AttendanceReservationReportTest.kt

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,121 @@ internal class AttendanceReservationReportTest : FullApplicationTest(resetDbBefo
15101510
assertThat(result).containsExactlyElementsOf(expected.values)
15111511
}
15121512

1513+
@Test
1514+
fun `Only include departed children with realization report`() {
1515+
val date = LocalDate.of(2020, 5, 28)
1516+
db.transaction { tx ->
1517+
val placementId =
1518+
tx.insert(
1519+
DevPlacement(
1520+
childId = testChild_1.id,
1521+
unitId = testDaycare.id,
1522+
startDate = date,
1523+
endDate = date,
1524+
)
1525+
)
1526+
tx.insert(
1527+
DevDaycareGroupPlacement(
1528+
daycarePlacementId = placementId,
1529+
daycareGroupId = testDaycareGroup.id,
1530+
startDate = date,
1531+
endDate = date,
1532+
)
1533+
)
1534+
tx.insert(
1535+
DevChildAttendance(
1536+
childId = testChild_1.id,
1537+
unitId = testDaycare.id,
1538+
date = date,
1539+
arrived = LocalTime.of(8, 0),
1540+
departed = LocalTime.of(8, 15),
1541+
)
1542+
)
1543+
1544+
val placementId2 =
1545+
tx.insert(
1546+
DevPlacement(
1547+
childId = testChild_2.id,
1548+
unitId = testDaycare.id,
1549+
startDate = date,
1550+
endDate = date,
1551+
)
1552+
)
1553+
tx.insert(
1554+
DevDaycareGroupPlacement(
1555+
daycarePlacementId = placementId2,
1556+
daycareGroupId = testDaycareGroup.id,
1557+
startDate = date,
1558+
endDate = date,
1559+
)
1560+
)
1561+
tx.insert(
1562+
DevChildAttendance(
1563+
childId = testChild_2.id,
1564+
unitId = testDaycare.id,
1565+
date = date,
1566+
arrived = LocalTime.of(8, 0),
1567+
departed = null,
1568+
)
1569+
)
1570+
tx.insert(
1571+
DevStaffAttendance(
1572+
employeeId = staff.id,
1573+
groupId = testDaycareGroup.id,
1574+
arrived = HelsinkiDateTime.of(date, LocalTime.of(8, 0)),
1575+
departed = HelsinkiDateTime.of(date, LocalTime.of(8, 30)),
1576+
modifiedAt = HelsinkiDateTime.of(date, LocalTime.of(8, 0)),
1577+
modifiedBy = admin.evakaUserId,
1578+
)
1579+
)
1580+
1581+
tx.insert(testDecisionMaker_2)
1582+
tx.insert(
1583+
DevStaffAttendance(
1584+
employeeId = testDecisionMaker_2.id,
1585+
groupId = testDaycareGroup.id,
1586+
arrived = HelsinkiDateTime.of(date, LocalTime.of(8, 0)),
1587+
departed = HelsinkiDateTime.of(date, LocalTime.of(8, 30)),
1588+
modifiedAt = HelsinkiDateTime.of(date, LocalTime.of(8, 0)),
1589+
modifiedBy = admin.evakaUserId,
1590+
occupancyCoefficient = BigDecimal.ZERO,
1591+
)
1592+
)
1593+
}
1594+
val result = getReport(date, date, reservationType = ReservationType.REALIZATION)
1595+
val expected =
1596+
createEmptyReport(date, date).also {
1597+
addExpectedRow(
1598+
it,
1599+
AttendanceReservationReportRow(
1600+
groupId = null,
1601+
groupName = null,
1602+
HelsinkiDateTime.of(LocalDate.of(2020, 5, 28), LocalTime.of(8, 0)),
1603+
childCountUnder3 = 1,
1604+
childCountOver3 = 0,
1605+
childCount = 1,
1606+
capacityFactor = 1.75,
1607+
staffCount = 1.0,
1608+
unknownChildCount = 0,
1609+
unknownChildCapacityFactor = 0.0,
1610+
),
1611+
AttendanceReservationReportRow(
1612+
groupId = null,
1613+
groupName = null,
1614+
HelsinkiDateTime.of(LocalDate.of(2020, 5, 28), LocalTime.of(8, 15)),
1615+
childCountUnder3 = 1,
1616+
childCountOver3 = 0,
1617+
childCount = 1,
1618+
capacityFactor = 1.75,
1619+
staffCount = 1.0,
1620+
unknownChildCount = 0,
1621+
unknownChildCapacityFactor = 0.0,
1622+
),
1623+
)
1624+
}
1625+
assertThat(result).containsExactlyElementsOf(expected.values)
1626+
}
1627+
15131628
private fun getReport(
15141629
startDate: LocalDate,
15151630
endDate: LocalDate,

service/src/main/kotlin/fi/espoo/evaka/reports/AttendanceReservationReportController.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ private fun Database.Read.getRealizations(
324324
SELECT child_id, date, start_time, end_time
325325
FROM child_attendance
326326
WHERE child_id = ANY(${bind(children)}) AND between_start_and_end(${bind(range)}, date)
327+
AND end_time IS NOT NULL
327328
"""
328329
)
329330
}

0 commit comments

Comments
 (0)