generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/pi 2158 mas get unpaid work time (#3741)
* PI-2158 return unpaid time worked Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update integration layer Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update service Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update tests Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update integration test and dataloader Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update service test Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 change minutes to hour calculation Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 amend logic Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 apply review comments to amend sql Signed-off-by: Amardeep Chimber <[email protected]> * Formatting changes * PI-2158 convert query from native to jpql Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 remove commented code Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 add more service test to cover unpaid work progress Signed-off-by: Amardeep Chimber <[email protected]> * Formatting changes * PI-2158 update service logic Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update service logic Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update service logic Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 add unpaid work progress to new section of sentence object Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 add unpaid work progress to new section of sentence object Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 refactor sql to no longer be a native query Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 refactor sql to no longer be a native query Signed-off-by: Amardeep Chimber <[email protected]> * Formatting changes * PI-2158 add scenario where no unpaid work has been completed Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 update integration test Signed-off-by: Amardeep Chimber <[email protected]> * Formatting changes * PI-2158 apply review comments Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 apply review comments Signed-off-by: Amardeep Chimber <[email protected]> * PI-2158 apply review comments Signed-off-by: Amardeep Chimber <[email protected]> --------- Signed-off-by: Amardeep Chimber <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d8258fa
commit d99fa85
Showing
9 changed files
with
398 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/UnpaidWorkApptGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator.ACTIVE_ORDER | ||
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.UpwAppointment | ||
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.UpwDetails | ||
|
||
object UnpaidWorkApptGenerator { | ||
|
||
val UNPAID_WORK_DETAILS_1 = UpwDetails(IdGenerator.getAndIncrement(), ACTIVE_ORDER, 0) | ||
|
||
val APPT1 = UpwAppointment(IdGenerator.getAndIncrement(), 3, "Y", 0, UNPAID_WORK_DETAILS_1) | ||
val APPT2 = UpwAppointment(IdGenerator.getAndIncrement(), 4, "Y", 1, UNPAID_WORK_DETAILS_1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/UpwAppointment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity | ||
|
||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Immutable | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Disposal | ||
|
||
@Entity | ||
@Immutable | ||
class UpwAppointment( | ||
@Id | ||
@Column(name = "upw_appointment_id") | ||
val id: Long, | ||
|
||
val minutesCredited: Long?, | ||
|
||
@Column(columnDefinition = "char(1)") | ||
val attended: String?, | ||
|
||
val softDeleted: Long, | ||
|
||
@JoinColumn(name = "upw_details_id") | ||
@ManyToOne | ||
val upwDetails: UpwDetails, | ||
) | ||
|
||
@Entity | ||
@Immutable | ||
class UpwDetails( | ||
@Id | ||
@Column(name = "upw_details_id") | ||
val id: Long, | ||
|
||
@JoinColumn(name = "disposal_id") | ||
@ManyToOne | ||
val disposal: Disposal, | ||
|
||
val softDeleted: Long, | ||
) | ||
|
||
interface UpwAppointmentRepository : JpaRepository<UpwAppointment, Long> { | ||
|
||
@Query( | ||
""" | ||
SELECT SUM(u.minutesCredited) | ||
FROM UpwAppointment u | ||
JOIN u.upwDetails upd | ||
JOIN upd.disposal d | ||
WHERE d.id = :id | ||
AND u.softDeleted = 0 | ||
""" | ||
) | ||
fun calculateUnpaidTimeWorked(id: Long): Long | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.