From 177da8f08a12077fb786fd828fa856237d7e73da Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Tue, 31 Oct 2023 09:11:39 +0000 Subject: [PATCH 1/3] PI-1602 Save previous address after end-dating --- .../justice/digital/hmpps/integrations/delius/AddressService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt index 674e2fc6f9..8aaf3a5972 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt @@ -29,6 +29,7 @@ class AddressService( val previousStatus = referenceDataRepository.previousAddressStatus() currentMain.status = previousStatus currentMain.endDate = endDate + personAddressRepository.save(currentMain) } } From be996d25f72b38eff50b5ff52d6ef5116ee3706d Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Tue, 31 Oct 2023 09:30:14 +0000 Subject: [PATCH 2/3] PI-1602 Make AddressService transactional --- .../digital/hmpps/integrations/delius/AddressService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt index 8aaf3a5972..97cf28c5e9 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.integrations.approvedpremesis.PersonArrived import uk.gov.justice.digital.hmpps.integrations.delius.entity.AddressTypeCode import uk.gov.justice.digital.hmpps.integrations.delius.entity.Person @@ -14,6 +15,7 @@ import java.time.LocalDate import java.time.ZonedDateTime @Service +@Transactional class AddressService( private val personAddressRepository: PersonAddressRepository, private val referenceDataRepository: ReferenceDataRepository @@ -29,7 +31,6 @@ class AddressService( val previousStatus = referenceDataRepository.previousAddressStatus() currentMain.status = previousStatus currentMain.endDate = endDate - personAddressRepository.save(currentMain) } } From 75e904e8e320039e5790ac9565005031e6873eb6 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Tue, 31 Oct 2023 09:43:55 +0000 Subject: [PATCH 3/3] Remove unnecessary repository save --- .../justice/digital/hmpps/integrations/delius/AddressService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt index 97cf28c5e9..61f58dd123 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/AddressService.kt @@ -41,7 +41,6 @@ class AddressService( val previousStatus = referenceDataRepository.previousAddressStatus() currentMain.status = previousStatus currentMain.endDate = endDate.toLocalDate() - personAddressRepository.save(currentMain) } } }