-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate manage income evidence stored procedure #130
Merged
karlbaker02
merged 3 commits into
main
from
karlb/lcam-1404-migrate-manage-income-evidence
Oct 28, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions
31
...nce/src/main/java/uk/gov/justice/laa/crime/evidence/builder/UpdateEvidenceDTOBuilder.java
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,31 @@ | ||
package uk.gov.justice.laa.crime.evidence.builder; | ||
|
||
import java.math.BigDecimal; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import uk.gov.justice.laa.crime.common.model.evidence.ApiUpdateIncomeEvidenceRequest; | ||
import uk.gov.justice.laa.crime.evidence.dto.UpdateEvidenceDTO; | ||
|
||
@Component | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class UpdateEvidenceDTOBuilder { | ||
|
||
public static UpdateEvidenceDTO build(final ApiUpdateIncomeEvidenceRequest request) { | ||
return UpdateEvidenceDTO.builder() | ||
.financialAssessmentId(request.getFinancialAssessmentId()) | ||
.magCourtOutcome(request.getMagCourtOutcome()) | ||
.applicantDetails(request.getApplicantEvidenceItems() != null ? request.getApplicantEvidenceItems().getApplicantDetails() : null) | ||
.applicantPensionAmount(request.getApplicantPensionAmount() != null ? request.getApplicantPensionAmount() : BigDecimal.ZERO) | ||
.applicationReceivedDate(request.getMetadata().getApplicationReceivedDate()) | ||
.partnerDetails(request.getPartnerEvidenceItems() != null ? request.getPartnerEvidenceItems().getApplicantDetails() : null) | ||
.partnerPensionAmount(request.getPartnerPensionAmount() != null ? request.getPartnerPensionAmount() : BigDecimal.ZERO) | ||
.applicantIncomeEvidenceItems(request.getApplicantEvidenceItems() != null ? request.getApplicantEvidenceItems().getIncomeEvidenceItems() : null) | ||
.partnerIncomeEvidenceItems(request.getPartnerEvidenceItems() != null ? request.getPartnerEvidenceItems().getIncomeEvidenceItems() : null) | ||
.evidencePending(request.getMetadata().getEvidencePending()) | ||
.evidenceDueDate(request.getEvidenceDueDate()) | ||
.evidenceReceivedDate(request.getEvidenceReceivedDate()) | ||
.previousEvidenceDueDate(request.getPreviousEvidenceDueDate()) | ||
.build(); | ||
} | ||
} |
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
23 changes: 0 additions & 23 deletions
23
crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/dto/EvidenceDTO.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...idence/src/main/java/uk/gov/justice/laa/crime/evidence/dto/EvidenceReceivedResultDTO.java
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,14 @@ | ||
package uk.gov.justice.laa.crime.evidence.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@AllArgsConstructor | ||
@Data | ||
@Builder | ||
public class EvidenceReceivedResultDTO { | ||
private boolean evidenceReceived; | ||
private int incomeEvidenceRequiredId; | ||
private int minimumEvidenceItemsRequired; | ||
} |
29 changes: 29 additions & 0 deletions
29
crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/dto/UpdateEvidenceDTO.java
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,29 @@ | ||
package uk.gov.justice.laa.crime.evidence.dto; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import uk.gov.justice.laa.crime.common.model.evidence.ApiApplicantDetails; | ||
import uk.gov.justice.laa.crime.common.model.evidence.ApiIncomeEvidence; | ||
import uk.gov.justice.laa.crime.enums.MagCourtOutcome; | ||
|
||
@Data | ||
@Builder | ||
public class UpdateEvidenceDTO { | ||
private int financialAssessmentId; | ||
private List<ApiIncomeEvidence> applicantIncomeEvidenceItems; | ||
private List<ApiIncomeEvidence> partnerIncomeEvidenceItems; | ||
private MagCourtOutcome magCourtOutcome; | ||
private ApiApplicantDetails applicantDetails; | ||
private ApiApplicantDetails partnerDetails; | ||
private BigDecimal applicantPensionAmount; | ||
private BigDecimal partnerPensionAmount; | ||
private LocalDate applicationReceivedDate; | ||
private boolean evidencePending; | ||
private LocalDateTime evidenceDueDate; | ||
private LocalDateTime evidenceReceivedDate; | ||
private LocalDateTime previousEvidenceDueDate; | ||
} |
12 changes: 12 additions & 0 deletions
12
...va/uk/gov/justice/laa/crime/evidence/repository/IncomeEvidenceRequiredItemRepository.java
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,12 @@ | ||
package uk.gov.justice.laa.crime.evidence.repository; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import uk.gov.justice.laa.crime.evidence.staticdata.entity.IncomeEvidenceRequiredItemEntity; | ||
import uk.gov.justice.laa.crime.evidence.staticdata.projection.IncomeEvidenceRequiredItemProjection; | ||
|
||
@Repository | ||
public interface IncomeEvidenceRequiredItemRepository extends JpaRepository<IncomeEvidenceRequiredItemEntity, Integer> { | ||
List<IncomeEvidenceRequiredItemProjection> findByIncomeEvidenceRequiredId(Integer id); | ||
} |
32 changes: 32 additions & 0 deletions
32
...n/java/uk/gov/justice/laa/crime/evidence/repository/IncomeEvidenceRequiredRepository.java
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,32 @@ | ||
package uk.gov.justice.laa.crime.evidence.repository; | ||
|
||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
import uk.gov.justice.laa.crime.evidence.staticdata.entity.IncomeEvidenceRequiredEntity; | ||
|
||
@Repository | ||
public interface IncomeEvidenceRequiredRepository extends CrudRepository<IncomeEvidenceRequiredEntity, String> { | ||
@Query( | ||
value = | ||
""" | ||
select ID, | ||
EVIDENCE_ITEMS_REQUIRED | ||
from income_evidence_required i | ||
where mcoo_outcome = ?1 | ||
and applicant_EMST_CODE = ?2 | ||
and ((partner_emst_code is null and ?3 is null) or (partner_emst_code = ?3)) | ||
and I.APPLICANT_PARTNER = ?4 | ||
and I.ANNUAL_PENSION_AMOUNT <= nvl(?5,0) | ||
and not exists (select 1 | ||
from income_evidence_required i2 | ||
where i2.mcoo_outcome = ?1 | ||
and i2.applicant_EMST_CODE = ?2 | ||
and ((i2.partner_emst_code is null and ?3 is null) or (i2.partner_emst_code = ?3)) | ||
and I2.APPLICANT_PARTNER = ?4 | ||
and i2.ANNUAL_PENSION_AMOUNT <= nvl(?5,0) | ||
and i2.ANNUAL_PENSION_AMOUNT > I.ANNUAL_PENSION_AMOUNT) | ||
""", | ||
nativeQuery = true) | ||
IncomeEvidenceRequiredEntity getNumberOfEvidenceItemsRequired(String mcooOutcome, String applicantEmstCode, String partnerEmstCode, String applicantPartner, Double annualPensionAmount); | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good candidate for adding some indexes to the DB for - imagine it's slow to run!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be, I didn't check if it has any indexes already but this is the same query that's currently in one of the nested stored procedures, so should at least be no worse than it currently is.