Skip to content

Commit

Permalink
BR-20 - Warning Details and Warning Type Changes
Browse files Browse the repository at this point in the history
BR-20 - Warning Details and Warning Type Changes
  • Loading branch information
peter-bcl authored Mar 5, 2025
1 parent c1ed16a commit 67f9aae
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ data class BreachNoticeEntity(
val breachNoticeRequirementList: List<BreachNoticeRequirementEntity> = emptyList(),
var optionalNumberChecked: Boolean? = null,
var optionalNumber: String? = null,
val conditionBeingEnforced: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.springframework.data.annotation.CreatedDate
import org.springframework.data.annotation.LastModifiedBy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.jpa.domain.support.AuditingEntityListener
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.*

Expand All @@ -29,6 +30,8 @@ data class BreachNoticeRequirementEntity(
val requirementTypeMainCategoryDescription: String? = null,
val requirementTypeSubCategoryDescription: String? = null,
val rejectionReason: String? = null,
val fromDate: LocalDate? = null,
val toDate: LocalDate? = null,
@CreatedBy
var createdByUser: String? = null,
@CreatedDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ data class BreachNotice(
val breachNoticeRequirementList: List<BreachNoticeRequirement> = emptyList(),
val optionalNumberChecked: Boolean? = null,
val optionalNumber: String? = null,
val conditionBeingEnforced: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class BreachNoticeDetails(
val titleAndFullName: String? = null,
val dateOfLetter: LocalDate? = null,
val referenceNumber: String? = null,
val responseRequiredByDate: LocalDate? = null,
val responseRequiredDate: LocalDate? = null,
val breachNoticeTypeCode: String? = null,
val breachNoticeTypeDescription: String? = null,
val breachConditionTypeCode: String? = null,
Expand Down Expand Up @@ -41,4 +41,5 @@ data class BreachNoticeDetails(
val breachNoticeRequirementList: List<BreachNoticeRequirement> = emptyList(),
val optionalNumberChecked: Boolean? = null,
val optionalNumber: String? = null,
val conditionBeingEnforced: String? = null,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.justice.digital.hmpps.breachnoticeapi.model

import java.time.LocalDate
import java.util.*

data class BreachNoticeRequirement(
Expand All @@ -8,6 +9,6 @@ data class BreachNoticeRequirement(
val requirementTypeMainCategoryDescription: String? = null,
val requirementTypeSubCategoryDescription: String? = null,
val rejectionReason: String? = null,
val fromDate: String? = null,
val toDate: String? = null,
val fromDate: LocalDate? = null,
val toDate: LocalDate? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class BreachNoticeService(
nextAppointmentSaved = nextAppointmentSaved,
useDefaultAddress = useDefaultAddress,
useDefaultReplyAddress = useDefaultReplyAddress,
conditionBeingEnforced = conditionBeingEnforced,
breachNoticeContactList = breachNoticeContactList.map {
it.toEntity(
existingEntity.breachNoticeContactList.find { existingContactEnitiy ->
Expand Down Expand Up @@ -160,6 +161,7 @@ class BreachNoticeService(
breachNoticeRequirementList = breachNoticeRequirementList.map { it.toModel() },
optionalNumberChecked = optionalNumberChecked,
optionalNumber = optionalNumber,
conditionBeingEnforced = conditionBeingEnforced,
)

fun getBreachNoticeById(uuid: UUID) = breachNoticeRepository.findById(uuid).getOrNull()?.let {
Expand All @@ -169,7 +171,7 @@ class BreachNoticeService(
titleAndFullName = it.titleAndFullName,
dateOfLetter = it.dateOfLetter,
referenceNumber = it.referenceNumber,
responseRequiredByDate = it.responseRequiredDate,
responseRequiredDate = it.responseRequiredDate,
breachNoticeTypeCode = it.breachNoticeTypeCode,
breachNoticeTypeDescription = it.breachNoticeTypeDescription,
breachConditionTypeCode = it.breachConditionTypeCode,
Expand All @@ -196,6 +198,7 @@ class BreachNoticeService(
breachNoticeRequirementList = it.breachNoticeRequirementList.map { it.toModel() },
optionalNumberChecked = it.optionalNumberChecked,
optionalNumber = it.optionalNumber,
conditionBeingEnforced = it.conditionBeingEnforced,
)
}

Expand Down Expand Up @@ -258,18 +261,24 @@ class BreachNoticeService(
requirementTypeMainCategoryDescription = requirementTypeMainCategoryDescription,
requirementTypeSubCategoryDescription = requirementTypeSubCategoryDescription,
rejectionReason = rejectionReason,
fromDate = fromDate,
toDate = toDate,
)

private fun BreachNoticeRequirement.toEntity(existingEntity: BreachNoticeRequirementEntity? = null) = existingEntity?.copy(
requirementId = requirementId,
requirementTypeMainCategoryDescription = requirementTypeMainCategoryDescription,
requirementTypeSubCategoryDescription = requirementTypeSubCategoryDescription,
rejectionReason = rejectionReason,
fromDate = fromDate,
toDate = toDate,
) ?: BreachNoticeRequirementEntity(
requirementId = requirementId,
requirementTypeMainCategoryDescription = requirementTypeMainCategoryDescription,
requirementTypeSubCategoryDescription = requirementTypeSubCategoryDescription,
rejectionReason = rejectionReason,
fromDate = fromDate,
toDate = toDate,
)

fun getBreachNoticeAsPdf(id: UUID, breachNoticeDetails: BreachNoticeDetails?, draft: Boolean): ByteArray? {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE public.breach_notice_requirement ADD from_date timestamp without time zone NULL;
ALTER TABLE public.breach_notice_requirement ADD to_date timestamp without time zone NULL;

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE public.breach_notice ADD condition_being_enforced varchar(200) NULL;
2 changes: 1 addition & 1 deletion src/main/resources/templates/NAT_Breach_Template.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
<p lang="en-US" class="western" align="justify" style="line-height: 100%; margin-bottom: 0cm">
<font face="Arial, serif"><span lang="en-GB">You must contact me
immediately to explain your reason (s) AND provide me with acceptable
supporting evidence for your breach, by <span th:text="${#temporals.format(breachNotice.responseRequiredByDate, 'dd/MM/yyyy')}">{responseDate}</span>. If
supporting evidence for your breach, by <span th:text="${#temporals.format(breachNotice.responseRequiredDate, 'dd/MM/yyyy')}">{responseDate}</span>. If
you do not provide me with an acceptable reason and acceptable
supporting evidence by this date, your failure to comply will remain
as a breach of this Order.</span></font></p>
Expand Down

0 comments on commit 67f9aae

Please sign in to comment.