From d5f054bf3345591a9646664d4281b6dbc6d96515 Mon Sep 17 00:00:00 2001 From: David Pitkin Date: Fri, 13 Dec 2024 16:27:25 -0800 Subject: [PATCH 01/11] PIM-1839: Updated endpoint, service method and factory for UwContractRsrc to load other year policies. --- .../client/v1/CirrasUnderwritingService.java | 2 +- .../impl/CirrasUnderwritingServiceImpl.java | 4 +- .../api/rest/v1/resource/UwContractRsrc.java | 11 ++++ .../rest/v1/endpoints/UwContractEndpoint.java | 4 +- .../impl/UwContractEndpointImpl.java | 4 +- .../factory/UwContractRsrcFactory.java | 56 +++++++++++++++--- .../v1/endpoints/UwContractEndpointTest.java | 12 ++-- .../endpoints/UwContractListEndpointTest.java | 4 +- .../model/v1/OtherYearPolicy.java | 58 +++++++++++++++++++ .../underwriting/model/v1/UwContract.java | 3 + .../api/v1/CirrasUnderwritingService.java | 2 + .../impl/CirrasUnderwritingServiceImpl.java | 14 ++++- .../v1/model/factory/UwContractFactory.java | 3 + .../api/v1/util/InventoryServiceEnums.java | 8 +++ 14 files changed, 164 insertions(+), 21 deletions(-) create mode 100644 cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/OtherYearPolicy.java diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/CirrasUnderwritingService.java b/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/CirrasUnderwritingService.java index 3e1996e4..dbb23480 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/CirrasUnderwritingService.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/CirrasUnderwritingService.java @@ -87,7 +87,7 @@ UwContractListRsrc getUwContractList( Integer pageNumber, Integer pageRowCount) throws CirrasUnderwritingServiceException; - UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies) throws CirrasUnderwritingServiceException; + UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies, String loadOtherYearPolicies, String screenType) throws CirrasUnderwritingServiceException; ////////////////////////////////////////////////////// // Annual Fields diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/impl/CirrasUnderwritingServiceImpl.java b/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/impl/CirrasUnderwritingServiceImpl.java index 0fe08a34..1d7eaa82 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/impl/CirrasUnderwritingServiceImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-client/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/client/v1/impl/CirrasUnderwritingServiceImpl.java @@ -297,7 +297,7 @@ public UwContractListRsrc getUwContractList( } @Override - public UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies) throws CirrasUnderwritingServiceException { + public UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies, String loadOtherYearPolicies, String screenType) throws CirrasUnderwritingServiceException { GenericRestDAO dao = this.getRestDAOFactory().getGenericRestDAO(UwContractRsrc.class); @@ -305,6 +305,8 @@ public UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPo Map queryParams = new HashMap(); putQueryParam(queryParams, "loadLinkedPolicies", loadLinkedPolicies); + putQueryParam(queryParams, "loadOtherYearPolicies", loadOtherYearPolicies); + putQueryParam(queryParams, "screenType", screenType); Response response = dao.Process(ResourceTypes.SELF, this.getTransformer(), resource, queryParams, getWebClient()); diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/UwContractRsrc.java b/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/UwContractRsrc.java index 2fff982c..873d87c0 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/UwContractRsrc.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/UwContractRsrc.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.types.ResourceTypes; +import ca.bc.gov.mal.cirras.underwriting.model.v1.OtherYearPolicy; import ca.bc.gov.mal.cirras.underwriting.model.v1.UwContract; import ca.bc.gov.nrs.common.wfone.rest.resource.BaseResource; @@ -51,6 +52,8 @@ public class UwContractRsrc extends BaseResource implements UwContract linkedPolicies = new ArrayList(); + private List otherYearPolicies = new ArrayList(); + public Integer getContractId() { return contractId; } @@ -253,5 +256,13 @@ public List getLinkedPolicies() { public void setLinkedPolicies(List linkedPolicies) { this.linkedPolicies = linkedPolicies; } + + public List getOtherYearPolicies() { + return otherYearPolicies; + } + + public void setOtherYearPolicies(List otherYearPolicies) { + this.otherYearPolicies = otherYearPolicies; + } } diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpoint.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpoint.java index 16d84cb8..520765d8 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpoint.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpoint.java @@ -45,6 +45,8 @@ public interface UwContractEndpoint extends BaseEndpoints { @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response getUwContract( @Parameter(description = "The Policy ID of the uw contract.") @PathParam("policyId") String policyId, - @Parameter(description = "True if linked policies should be included in the returned resource, False if not") @QueryParam("loadLinkedPolicies") String loadLinkedPolicies + @Parameter(description = "True if linked policies should be included in the returned resource, False if not") @QueryParam("loadLinkedPolicies") String loadLinkedPolicies, + @Parameter(description = "True if other year policies should be included in the returned resource, False if not") @QueryParam("loadOtherYearPolicies") String loadOtherYearPolicies, + @Parameter(description = "The screen type for which other year policies should be loaded: INVENTORY, DOP or VERIFIED") @QueryParam("screenType") String screenType ); } diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/impl/UwContractEndpointImpl.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/impl/UwContractEndpointImpl.java index d3aebb19..75c301c3 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/impl/UwContractEndpointImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/impl/UwContractEndpointImpl.java @@ -29,7 +29,7 @@ public class UwContractEndpointImpl extends BaseEndpointsImpl implements UwContr private CirrasUnderwritingService cirrasUnderwritingService; @Override - public Response getUwContract(final String policyId, String loadLinkedPolicies) { + public Response getUwContract(final String policyId, String loadLinkedPolicies, String loadOtherYearPolicies, String screenType) { Response response = null; @@ -43,6 +43,8 @@ public Response getUwContract(final String policyId, String loadLinkedPolicies) UwContractRsrc result = (UwContractRsrc) cirrasUnderwritingService.getUwContract( toInteger(policyId), toBoolean(loadLinkedPolicies), + toBoolean(loadOtherYearPolicies), + toString(screenType), getFactoryContext(), getWebAdeAuthentication()); response = Response.ok(result).tag(result.getUnquotedETag()).build(); diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/UwContractRsrcFactory.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/UwContractRsrcFactory.java index 89cc388f..444deff4 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/UwContractRsrcFactory.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/UwContractRsrcFactory.java @@ -41,6 +41,7 @@ import ca.bc.gov.mal.cirras.underwriting.model.v1.AnnualField; import ca.bc.gov.mal.cirras.underwriting.model.v1.Field; import ca.bc.gov.mal.cirras.underwriting.model.v1.LegalLand; +import ca.bc.gov.mal.cirras.underwriting.model.v1.OtherYearPolicy; import ca.bc.gov.mal.cirras.underwriting.model.v1.PolicySimple; import ca.bc.gov.mal.cirras.underwriting.model.v1.RemoveFieldValidation; import ca.bc.gov.mal.cirras.underwriting.model.v1.RenameLegalValidation; @@ -52,6 +53,7 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.PolicyDto; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.model.factory.UwContractFactory; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.InventoryServiceEnums; +import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.InventoryServiceEnums.ScreenType; public class UwContractRsrcFactory extends BaseResourceFactory implements UwContractFactory { @@ -87,7 +89,7 @@ public UwContractList>> getUwContra populateResource(resource, dto); - setSelfLink(dto.getPolicyId(), false, resource, baseUri); + setSelfLink(dto.getPolicyId(), false, false, null, resource, baseUri); setLinks(resource, baseUri, authentication); resources.add(resource); @@ -146,7 +148,10 @@ public UwContractList>> getUwContra public UwContract> getUwContract( PolicyDto dto, List linkedPolicyDtos, + List otherYearPolicyDtos, Boolean loadLinkedPolicies, + Boolean loadOtherYearPolicies, + String screenType, FactoryContext context, WebAdeAuthentication authentication ) throws FactoryException { @@ -165,7 +170,7 @@ public UwContract> getUwContract( UwContractRsrc linkedPolicyModel = new UwContractRsrc(); populateResource(linkedPolicyModel, lpDto); - setSelfLink(lpDto.getPolicyId(), false, linkedPolicyModel, baseUri); + setSelfLink(lpDto.getPolicyId(), false, false, null, linkedPolicyModel, baseUri); setLinks(linkedPolicyModel, baseUri, authentication); linkedPoliciesModel.add(linkedPolicyModel); @@ -173,12 +178,23 @@ public UwContract> getUwContract( resource.setLinkedPolicies(linkedPoliciesModel); } - + + // Other Year Policies + if ( otherYearPolicyDtos != null && !otherYearPolicyDtos.isEmpty() ) { + List otherYearPoliciesModel = new ArrayList(); + + for (PolicyDto pDto : otherYearPolicyDtos) { + OtherYearPolicy otherYearPolicyModel = createOtherYearPolicy(pDto, screenType); + otherYearPoliciesModel.add(otherYearPolicyModel); + } + + resource.setOtherYearPolicies(otherYearPoliciesModel); + } String eTag = getEtag(resource); resource.setETag(eTag); - setSelfLink(dto.getPolicyId(), loadLinkedPolicies, resource, baseUri); + setSelfLink(dto.getPolicyId(), loadLinkedPolicies, loadOtherYearPolicies, screenType, resource, baseUri); setLinks(resource, baseUri, authentication); return resource; @@ -214,19 +230,45 @@ private void populateResource(UwContractRsrc resource, PolicyDto dto) { // growerProvince } + + private OtherYearPolicy createOtherYearPolicy(PolicyDto dto, String screenType) { + + OtherYearPolicy model = new OtherYearPolicy(); + + model.setCropYear(dto.getCropYear()); + model.setInsurancePlanId(dto.getInsurancePlanId()); + model.setPolicyId(dto.getPolicyId()); + model.setPolicyNumber(dto.getPolicyNumber()); + + if ( ScreenType.INVENTORY.name().equals(screenType) ) { + model.setScreenRecordGuid(dto.getInventoryContractGuid()); + } else if ( ScreenType.DOP.name().equals(screenType) ) { + model.setScreenRecordGuid(dto.getDeclaredYieldContractGuid()); + } else if ( ScreenType.VERIFIED.name().equals(screenType) ) { + model.setScreenRecordGuid(dto.getVerifiedYieldContractGuid()); + } else { + throw new FactoryException("Invalid value for screenType: " + screenType); + } + + model.setScreenType(screenType); + + return model; + } - static void setSelfLink(Integer policyId, Boolean loadLinkedPolicies, UwContractRsrc resource, URI baseUri) { + static void setSelfLink(Integer policyId, Boolean loadLinkedPolicies, Boolean loadOtherYearPolicies, String screenType, UwContractRsrc resource, URI baseUri) { if (policyId != null) { - String selfUri = getUwContractSelfUri(policyId, loadLinkedPolicies, baseUri); + String selfUri = getUwContractSelfUri(policyId, loadLinkedPolicies, loadOtherYearPolicies, screenType, baseUri); resource.getLinks().add(new RelLink(ResourceTypes.SELF, selfUri, "GET")); } } - public static String getUwContractSelfUri(Integer policyId, Boolean loadLinkedPolicies, URI baseUri) { + public static String getUwContractSelfUri(Integer policyId, Boolean loadLinkedPolicies, Boolean loadOtherYearPolicies, String screenType, URI baseUri) { String result = UriBuilder .fromUri(baseUri) .path(UwContractEndpoint.class) .queryParam("loadLinkedPolicies", nvl(toString(loadLinkedPolicies), "")) + .queryParam("loadOtherYearPolicies", nvl(toString(loadOtherYearPolicies), "")) + .queryParam("screenType", nvl(screenType, "")) .build(policyId).toString(); return result; } diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java index ad3c6918..3bb0e4b0 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java @@ -280,7 +280,7 @@ public void testGetUwContract() throws CirrasUnderwritingServiceException, Oauth Assert.assertEquals(1, searchResults.getCollection().size()); UwContractRsrc referrer = searchResults.getCollection().get(0); - UwContractRsrc fetchedResource = service.getUwContract(referrer, "false"); + UwContractRsrc fetchedResource = service.getUwContract(referrer, "false", "false", null); Assert.assertNotNull(fetchedResource); Assert.assertEquals(contractNumber, fetchedResource.getContractNumber()); @@ -349,7 +349,7 @@ public void testGetUwContractLoadLinkedPolicies() throws CirrasUnderwritingServi UwContractRsrc referrer = searchResults.getCollection().get(0); // Test: No linked policies exist. - UwContractRsrc fetchedResource = service.getUwContract(referrer, "true"); + UwContractRsrc fetchedResource = service.getUwContract(referrer, "true", "false", null); Assert.assertNotNull(fetchedResource); Assert.assertEquals(policyNumber1, fetchedResource.getPolicyNumber()); checkUwContractList(fetchedResource.getLinkedPolicies()); @@ -358,13 +358,13 @@ public void testGetUwContractLoadLinkedPolicies() throws CirrasUnderwritingServi createPolicy(policyId2, growerId1, 5, policyNumber2, contractNumber2, contractId2, 2020, createTransactionDate); // A. loadLinkedPolicies param is false. - fetchedResource = service.getUwContract(referrer, "false"); + fetchedResource = service.getUwContract(referrer, "false", "false", null); Assert.assertNotNull(fetchedResource); Assert.assertEquals(policyNumber1, fetchedResource.getPolicyNumber()); checkUwContractList(fetchedResource.getLinkedPolicies()); // B. loadLinkedPolicies param is true. - fetchedResource = service.getUwContract(referrer, "true"); + fetchedResource = service.getUwContract(referrer, "true", "false", null); Assert.assertNotNull(fetchedResource); Assert.assertEquals(policyNumber1, fetchedResource.getPolicyNumber()); checkUwContractList(fetchedResource.getLinkedPolicies(), policyId2); @@ -384,7 +384,7 @@ public void testGetUwContractLoadLinkedPolicies() throws CirrasUnderwritingServi createGrowerContractYear(growerContractYearId2, contractId2, growerId2, 2020, 5, createTransactionDate); createContractedFieldDetail(contractedFieldDetailId2, annualFieldDetailId1, growerContractYearId2, 1); - fetchedResource = service.getUwContract(referrer, "true"); + fetchedResource = service.getUwContract(referrer, "true", "false", null); Assert.assertNotNull(fetchedResource); Assert.assertEquals(policyNumber1, fetchedResource.getPolicyNumber()); checkUwContractList(fetchedResource.getLinkedPolicies(), policyId2); @@ -454,7 +454,7 @@ public void testUwContractDopEligibleInventory() throws CirrasUnderwritingServic Assert.assertEquals(policyNumber, referrer.getPolicyNumber()); Assert.assertEquals("Eligible Inventory 1", eligibleInventory, referrer.getTotalDopEligibleInventory()); - UwContractRsrc fetchedResource = service.getUwContract(referrer, "false"); + UwContractRsrc fetchedResource = service.getUwContract(referrer, "false", "false", null); Assert.assertNotNull(fetchedResource); Assert.assertEquals(policyNumber, fetchedResource.getPolicyNumber()); diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractListEndpointTest.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractListEndpointTest.java index 84a7e90a..3cf2b45d 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractListEndpointTest.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractListEndpointTest.java @@ -646,7 +646,7 @@ public void testTotalDopEligibleInventory() throws Exception { Assert.assertEquals(0, searchResults.getCollection().get(0).getTotalDopEligibleInventory().intValue()); // B: Fetch - 0 - UwContractRsrc uwContract = service.getUwContract(searchResults.getCollection().get(0), "false"); + UwContractRsrc uwContract = service.getUwContract(searchResults.getCollection().get(0), "false", "false", null); Assert.assertEquals(0, uwContract.getTotalDopEligibleInventory().intValue()); // C: Select - 1 @@ -670,7 +670,7 @@ public void testTotalDopEligibleInventory() throws Exception { Assert.assertEquals(1, searchResults.getCollection().get(0).getTotalDopEligibleInventory().intValue()); // D: Fetch - 1 - uwContract = service.getUwContract(searchResults.getCollection().get(0), "false"); + uwContract = service.getUwContract(searchResults.getCollection().get(0), "false", "false", null); Assert.assertEquals(1, uwContract.getTotalDopEligibleInventory().intValue()); diff --git a/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/OtherYearPolicy.java b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/OtherYearPolicy.java new file mode 100644 index 00000000..4084b242 --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/OtherYearPolicy.java @@ -0,0 +1,58 @@ +package ca.bc.gov.mal.cirras.underwriting.model.v1; + +import java.io.Serializable; + +public class OtherYearPolicy implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer policyId; + private Integer insurancePlanId; + private String policyNumber; + private Integer cropYear; + private String screenRecordGuid; + private String screenType; + + + public Integer getPolicyId() { + return policyId; + } + public void setPolicyId(Integer policyId) { + this.policyId = policyId; + } + + public Integer getInsurancePlanId() { + return insurancePlanId; + } + public void setInsurancePlanId(Integer insurancePlanId) { + this.insurancePlanId = insurancePlanId; + } + + public String getPolicyNumber() { + return policyNumber; + } + public void setPolicyNumber(String policyNumber) { + this.policyNumber = policyNumber; + } + + public Integer getCropYear() { + return cropYear; + } + public void setCropYear(Integer cropYear) { + this.cropYear = cropYear; + } + + public String getScreenRecordGuid() { + return screenRecordGuid; + } + public void setScreenRecordGuid(String screenRecordGuid) { + this.screenRecordGuid = screenRecordGuid; + } + + public String getScreenType() { + return screenType; + } + public void setScreenType(String screenType) { + this.screenType = screenType; + } + +} diff --git a/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UwContract.java b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UwContract.java index b1bee697..bcc887ae 100644 --- a/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UwContract.java +++ b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UwContract.java @@ -79,5 +79,8 @@ public interface UwContract> extends Serializable { public List getLinkedPolicies(); public void setLinkedPolicies(List linkedPolicies); + + public List getOtherYearPolicies(); + public void setOtherYearPolicies(List otherYearPolicies); } diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/CirrasUnderwritingService.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/CirrasUnderwritingService.java index 0e76c8a6..2efd7102 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/CirrasUnderwritingService.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/CirrasUnderwritingService.java @@ -36,6 +36,8 @@ UwContractList>> getUwContractList( UwContract> getUwContract( Integer policyId, Boolean loadLinkedPolicies, + Boolean loadOtherYearPolicies, + String screenType, FactoryContext factoryContext, WebAdeAuthentication authentication ) diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java index c7701ea4..4053fd8a 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java @@ -157,7 +157,12 @@ public UwContractList>> getUwContra @Override - public UwContract> getUwContract(Integer policyId, Boolean loadLinkedPolicies, FactoryContext factoryContext, WebAdeAuthentication authentication) + public UwContract> getUwContract(Integer policyId, + Boolean loadLinkedPolicies, + Boolean loadOtherYearPolicies, + String screenType, + FactoryContext factoryContext, + WebAdeAuthentication authentication) throws ServiceException, NotFoundException { logger.debug("> getUwContract(Integer policyId, Boole linkedPolicyDtos = linkedPolicyResultDtos.getResults(); } - result = uwContractFactory.getUwContract(dto, linkedPolicyDtos, loadLinkedPolicies, factoryContext, authentication); + List otherYearPolicyDtos = null; + if ( Boolean.TRUE.equals(loadOtherYearPolicies) ) { + // TODO: Load OtherYearPolicies. + } + + result = uwContractFactory.getUwContract(dto, linkedPolicyDtos, otherYearPolicyDtos, loadLinkedPolicies, loadOtherYearPolicies, screenType, factoryContext, authentication); } catch (DaoException e) { throw new ServiceException("DAO threw an exception", e); diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/model/factory/UwContractFactory.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/model/factory/UwContractFactory.java index 78e18fce..18b9b367 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/model/factory/UwContractFactory.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/model/factory/UwContractFactory.java @@ -44,7 +44,10 @@ UwContractList>> getUwContractList( UwContract> getUwContract( PolicyDto dto, List linkedPolicyDtos, + List otherYearPolicyDtos, Boolean loadLinkedPolicies, + Boolean loadOtherYearPolicies, + String screenType, FactoryContext context, WebAdeAuthentication authentication ) throws FactoryException; diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/util/InventoryServiceEnums.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/util/InventoryServiceEnums.java index 63a7c5ba..f7133f92 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/util/InventoryServiceEnums.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/util/InventoryServiceEnums.java @@ -60,4 +60,12 @@ public enum InventoryReportType { unseeded, seeded; } + + // Valid options for screenType parameter for GET UwContractRsrc. + public enum ScreenType { + INVENTORY, + DOP, + VERIFIED; + } + } From 179ee4a0737e922aad38976676a286321546436f Mon Sep 17 00:00:00 2001 From: David Pitkin Date: Mon, 16 Dec 2024 16:40:54 -0800 Subject: [PATCH 02/11] PIM-1839: Added persistence layer for loading otherYearPolicies. --- .../persistence/v1/dao/PolicyDao.java | 6 + .../v1/dao/mybatis/PolicyDaoImpl.java | 70 +++++++- .../v1/dao/mybatis/mapper/PolicyMapper.java | 6 + .../v1/dao/mybatis/mapper/PolicyMapper.xml | 154 ++++++++++++++++++ .../impl/CirrasUnderwritingServiceImpl.java | 14 +- 5 files changed, 248 insertions(+), 2 deletions(-) diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDao.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDao.java index 16d71f1d..6b58706c 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDao.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDao.java @@ -50,6 +50,12 @@ List selectByFieldAndYear( Integer fieldId, Integer cropYear ) throws DaoException; + + List selectByOtherYearInventory(Integer contractId, Integer currentCropYear, Integer numYears) throws DaoException; + + List selectByOtherYearDop(Integer contractId, Integer currentCropYear, Integer numYears) throws DaoException; + + List selectByOtherYearVerified(Integer contractId, Integer currentCropYear, Integer numYears) throws DaoException; String cleanGrowerPhoneNumber(String growerInfo); diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/PolicyDaoImpl.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/PolicyDaoImpl.java index 90c9d41a..67b33171 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/PolicyDaoImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/PolicyDaoImpl.java @@ -138,7 +138,75 @@ public List selectByFieldAndYear(Integer fieldId, Integer cropYear) t logger.debug(">selectByFieldAndYear " + dtos); return dtos; } - + + @Override + public List selectByOtherYearInventory(Integer contractId, Integer currentCropYear, Integer numYears) throws DaoException { + + logger.debug(" dtos = null; + + try { + Map parameters = new HashMap(); + parameters.put("contractId", contractId); + parameters.put("currentCropYear", currentCropYear); + parameters.put("numYears", numYears); + + dtos = this.mapper.selectByOtherYearInventory(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">selectByOtherYearInventory " + dtos); + return dtos; + } + + @Override + public List selectByOtherYearDop(Integer contractId, Integer currentCropYear, Integer numYears) throws DaoException { + logger.debug(" dtos = null; + + try { + Map parameters = new HashMap(); + parameters.put("contractId", contractId); + parameters.put("currentCropYear", currentCropYear); + parameters.put("numYears", numYears); + + dtos = this.mapper.selectByOtherYearDop(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">selectByOtherYearDop " + dtos); + return dtos; + } + + @Override + public List selectByOtherYearVerified(Integer contractId, Integer currentCropYear, Integer numYears) throws DaoException { + logger.debug(" dtos = null; + + try { + Map parameters = new HashMap(); + parameters.put("contractId", contractId); + parameters.put("currentCropYear", currentCropYear); + parameters.put("numYears", numYears); + + dtos = this.mapper.selectByOtherYearVerified(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">selectByOtherYearVerified " + dtos); + return dtos; + } + + @Override public PagedDtos select( Integer cropYear, diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.java index 013a5031..cf284fdd 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.java @@ -20,4 +20,10 @@ public interface PolicyMapper { List select(Map parameters); List selectByFieldAndYear(Map parameters); + + List selectByOtherYearInventory(Map parameters); + + List selectByOtherYearDop(Map parameters); + + List selectByOtherYearVerified(Map parameters); } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.xml b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.xml index 367ec22a..16d41ef5 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.xml +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/PolicyMapper.xml @@ -151,6 +151,160 @@ AND afd.crop_year = #{cropYear} ORDER BY p.policy_number + + + + + + + diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java index 4053fd8a..f0d40405 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasUnderwritingServiceImpl.java @@ -28,6 +28,7 @@ import ca.bc.gov.mal.cirras.underwriting.service.api.v1.model.factory.AnnualFieldFactory; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.model.factory.UwContractFactory; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.UnderwritingServiceHelper; +import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.InventoryServiceEnums.ScreenType; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.OutOfSync; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.validation.ModelValidator; @@ -59,6 +60,9 @@ public class CirrasUnderwritingServiceImpl implements CirrasUnderwritingService public static final int DefaultMaximumResults = 800; + // Number of past or future years to search when loading UwContract.otherYearPolicies. + public static final Integer numOtherYearPoliciesToLoad = 5; + public void setUnderwritingServiceHelper(UnderwritingServiceHelper underwritingServiceHelper) { this.underwritingServiceHelper = underwritingServiceHelper; } @@ -197,7 +201,15 @@ public UwContract> getUwContract(Integer policyId, List otherYearPolicyDtos = null; if ( Boolean.TRUE.equals(loadOtherYearPolicies) ) { - // TODO: Load OtherYearPolicies. + if ( ScreenType.INVENTORY.name().equals(screenType) ) { + otherYearPolicyDtos = policyDao.selectByOtherYearInventory(dto.getContractId(), dto.getCropYear(), numOtherYearPoliciesToLoad); + } else if ( ScreenType.DOP.name().equals(screenType) ) { + otherYearPolicyDtos = policyDao.selectByOtherYearDop(dto.getContractId(), dto.getCropYear(), numOtherYearPoliciesToLoad); + } else if ( ScreenType.VERIFIED.name().equals(screenType) ) { + otherYearPolicyDtos = policyDao.selectByOtherYearVerified(dto.getContractId(), dto.getCropYear(), numOtherYearPoliciesToLoad); + } else { + throw new ServiceException("Invalid value for screenType: " + screenType); + } } result = uwContractFactory.getUwContract(dto, linkedPolicyDtos, otherYearPolicyDtos, loadLinkedPolicies, loadOtherYearPolicies, screenType, factoryContext, authentication); From c05ccee68c5a34c424cd2e52251b5609735445b6 Mon Sep 17 00:00:00 2001 From: David Pitkin Date: Tue, 17 Dec 2024 16:34:20 -0800 Subject: [PATCH 03/11] PIM-1839: Added persistence unit tests. --- .../persistence/v1/dao/PolicyDaoTest.java | 568 +++++++++++++++++- 1 file changed, 567 insertions(+), 1 deletion(-) diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDaoTest.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDaoTest.java index 4905bfa3..dd7dcabb 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDaoTest.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/PolicyDaoTest.java @@ -21,11 +21,14 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContactEmailDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContactPhoneDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContractedFieldDetailDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.DeclaredYieldContractDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.FieldDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.GrowerContactDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.GrowerContractYearDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.GrowerDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventoryContractDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.PolicyDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.spring.PersistenceSpringConfig; import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; @@ -46,12 +49,29 @@ public class PolicyDaoTest { private String policyNumber1 = "998877-20"; private String contractNumber1 = "998877"; private Integer gcyId1 = 90000003; + private Integer cropYear1 = 2020; + private Integer policyId2 = 90000004; private Integer contractId2 = 90000005; private String policyNumber2 = "998899-20"; private String contractNumber2 = "998899"; private Integer gcyId2 = 90000006; + private Integer cropYear2 = 2020; + + private Integer policyId3 = 90000017; + private Integer contractId3 = 90000018; + private String policyNumber3 = "998866-20"; + private String contractNumber3 = "998866"; + private Integer gcyId3 = 90000019; + private Integer cropYear3 = 2020; + + private Integer policyId4 = 90000020; + private Integer contractId4 = 90000021; + private String policyNumber4 = "998855-20"; + private String contractNumber4 = "998855"; + private Integer gcyId4 = 90000022; + private Integer cropYear4 = 2020; private Integer growerId1 = 90000007; private Integer growerId2 = 90000008; @@ -70,20 +90,36 @@ public class PolicyDaoTest { @Before public void prepareTests() throws NotFoundDaoException, DaoException{ delete(); + resetTestDefaults(); } @After public void cleanUp() throws NotFoundDaoException, DaoException{ delete(); + resetTestDefaults(); } private void delete() throws NotFoundDaoException, DaoException { + deleteVerifiedYieldContract(gcyId1); + deleteVerifiedYieldContract(gcyId2); + deleteVerifiedYieldContract(gcyId3); + deleteVerifiedYieldContract(gcyId4); + deleteDeclaredYieldContract(gcyId1); + deleteDeclaredYieldContract(gcyId2); + deleteDeclaredYieldContract(gcyId3); + deleteDeclaredYieldContract(gcyId4); + deleteInventoryContract(gcyId1); + deleteInventoryContract(gcyId2); + deleteInventoryContract(gcyId3); + deleteInventoryContract(gcyId4); deleteContractedFieldDetail(cfdId1); deleteContractedFieldDetail(cfdId2); deleteGrowerContractYear(gcyId1); deleteGrowerContractYear(gcyId2); + deleteGrowerContractYear(gcyId3); + deleteGrowerContractYear(gcyId4); deleteAnnualFieldDetail(afdId); deleteField(fieldId); deleteGrowerContact(growerContactId1); @@ -93,10 +129,31 @@ private void delete() throws NotFoundDaoException, DaoException { deletePolicy(policyId); deletePolicy(policyId1); deletePolicy(policyId2); + deletePolicy(policyId3); + deletePolicy(policyId4); deleteGrower(growerId1); deleteGrower(growerId2); } + // Some tests modify these members so they have different contract numbers or crop years + // than the defaults. This resets them afterward. + private void resetTestDefaults() { + contractId2 = 90000005; + policyNumber2 = "998899-20"; + contractNumber2 = "998899"; + cropYear2 = 2020; + + contractId3 = 90000018; + policyNumber3 = "998866-20"; + contractNumber3 = "998866"; + cropYear3 = 2020; + + contractId4 = 90000021; + policyNumber4 = "998855-20"; + contractNumber4 = "998855"; + cropYear4 = 2020; + } + private void deletePolicy(Integer policyId) throws NotFoundDaoException, DaoException{ PolicyDao dao = persistenceSpringConfig.policyDao(); @@ -180,6 +237,30 @@ private void deleteGrowerContractYear(Integer growerContractYearId) throws DaoEx } } + private void deleteInventoryContract(Integer gcyId) throws NotFoundDaoException, DaoException { + InventoryContractDao dao = persistenceSpringConfig.inventoryContractDao(); + InventoryContractDto dto = dao.getByGrowerContract(gcyId); + if ( dto != null ) { + dao.delete(dto.getInventoryContractGuid()); + } + } + + private void deleteDeclaredYieldContract(Integer gcyId) throws NotFoundDaoException, DaoException { + DeclaredYieldContractDao dao = persistenceSpringConfig.declaredYieldContractDao(); + DeclaredYieldContractDto dto = dao.getByGrowerContract(gcyId); + if ( dto != null ) { + dao.delete(dto.getDeclaredYieldContractGuid()); + } + } + + private void deleteVerifiedYieldContract(Integer gcyId) throws NotFoundDaoException, DaoException { + VerifiedYieldContractDao dao = persistenceSpringConfig.verifiedYieldContractDao(); + VerifiedYieldContractDto dto = dao.getByGrowerContract(gcyId); + if ( dto != null ) { + dao.delete(dto.getVerifiedYieldContractGuid()); + } + } + private void createField(Integer fieldId, String fieldLabel) throws DaoException { String userId = "JUNIT_TEST"; @@ -435,12 +516,85 @@ private void createPolicy( policyDto.setContractId(contractId); policyDto.setCropYear(cropYear); policyDto.setDataSyncTransDate(transDate); - + //INSERT policyDao.insert(policyDto, userId); } + private String createInventoryContract(Integer contractId, Integer cropYear, String userId) throws DaoException { + + //Date without time + Date date = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant()); + + InventoryContractDao invContractDao = persistenceSpringConfig.inventoryContractDao(); + + // Create parent InventoryContract. + InventoryContractDto invContractDto = new InventoryContractDto(); + + invContractDto.setContractId(contractId); + invContractDto.setCropYear(cropYear); + invContractDto.setFertilizerInd(false); + invContractDto.setGrainFromPrevYearInd(false); + invContractDto.setHerbicideInd(false); + invContractDto.setOtherChangesComment(null); + invContractDto.setOtherChangesInd(false); + invContractDto.setSeededCropReportSubmittedInd(false); + invContractDto.setTilliageInd(false); + invContractDto.setUnseededIntentionsSubmittedInd(false); + invContractDto.setInvUpdateTimestamp(date); + invContractDto.setInvUpdateUser(userId); + + invContractDao.insert(invContractDto, userId); + + return invContractDto.getInventoryContractGuid(); + } + + private String createDeclaredYieldContract(Integer contractId, Integer cropYear, String userId) throws DaoException { + + // Create parent Declared Yield Contract. + Calendar cal = Calendar.getInstance(); + cal.clear(); + cal.set(2020, Calendar.JANUARY, 15); + Date dopDate = cal.getTime(); + + DeclaredYieldContractDao dao = persistenceSpringConfig.declaredYieldContractDao(); + + DeclaredYieldContractDto newDto = new DeclaredYieldContractDto(); + + newDto.setContractId(contractId); + newDto.setCropYear(cropYear); + newDto.setDeclarationOfProductionDate(dopDate); + newDto.setDefaultYieldMeasUnitTypeCode("TONNE"); + newDto.setEnteredYieldMeasUnitTypeCode("BUSHEL"); + newDto.setGrainFromOtherSourceInd(false); + newDto.setBalerWagonInfo(null); + newDto.setTotalLivestock(null); + + //INSERT + dao.insert(newDto, userId); + return newDto.getDeclaredYieldContractGuid(); + + } + + private String createVerifiedYieldContract(Integer contractId, Integer cropYear, String declaredYieldContractGuid, String userId) throws DaoException { + + VerifiedYieldContractDao dao = persistenceSpringConfig.verifiedYieldContractDao(); + + VerifiedYieldContractDto newDto = new VerifiedYieldContractDto(); + + newDto.setContractId(contractId); + newDto.setCropYear(cropYear); + newDto.setDeclaredYieldContractGuid(declaredYieldContractGuid); + newDto.setDefaultYieldMeasUnitTypeCode("TONNE"); + newDto.setInsurancePlanId(4); + + //INSERT + dao.insert(newDto, userId); + return newDto.getVerifiedYieldContractGuid(); + } + + @Test public void testInsertUpdateDeletePolicy() throws Exception { @@ -1095,7 +1249,419 @@ public void testSelectByFieldAndYear() throws Exception { } + @Test + public void testSelectByOtherYearInventory() throws Exception { + + String userId = "JUNIT_TEST"; + + PolicyDao dao = persistenceSpringConfig.policyDao(); + + createGrower(growerId1, 999888, "grower name"); + createPolicy(policyId1, growerId1, contractId1, cropYear1, policyNumber1, contractNumber1, 4, "ACTIVE", 1); + createGrowerContractYear(gcyId1, contractId1, growerId1, cropYear1, 4); + String invContractGuid1 = createInventoryContract(contractId1, cropYear1, userId); + + // Test: No other years. + List dtos = dao.selectByOtherYearInventory(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + + // Test: Other prev years, but no inventory. + cropYear2 = 2019; + contractId2 = contractId1; + contractNumber2 = contractNumber1; + policyNumber2 = contractNumber2 + "-19"; + + cropYear3 = 2018; + contractId3 = contractId1; + contractNumber3 = contractNumber1; + policyNumber3 = contractNumber3 + "-18"; + + cropYear4 = 2017; + contractId4 = contractId1; + contractNumber4 = contractNumber1; + policyNumber4 = contractNumber4 + "-17"; + + createPolicy(policyId2, growerId1, contractId2, cropYear2, policyNumber2, contractNumber2, 4, "ACTIVE", 1); + createPolicy(policyId3, growerId1, contractId3, cropYear3, policyNumber3, contractNumber3, 4, "ACTIVE", 1); + createPolicy(policyId4, growerId1, contractId4, cropYear4, policyNumber4, contractNumber4, 4, "ACTIVE", 1); + + createGrowerContractYear(gcyId2, contractId2, growerId1, cropYear2, 4); + createGrowerContractYear(gcyId3, contractId3, growerId1, cropYear3, 4); + createGrowerContractYear(gcyId4, contractId4, growerId1, cropYear4, 4); + + dtos = dao.selectByOtherYearInventory(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + + // Test: One year with inventory. + String invContractGuid2 = createInventoryContract(contractId2, cropYear2, userId); + + dtos = dao.selectByOtherYearInventory(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(1, dtos.size()); + PolicyDto dto = dtos.get(0); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid2, dto.getInventoryContractGuid()); + + + // Test: All prev years with inventory. + String invContractGuid3 = createInventoryContract(contractId3, cropYear3, userId); + String invContractGuid4 = createInventoryContract(contractId4, cropYear4, userId); + + dtos = dao.selectByOtherYearInventory(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid3, dto.getInventoryContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid2, dto.getInventoryContractGuid()); + + // Test: prev and future years with inventory. + dtos = dao.selectByOtherYearInventory(contractId2, cropYear2, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(3, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId4, dto.getPolicyId()); + Assert.assertEquals(policyNumber4, dto.getPolicyNumber()); + Assert.assertEquals(contractId4, dto.getContractId()); + Assert.assertEquals(cropYear4, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid4, dto.getInventoryContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid3, dto.getInventoryContractGuid()); + + dto = dtos.get(2); + Assert.assertEquals(policyId1, dto.getPolicyId()); + Assert.assertEquals(policyNumber1, dto.getPolicyNumber()); + Assert.assertEquals(contractId1, dto.getContractId()); + Assert.assertEquals(cropYear1, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid1, dto.getInventoryContractGuid()); + + // Test: future years with inventory. + dtos = dao.selectByOtherYearInventory(contractId4, cropYear4, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid3, dto.getInventoryContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(invContractGuid2, dto.getInventoryContractGuid()); + } + + @Test + public void testSelectByOtherYearDop() throws Exception { + + String userId = "JUNIT_TEST"; + + PolicyDao dao = persistenceSpringConfig.policyDao(); + + createGrower(growerId1, 999888, "grower name"); + createPolicy(policyId1, growerId1, contractId1, cropYear1, policyNumber1, contractNumber1, 4, "ACTIVE", 1); + createGrowerContractYear(gcyId1, contractId1, growerId1, cropYear1, 4); + String dyContractGuid1 = createDeclaredYieldContract(contractId1, cropYear1, userId); + + // Test: No other years. + List dtos = dao.selectByOtherYearDop(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + + // Test: Other prev years, but no inventory. + cropYear2 = 2019; + contractId2 = contractId1; + contractNumber2 = contractNumber1; + policyNumber2 = contractNumber2 + "-19"; + + cropYear3 = 2018; + contractId3 = contractId1; + contractNumber3 = contractNumber1; + policyNumber3 = contractNumber3 + "-18"; + + cropYear4 = 2017; + contractId4 = contractId1; + contractNumber4 = contractNumber1; + policyNumber4 = contractNumber4 + "-17"; + + createPolicy(policyId2, growerId1, contractId2, cropYear2, policyNumber2, contractNumber2, 4, "ACTIVE", 1); + createPolicy(policyId3, growerId1, contractId3, cropYear3, policyNumber3, contractNumber3, 4, "ACTIVE", 1); + createPolicy(policyId4, growerId1, contractId4, cropYear4, policyNumber4, contractNumber4, 4, "ACTIVE", 1); + + createGrowerContractYear(gcyId2, contractId2, growerId1, cropYear2, 4); + createGrowerContractYear(gcyId3, contractId3, growerId1, cropYear3, 4); + createGrowerContractYear(gcyId4, contractId4, growerId1, cropYear4, 4); + + dtos = dao.selectByOtherYearDop(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + + // Test: One year with dop. + String dyContractGuid2 = createDeclaredYieldContract(contractId2, cropYear2, userId); + + dtos = dao.selectByOtherYearDop(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(1, dtos.size()); + + PolicyDto dto = dtos.get(0); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid2, dto.getDeclaredYieldContractGuid()); + + + // Test: All prev years with inventory. + String dyContractGuid3 = createDeclaredYieldContract(contractId3, cropYear3, userId); + String dyContractGuid4 = createDeclaredYieldContract(contractId4, cropYear4, userId); + + dtos = dao.selectByOtherYearDop(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid3, dto.getDeclaredYieldContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid2, dto.getDeclaredYieldContractGuid()); + + // Test: prev and future years with inventory. + dtos = dao.selectByOtherYearDop(contractId2, cropYear2, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(3, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId4, dto.getPolicyId()); + Assert.assertEquals(policyNumber4, dto.getPolicyNumber()); + Assert.assertEquals(contractId4, dto.getContractId()); + Assert.assertEquals(cropYear4, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid4, dto.getDeclaredYieldContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid3, dto.getDeclaredYieldContractGuid()); + + dto = dtos.get(2); + Assert.assertEquals(policyId1, dto.getPolicyId()); + Assert.assertEquals(policyNumber1, dto.getPolicyNumber()); + Assert.assertEquals(contractId1, dto.getContractId()); + Assert.assertEquals(cropYear1, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid1, dto.getDeclaredYieldContractGuid()); + + // Test: future years with dop. + dtos = dao.selectByOtherYearDop(contractId4, cropYear4, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid3, dto.getDeclaredYieldContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(dyContractGuid2, dto.getDeclaredYieldContractGuid()); + } + + @Test + public void testSelectByOtherYearVerified() throws Exception { + + String userId = "JUNIT_TEST"; + + PolicyDao dao = persistenceSpringConfig.policyDao(); + + createGrower(growerId1, 999888, "grower name"); + createPolicy(policyId1, growerId1, contractId1, cropYear1, policyNumber1, contractNumber1, 4, "ACTIVE", 1); + createGrowerContractYear(gcyId1, contractId1, growerId1, cropYear1, 4); + String dyContractGuid1 = createDeclaredYieldContract(contractId1, cropYear1, userId); + String verContractGuid1 = createVerifiedYieldContract(contractId1, cropYear1, dyContractGuid1, userId); + + // Test: No other years. + List dtos = dao.selectByOtherYearVerified(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + + // Test: Other prev years, but no verified yield. + cropYear2 = 2019; + contractId2 = contractId1; + contractNumber2 = contractNumber1; + policyNumber2 = contractNumber2 + "-19"; + + cropYear3 = 2018; + contractId3 = contractId1; + contractNumber3 = contractNumber1; + policyNumber3 = contractNumber3 + "-18"; + + cropYear4 = 2017; + contractId4 = contractId1; + contractNumber4 = contractNumber1; + policyNumber4 = contractNumber4 + "-17"; + + createPolicy(policyId2, growerId1, contractId2, cropYear2, policyNumber2, contractNumber2, 4, "ACTIVE", 1); + createPolicy(policyId3, growerId1, contractId3, cropYear3, policyNumber3, contractNumber3, 4, "ACTIVE", 1); + createPolicy(policyId4, growerId1, contractId4, cropYear4, policyNumber4, contractNumber4, 4, "ACTIVE", 1); + + createGrowerContractYear(gcyId2, contractId2, growerId1, cropYear2, 4); + createGrowerContractYear(gcyId3, contractId3, growerId1, cropYear3, 4); + createGrowerContractYear(gcyId4, contractId4, growerId1, cropYear4, 4); + + dtos = dao.selectByOtherYearVerified(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + + // Test: One year with verified yield. + String dyContractGuid2 = createDeclaredYieldContract(contractId2, cropYear2, userId); + String verContractGuid2 = createVerifiedYieldContract(contractId2, cropYear2, dyContractGuid2, userId); + + dtos = dao.selectByOtherYearVerified(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(1, dtos.size()); + + PolicyDto dto = dtos.get(0); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid2, dto.getVerifiedYieldContractGuid()); + + + // Test: All prev years with verified yield. + String dyContractGuid3 = createDeclaredYieldContract(contractId3, cropYear3, userId); + String dyContractGuid4 = createDeclaredYieldContract(contractId4, cropYear4, userId); + + String verContractGuid3 = createVerifiedYieldContract(contractId3, cropYear3, dyContractGuid3, userId); + String verContractGuid4 = createVerifiedYieldContract(contractId4, cropYear4, dyContractGuid4, userId); + + dtos = dao.selectByOtherYearVerified(contractId1, cropYear1, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid3, dto.getVerifiedYieldContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid2, dto.getVerifiedYieldContractGuid()); + + // Test: prev and future years with inventory. + dtos = dao.selectByOtherYearVerified(contractId2, cropYear2, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(3, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId4, dto.getPolicyId()); + Assert.assertEquals(policyNumber4, dto.getPolicyNumber()); + Assert.assertEquals(contractId4, dto.getContractId()); + Assert.assertEquals(cropYear4, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid4, dto.getVerifiedYieldContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid3, dto.getVerifiedYieldContractGuid()); + + dto = dtos.get(2); + Assert.assertEquals(policyId1, dto.getPolicyId()); + Assert.assertEquals(policyNumber1, dto.getPolicyNumber()); + Assert.assertEquals(contractId1, dto.getContractId()); + Assert.assertEquals(cropYear1, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid1, dto.getVerifiedYieldContractGuid()); + + // Test: future years with verified yield. + dtos = dao.selectByOtherYearVerified(contractId4, cropYear4, 2); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + dto = dtos.get(0); + Assert.assertEquals(policyId3, dto.getPolicyId()); + Assert.assertEquals(policyNumber3, dto.getPolicyNumber()); + Assert.assertEquals(contractId3, dto.getContractId()); + Assert.assertEquals(cropYear3, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid3, dto.getVerifiedYieldContractGuid()); + + dto = dtos.get(1); + Assert.assertEquals(policyId2, dto.getPolicyId()); + Assert.assertEquals(policyNumber2, dto.getPolicyNumber()); + Assert.assertEquals(contractId2, dto.getContractId()); + Assert.assertEquals(cropYear2, dto.getCropYear()); + Assert.assertEquals(Integer.valueOf(4), dto.getInsurancePlanId()); + Assert.assertEquals(verContractGuid2, dto.getVerifiedYieldContractGuid()); + } + private void compareStrings(String sortDirection) { //First iteration of loop: previousValue = 0 if(previousStringValue != ""){ From 9a8dbe371c4165cd07b69c61bcbf60095d06b47a Mon Sep 17 00:00:00 2001 From: dpitk2222 <168222245+dpitk2222@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:56:55 -0800 Subject: [PATCH 04/11] Update openshift-create-update-db.yml to manually install oc. --- .github/workflows/openshift-create-update-db.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/openshift-create-update-db.yml b/.github/workflows/openshift-create-update-db.yml index c6c3ef4a..d3dd21d3 100644 --- a/.github/workflows/openshift-create-update-db.yml +++ b/.github/workflows/openshift-create-update-db.yml @@ -59,6 +59,10 @@ jobs: chmod 700 get_helm.sh ./get_helm.sh + #Explicit install of oc cli tool + - name: Install oc + uses: redhat-actions/oc-installer@v1 + - name: Authenticate and set context uses: redhat-actions/oc-login@v1 with: From 27975a1d5149ca7918c6d359c01b3b69203e74ae Mon Sep 17 00:00:00 2001 From: Vividsolutions/esnauffer Date: Wed, 18 Dec 2024 10:32:31 -0800 Subject: [PATCH 05/11] PIM-1831: Create Dropdown to select another year while in a specific policy - Frontend --- .../grower-contract-header.component.html | 3 +- .../other-year-policy.component.html | 12 ++++ .../other-year-policy.component.scss | 32 +++++++++++ .../other-year-policy.component.ts | 55 +++++++++++++++++++ .../app/conversion/conversion-from-rest.ts | 3 +- .../main/angular/src/app/conversion/models.ts | 12 +++- 6 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html create mode 100644 cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss create mode 100644 cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html index 8db8e514..35cf53d3 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html @@ -101,7 +101,8 @@ {{ (growerContract && growerContract.policyNumber) ? growerContract.policyNumber : "" }}
- {{ (growerContract && growerContract.cropYear) ? growerContract.cropYear : "" }} + +
{{ (growerContract && growerContract.growerPrimaryEmail) ? growerContract.growerPrimaryEmail : "" }} diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html new file mode 100644 index 00000000..56562145 --- /dev/null +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html @@ -0,0 +1,12 @@ + +
+ + + {{ option.description }} + + +
+ diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss new file mode 100644 index 00000000..6676edf8 --- /dev/null +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss @@ -0,0 +1,32 @@ +@import '../../../styles/variables'; + +.other-year-policy{ + + .mat-mdc-text-field-wrapper { + width: 100px; + height: 36px; + padding-left: 6px; + border: 0.5px solid rgba(194, 194, 194, 1) !important; + border-radius: 5px !important; + } + + .mat-mdc-form-field-flex { + width: 50px; + height: 36px; + + } + + .mat-mdc-form-field-infix { + width: 505px !important; + min-height: 36px; + } + + .mat-mdc-select{ + font-family: $font-family-main; + } + + .mdc-text-field--outlined .mat-mdc-form-field-infix { + padding-top: 7px; + } + +} \ No newline at end of file diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts new file mode 100644 index 00000000..74a68553 --- /dev/null +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts @@ -0,0 +1,55 @@ +import { ChangeDetectionStrategy, Component, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core'; +import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; +import { Router } from '@angular/router'; +import { SecurityUtilService } from 'src/app/services/security-util.service'; + +@Component({ + selector: 'other-year-policy', + templateUrl: './other-year-policy.component.html', + styleUrl: './other-year-policy.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, +}) +export class OtherYearPolicyComponent implements OnInit, OnChanges { + + // Input() OtherYearPolicy? or growerContract? + cropYearOptions = []; + + otherYearPoliciesForm: UntypedFormGroup; + + constructor( + private fb: UntypedFormBuilder, + protected router: Router, + public securityUtilService: SecurityUtilService + ) { } + + ngOnInit(): void { + // initialize the form + this.otherYearPoliciesForm = this.fb.group({ + cropYear: [""], + }) + } + + ngOnChanges(changes: SimpleChanges) { + + // // populate crop year dropdown + // if (changes.growerContract && + // this.growerContract && + // this.growerContract.linkedPolicies + // ) { + + // this.populateCropYears(); + // } + } + + populateCropYears(){ + + // add a general info choice + this.cropYearOptions.push ({ + description: "2024", + value: "2024" + }) + + } + +} diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/conversion-from-rest.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/conversion-from-rest.ts index 766c25b0..3d50fa9a 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/conversion-from-rest.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/conversion-from-rest.ts @@ -124,7 +124,8 @@ export function convertToUwContract(uwContract: any): UwContract { totalDopEligibleInventory: uwContract.totalDopEligibleInventory, linkedPolicies: uwContract.linkedPolicies, - + otherYearPolicies: uwContract.otherYearPolicies, + isSelectedForPrint: false, etag: uwContract.etag, diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/models.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/models.ts index ff54847b..4c4521af 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/models.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/conversion/models.ts @@ -51,7 +51,8 @@ export interface UwContract { isSelectedForPrint?: boolean; linkedPolicies? : Array; - + otherYearPolicies?: Array; + etag?: string; type?: string; } @@ -238,3 +239,12 @@ export interface Field { etag?: string; type: string; } + +export interface OtherYearPolicy { + policyId?: number; + insurancePlanId?: number ; + policyNumber?: string; + cropYear?: number; + screenRecordGuid?: string; + screenType?: string; + } From 2cbd5578f65efbb63405698e2cb6a516b41f9ff8 Mon Sep 17 00:00:00 2001 From: dpitk2222 <168222245+dpitk2222@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:37:56 -0800 Subject: [PATCH 06/11] Update openshift-create-update-db.yml with run-name. --- .github/workflows/openshift-create-update-db.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/openshift-create-update-db.yml b/.github/workflows/openshift-create-update-db.yml index d3dd21d3..a64c6ff6 100644 --- a/.github/workflows/openshift-create-update-db.yml +++ b/.github/workflows/openshift-create-update-db.yml @@ -1,4 +1,5 @@ name: Openshift DB deploy/update +run-name: Deploy PostgresCluster to ${{ inputs.ENVIRONMENT_NAME}} on: workflow_dispatch: From db54d73a4aee99dfa3ca4bc4941350f078699b64 Mon Sep 17 00:00:00 2001 From: Vividsolutions/esnauffer Date: Wed, 18 Dec 2024 13:19:04 -0800 Subject: [PATCH 07/11] PIM-1842: Modify the New Seeded Crop Report - Align Top and Bottom Portions - Jasper --- .../resources/reports/CUWS_Seeded_Grain.jrxml | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/resources/reports/CUWS_Seeded_Grain.jrxml b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/resources/reports/CUWS_Seeded_Grain.jrxml index 10c44aa7..e1e1f2d2 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/resources/reports/CUWS_Seeded_Grain.jrxml +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/resources/reports/CUWS_Seeded_Grain.jrxml @@ -396,11 +396,11 @@ order by sort_column, - + - + @@ -408,7 +408,7 @@ order by sort_column, - + @@ -416,7 +416,7 @@ order by sort_column, - + @@ -428,7 +428,7 @@ order by sort_column, - + @@ -446,7 +446,7 @@ order by sort_column, - + @@ -455,7 +455,7 @@ order by sort_column, - + @@ -473,8 +473,10 @@ order by sort_column, - + + + @@ -482,7 +484,7 @@ order by sort_column, - + @@ -500,8 +502,9 @@ order by sort_column, - + + @@ -509,7 +512,7 @@ order by sort_column, - + @@ -527,7 +530,7 @@ order by sort_column, - + @@ -536,7 +539,7 @@ order by sort_column, - + @@ -547,7 +550,7 @@ order by sort_column, - + @@ -565,7 +568,7 @@ order by sort_column, - + @@ -574,7 +577,7 @@ order by sort_column, - + @@ -592,7 +595,7 @@ order by sort_column, - + @@ -601,13 +604,13 @@ order by sort_column, - + - + @@ -625,7 +628,7 @@ order by sort_column, - + @@ -637,7 +640,7 @@ order by sort_column, - + @@ -654,7 +657,7 @@ order by sort_column, - + @@ -665,12 +668,12 @@ order by sort_column, - + - + @@ -681,12 +684,12 @@ order by sort_column, - + - + @@ -697,12 +700,12 @@ order by sort_column, - + - + @@ -713,7 +716,7 @@ order by sort_column, - + @@ -724,19 +727,19 @@ order by sort_column, - + - + - + @@ -747,13 +750,13 @@ order by sort_column, - + - + @@ -765,7 +768,7 @@ order by sort_column, - + @@ -777,7 +780,7 @@ order by sort_column, - + @@ -853,7 +856,7 @@ order by sort_column, - + @@ -869,7 +872,7 @@ order by sort_column, - + From 2a9ac22de3547f14476d4cd461cb2f4bf4f1426b Mon Sep 17 00:00:00 2001 From: Michael Hostettler Date: Wed, 18 Dec 2024 16:49:47 -0800 Subject: [PATCH 08/11] PIM-1807: Implementing data load of verified yield summary --- .../resource/VerifiedYieldContractRsrc.java | 9 + .../VerifiedYieldContractRsrcFactory.java | 48 +++ .../model/v1/VerifiedYieldSummary.java | 143 +++++++ .../v1/dao/UnderwritingCommentDao.java | 6 + .../v1/dao/VerifiedYieldSummaryDao.java | 24 ++ .../mybatis/UnderwritingCommentDaoImpl.java | 63 +++- .../mybatis/VerifiedYieldSummaryDaoImpl.java | 169 +++++++++ .../mapper/UnderwritingCommentMapper.java | 6 + .../mapper/VerifiedYieldSummaryMapper.java | 22 ++ .../v1/dto/UnderwritingCommentDto.java | 12 + .../v1/dto/VerifiedYieldContractDto.java | 16 + .../v1/dto/VerifiedYieldSummaryDto.java | 263 +++++++++++++ .../v1/spring/PersistenceSpringConfig.java | 7 + .../mapper/UnderwritingCommentMapper.xml | 22 +- .../mapper/VerifiedYieldSummaryMapper.xml | 135 +++++++ .../v1/dao/UnderwritingCommentDaoTest.java | 202 +++++++++- .../v1/dao/VerifiedYieldSummaryDaoTest.java | 350 ++++++++++++++++++ .../impl/CirrasVerifiedYieldServiceImpl.java | 32 +- .../api/v1/spring/ServiceApiSpringConfig.java | 2 + .../00/cirras.cuws.03_06_00_00.dml.json | 3 +- ....insert.underwriting_comment_type_code.sql | 21 ++ 21 files changed, 1549 insertions(+), 6 deletions(-) create mode 100644 cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/VerifiedYieldSummary.java create mode 100644 cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDao.java create mode 100644 cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/VerifiedYieldSummaryDaoImpl.java create mode 100644 cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.java create mode 100644 cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldSummaryDto.java create mode 100644 cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.xml create mode 100644 cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDaoTest.java create mode 100644 cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/dml/cuws.insert.underwriting_comment_type_code.sql diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/VerifiedYieldContractRsrc.java b/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/VerifiedYieldContractRsrc.java index d4dccb42..88e319c9 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/VerifiedYieldContractRsrc.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-common/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/VerifiedYieldContractRsrc.java @@ -13,6 +13,7 @@ import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldAmendment; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContract; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContractCommodity; +import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldSummary; import ca.bc.gov.nrs.common.wfone.rest.resource.BaseResource; import ca.bc.gov.nrs.common.wfone.rest.resource.MessageRsrc; @@ -38,6 +39,7 @@ public class VerifiedYieldContractRsrc extends BaseResource implements VerifiedY private List fields = new ArrayList(); private List verifiedYieldContractCommodities = new ArrayList(); private List verifiedYieldAmendments = new ArrayList(); + private List verifiedYieldSummaries = new ArrayList(); private List productWarningMessages = new ArrayList(); public String getVerifiedYieldContractGuid() { @@ -132,6 +134,13 @@ public void setVerifiedYieldAmendments(List verifiedYiel this.verifiedYieldAmendments = verifiedYieldAmendments; } + public List getVerifiedYieldSummaries() { + return verifiedYieldSummaries; + } + public void setVerifiedYieldSummaries(List verifiedYieldSummaries) { + this.verifiedYieldSummaries = verifiedYieldSummaries; + } + public List getProductWarningMessages() { return productWarningMessages; } diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/VerifiedYieldContractRsrcFactory.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/VerifiedYieldContractRsrcFactory.java index eccfebcb..32fde19c 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/VerifiedYieldContractRsrcFactory.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/VerifiedYieldContractRsrcFactory.java @@ -28,8 +28,10 @@ import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.VerifiedYieldContractRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.types.ResourceTypes; import ca.bc.gov.mal.cirras.underwriting.model.v1.AnnualField; +import ca.bc.gov.mal.cirras.underwriting.model.v1.UnderwritingComment; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiableCommodity; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldAmendment; +import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldSummary; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContract; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContractCommodity; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContractedFieldDetailDto; @@ -39,7 +41,9 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventorySeededGrainDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.PolicyDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ProductDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.UnderwritingCommentDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldAmendmentDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractCommodityDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractDto; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.model.factory.VerifiedYieldContractFactory; @@ -185,6 +189,18 @@ private VerifiedYieldContractCommodity createDefaultVerifiedYieldContractCommodi resource.setVerifiedYieldAmendments(verifiedYieldAmendments); } + + // Verified Yield Summary + if (!dto.getVerifiedYieldSummaries().isEmpty()) { + List verifiedYieldSummaries = new ArrayList(); + + for (VerifiedYieldSummaryDto vysDto : dto.getVerifiedYieldSummaries()) { + VerifiedYieldSummary vysModel = createVerifiedYieldSummary(vysDto, authentication); + verifiedYieldSummaries.add(vysModel); + } + + resource.setVerifiedYieldSummaries(verifiedYieldSummaries); + } resource.setProductWarningMessages(productWarnings); @@ -329,6 +345,38 @@ private VerifiedYieldAmendment createVerifiedYieldAmendment(VerifiedYieldAmendme return model; } + + private VerifiedYieldSummary createVerifiedYieldSummary(VerifiedYieldSummaryDto dto, WebAdeAuthentication authentication) { + VerifiedYieldSummary model = new VerifiedYieldSummary(); + + model.setVerifiedYieldSummaryGuid(dto.getVerifiedYieldSummaryGuid()); + model.setVerifiedYieldContractGuid(dto.getVerifiedYieldContractGuid()); + model.setCropCommodityId(dto.getCropCommodityId()); + model.setCropCommodityName(dto.getCropCommodityName()); + model.setIsPedigreeInd(dto.getIsPedigreeInd()); + model.setHarvestedYield(dto.getHarvestedYield()); + model.setHarvestedYieldPerAcre(dto.getHarvestedYieldPerAcre()); + model.setAppraisedYield(dto.getAppraisedYield()); + model.setAssessedYield(dto.getAssessedYield()); + model.setYieldToCount(dto.getYieldToCount()); + model.setYieldPercentPy(dto.getYieldPercentPy()); + model.setProductionGuarantee(dto.getProductionGuarantee()); + model.setProbableYield(dto.getProbableYield()); + + // UnderwritingComment + if (!dto.getUwComments().isEmpty()) { + List uwComments = new ArrayList(); + + for (UnderwritingCommentDto ucDto : dto.getUwComments()) { + UnderwritingComment ucModel = InventoryContractRsrcFactory.createUnderwritingComment(ucDto, authentication); + uwComments.add(ucModel); + } + + model.setUwComments(uwComments); + } + + return model; + } // Creates an AnnualFieldRsrc and populates its verifiableCommodities. private AnnualFieldRsrc createAnnualField(ContractedFieldDetailDto dto, WebAdeAuthentication authentication) { diff --git a/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/VerifiedYieldSummary.java b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/VerifiedYieldSummary.java new file mode 100644 index 00000000..364ed15d --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/VerifiedYieldSummary.java @@ -0,0 +1,143 @@ +package ca.bc.gov.mal.cirras.underwriting.model.v1; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +// +// This is not going to be a resource. +// +public class VerifiedYieldSummary implements Serializable { + private static final long serialVersionUID = 1L; + + private String verifiedYieldSummaryGuid; + private String verifiedYieldContractGuid; + private Integer cropCommodityId; + private Boolean isPedigreeInd; + private Double harvestedYield; + private Double harvestedYieldPerAcre; + private Double appraisedYield; + private Double assessedYield; + private Double yieldToCount; + private Double yieldPercentPy; + private Double productionGuarantee; + private Double probableYield; + + // Extended columns + private String cropCommodityName; + + private List uwComments = new ArrayList(); + + public String getVerifiedYieldSummaryGuid() { + return verifiedYieldSummaryGuid; + } + + public void setVerifiedYieldSummaryGuid(String verifiedYieldSummaryGuid) { + this.verifiedYieldSummaryGuid = verifiedYieldSummaryGuid; + } + + public String getVerifiedYieldContractGuid() { + return verifiedYieldContractGuid; + } + + public void setVerifiedYieldContractGuid(String verifiedYieldContractGuid) { + this.verifiedYieldContractGuid = verifiedYieldContractGuid; + } + + public Integer getCropCommodityId() { + return cropCommodityId; + } + + public void setCropCommodityId(Integer cropCommodityId) { + this.cropCommodityId = cropCommodityId; + } + + public Boolean getIsPedigreeInd() { + return isPedigreeInd; + } + + public void setIsPedigreeInd(Boolean isPedigreeInd) { + this.isPedigreeInd = isPedigreeInd; + } + + public Double getHarvestedYield() { + return harvestedYield; + } + + public void setHarvestedYield(Double harvestedYield) { + this.harvestedYield = harvestedYield; + } + + public Double getHarvestedYieldPerAcre() { + return harvestedYieldPerAcre; + } + + public void setHarvestedYieldPerAcre(Double harvestedYieldPerAcre) { + this.harvestedYieldPerAcre = harvestedYieldPerAcre; + } + + public Double getAppraisedYield() { + return appraisedYield; + } + + public void setAppraisedYield(Double appraisedYield) { + this.appraisedYield = appraisedYield; + } + + public Double getAssessedYield() { + return assessedYield; + } + + public void setAssessedYield(Double assessedYield) { + this.assessedYield = assessedYield; + } + + public Double getYieldToCount() { + return yieldToCount; + } + + public void setYieldToCount(Double yieldToCount) { + this.yieldToCount = yieldToCount; + } + + public Double getYieldPercentPy() { + return yieldPercentPy; + } + + public void setYieldPercentPy(Double yieldPercentPy) { + this.yieldPercentPy = yieldPercentPy; + } + + public Double getProductionGuarantee() { + return productionGuarantee; + } + + public void setProductionGuarantee(Double productionGuarantee) { + this.productionGuarantee = productionGuarantee; + } + + public Double getProbableYield() { + return probableYield; + } + + public void setProbableYield(Double probableYield) { + this.probableYield = probableYield; + } + + public String getCropCommodityName() { + return cropCommodityName; + } + + public void setCropCommodityName(String cropCommodityName) { + this.cropCommodityName = cropCommodityName; + } + + public List getUwComments() { + return uwComments; + } + + public void setUwComments(List uwComments) { + this.uwComments = uwComments; + } + +} diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDao.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDao.java index 5fc5adac..3259d815 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDao.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDao.java @@ -24,9 +24,15 @@ public interface UnderwritingCommentDao extends Serializable { void deleteForField(Integer fieldId) throws DaoException, NotFoundDaoException; + void deleteForVerifiedYieldSummaryGuid(String verifiedYieldSummaryGuid) throws DaoException, NotFoundDaoException; + + void deleteForVerifiedYieldContract(String verifiedYieldContractGuid) throws DaoException, NotFoundDaoException; + List select(Integer annualFieldDetailId) throws DaoException; List selectForDopContract(String declaredYieldContractGuid) throws DaoException; List selectForField(Integer fieldId) throws DaoException; + + List selectForVerifiedYieldSummary(String verifiedYieldSummaryGuid) throws DaoException; } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDao.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDao.java new file mode 100644 index 00000000..de4a003b --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDao.java @@ -0,0 +1,24 @@ +package ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao; + +import java.io.Serializable; +import java.util.List; + +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; +import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; +import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; + + +public interface VerifiedYieldSummaryDao extends Serializable { + + VerifiedYieldSummaryDto fetch(String verifiedYieldSummaryGuid) throws DaoException; + + void insert(VerifiedYieldSummaryDto dto, String userId) throws DaoException; + + void update(VerifiedYieldSummaryDto dto, String userId) throws DaoException, NotFoundDaoException; + + void delete(String verifiedYieldSummaryGuid) throws DaoException, NotFoundDaoException; + + void deleteForVerifiedYieldContract(String verifiedYieldContractGuid) throws DaoException, NotFoundDaoException; + + List selectForVerifiedYieldContract(String verifiedYieldContractGuid) throws DaoException; +} diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/UnderwritingCommentDaoImpl.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/UnderwritingCommentDaoImpl.java index 01ef83f2..d3629210 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/UnderwritingCommentDaoImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/UnderwritingCommentDaoImpl.java @@ -174,6 +174,41 @@ public void deleteForField(Integer fieldId) throws DaoException, NotFoundDaoExce logger.debug(">deleteForField"); } + @Override + public void deleteForVerifiedYieldSummaryGuid(String verifiedYieldSummaryGuid) + throws DaoException, NotFoundDaoException { + logger.debug(" parameters = new HashMap(); + parameters.put("verifiedYieldSummaryGuid", verifiedYieldSummaryGuid); + this.mapper.deleteForVerifiedYieldSummaryGuid(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">deleteForVerifiedYieldSummaryGuid"); + } + + + @Override + public void deleteForVerifiedYieldContract(String verifiedYieldContractGuid) + throws DaoException, NotFoundDaoException { + logger.debug(" parameters = new HashMap(); + parameters.put("verifiedYieldContractGuid", verifiedYieldContractGuid); + this.mapper.deleteForVerifiedYieldContract(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">deleteForVerifiedYieldContract"); + } + @Override public List select(Integer annualFieldDetailId) throws DaoException { List dtos = null; @@ -231,6 +266,30 @@ public List selectForField(Integer fieldId) throws DaoEx logger.debug(">selectForField " + dtos); return dtos; - } - + } + + + @Override + public List selectForVerifiedYieldSummary(String verifiedYieldSummaryGuid) + throws DaoException { + List dtos = null; + + logger.debug(" parameters = new HashMap(); + + parameters.put("verifiedYieldSummaryGuid", verifiedYieldSummaryGuid); + + dtos = this.mapper.selectForVerifiedYieldSummary(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">selectForVerifiedYieldSummary " + dtos); + return dtos; + } + + } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/VerifiedYieldSummaryDaoImpl.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/VerifiedYieldSummaryDaoImpl.java new file mode 100644 index 00000000..6f47ee36 --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/VerifiedYieldSummaryDaoImpl.java @@ -0,0 +1,169 @@ +package ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldSummaryDao; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.mapper.VerifiedYieldSummaryMapper; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; +import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; +import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; +import ca.bc.gov.nrs.wfone.common.persistence.dao.mybatis.BaseDao; + + +@Repository +public class VerifiedYieldSummaryDaoImpl extends BaseDao implements VerifiedYieldSummaryDao { + + private static final long serialVersionUID = 1L; + + private static final Logger logger = LoggerFactory.getLogger(VerifiedYieldSummaryDaoImpl.class); + + @Autowired + private VerifiedYieldSummaryMapper mapper; + + @Override + public VerifiedYieldSummaryDto fetch(String verifiedYieldSummaryGuid) throws DaoException { + logger.debug(" parameters = new HashMap(); + parameters.put("verifiedYieldSummaryGuid", verifiedYieldSummaryGuid); + result = this.mapper.fetch(parameters); + + if(result!=null) { + result.resetDirty(); + } + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">fetch " + result); + return result; + } + + + @Override + public void insert(VerifiedYieldSummaryDto dto, String userId) throws DaoException { + logger.debug(" parameters = new HashMap(); + + parameters.put("dto", dto); + parameters.put("userId", userId); + int count = this.mapper.insert(parameters); + + if(count==0) { + throw new DaoException("Record not inserted: "+count); + } + + verifiedYieldSummaryGuid = (String) parameters.get("verifiedYieldSummaryGuid"); + dto.setVerifiedYieldSummaryGuid(verifiedYieldSummaryGuid); + + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">insert " + verifiedYieldSummaryGuid); + } + + + @Override + public void update(VerifiedYieldSummaryDto dto, String userId) + throws DaoException, NotFoundDaoException { + logger.debug(" parameters = new HashMap(); + parameters.put("dto", dto); + parameters.put("userId", userId); + int count = this.mapper.update(parameters); + + if(count==0) { + throw new DaoException("Record not updated: "+count); + } + + } catch (RuntimeException e) { + handleException(e); + } + } else { + + logger.info("Skipping update because dto is not dirty"); + } + + logger.debug(">update"); + } + + @Override + public void delete(String verifiedYieldSummaryGuid) throws DaoException, NotFoundDaoException { + logger.debug(" parameters = new HashMap(); + parameters.put("verifiedYieldSummaryGuid", verifiedYieldSummaryGuid); + int count = this.mapper.delete(parameters); + + if(count==0) { + throw new DaoException("Record not deleted: "+count); + } + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">delete"); + } + + + @Override + public void deleteForVerifiedYieldContract(String verifiedYieldContractGuid) throws DaoException, NotFoundDaoException { + + logger.debug(" parameters = new HashMap(); + parameters.put("verifiedYieldContractGuid", verifiedYieldContractGuid); + this.mapper.deleteForVerifiedYieldContract(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">deleteForVerifiedYieldContract"); + + } + + @Override + public List selectForVerifiedYieldContract(String verifiedYieldContractGuid) throws DaoException { + + logger.debug(" dtos = null; + + try { + Map parameters = new HashMap(); + + parameters.put("verifiedYieldContractGuid", verifiedYieldContractGuid); + + dtos = this.mapper.selectForVerifiedYieldContract(parameters); + + } catch (RuntimeException e) { + handleException(e); + } + + logger.debug(">selectForVerifiedYieldContract " + dtos); + return dtos; + } +} diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.java index 866daff1..1952ebef 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.java @@ -21,10 +21,16 @@ public interface UnderwritingCommentMapper { int deleteForField(Map parameters); + void deleteForVerifiedYieldSummaryGuid(Map parameters); + + void deleteForVerifiedYieldContract(Map parameters); + List select(Map parameters); List selectForDopContract(Map parameters); List selectForField(Map parameters); + + List selectForVerifiedYieldSummary(Map parameters); } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.java new file mode 100644 index 00000000..37938ecd --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.java @@ -0,0 +1,22 @@ +package ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.mapper; + +import java.util.List; +import java.util.Map; + +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; + +public interface VerifiedYieldSummaryMapper { + + VerifiedYieldSummaryDto fetch(Map parameters); + + int insert(Map parameters); + + int update(Map parameters); + + int delete(Map parameters); + + int deleteForVerifiedYieldContract(Map parameters); + + List selectForVerifiedYieldContract(Map parameters); + +} \ No newline at end of file diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/UnderwritingCommentDto.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/UnderwritingCommentDto.java index 7d44a309..fa060165 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/UnderwritingCommentDto.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/UnderwritingCommentDto.java @@ -29,6 +29,7 @@ public class UnderwritingCommentDto extends BaseDto { private Integer growerContractYearId; private String declaredYieldContractGuid; + private String verifiedYieldSummaryGuid; public UnderwritingCommentDto() { } @@ -48,6 +49,8 @@ public UnderwritingCommentDto(UnderwritingCommentDto dto) { this.growerContractYearId = dto.growerContractYearId; this.declaredYieldContractGuid = dto.declaredYieldContractGuid; + this.verifiedYieldSummaryGuid = dto.verifiedYieldSummaryGuid; + } @@ -69,6 +72,7 @@ public boolean equalsAll(UnderwritingCommentDto other) { result = result&&dtoUtils.equals("underwritingComment", underwritingComment, other.underwritingComment); result = result&&dtoUtils.equals("growerContractYearId", growerContractYearId, other.growerContractYearId); result = result&&dtoUtils.equals("declaredYieldContractGuid", declaredYieldContractGuid, other.declaredYieldContractGuid); + result = result&&dtoUtils.equals("verifiedYieldSummaryGuid", verifiedYieldSummaryGuid, other.verifiedYieldSummaryGuid); } return result; @@ -161,5 +165,13 @@ public String getDeclaredYieldContractGuid() { public void setDeclaredYieldContractGuid(String declaredYieldContractGuid) { this.declaredYieldContractGuid = declaredYieldContractGuid; } + + public String getVerifiedYieldSummaryGuid() { + return verifiedYieldSummaryGuid; + } + + public void setVerifiedYieldSummaryGuid(String verifiedYieldSummaryGuid) { + this.verifiedYieldSummaryGuid = verifiedYieldSummaryGuid; + } } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldContractDto.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldContractDto.java index 7587e958..6a02c9ab 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldContractDto.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldContractDto.java @@ -28,6 +28,7 @@ public class VerifiedYieldContractDto extends BaseDto private List fields = new ArrayList(); private List verifiedYieldContractCommodities = new ArrayList(); private List verifiedYieldAmendments = new ArrayList(); + private List verifiedYieldSummaries = new ArrayList(); private String createUser; private Date createDate; @@ -75,6 +76,14 @@ public VerifiedYieldContractDto(VerifiedYieldContractDto dto) { this.verifiedYieldAmendments.add(vyaDto.copy()); } } + + if ( dto.verifiedYieldSummaries != null ) { + this.verifiedYieldSummaries = new ArrayList<>(); + + for ( VerifiedYieldSummaryDto vyaDto : dto.verifiedYieldSummaries) { + this.verifiedYieldSummaries.add(vyaDto.copy()); + } + } this.createUser = dto.createUser; this.createDate = dto.createDate; @@ -192,6 +201,13 @@ public void setVerifiedYieldAmendments(List verifiedY this.verifiedYieldAmendments = verifiedYieldAmendments; } + public List getVerifiedYieldSummaries() { + return verifiedYieldSummaries; + } + public void setVerifiedYieldSummaries(List verifiedYieldSummaries) { + this.verifiedYieldSummaries = verifiedYieldSummaries; + } + public String getCreateUser() { return createUser; } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldSummaryDto.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldSummaryDto.java new file mode 100644 index 00000000..b48a38b4 --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dto/VerifiedYieldSummaryDto.java @@ -0,0 +1,263 @@ +package ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.bc.gov.nrs.wfone.common.persistence.dto.BaseDto; +import ca.bc.gov.nrs.wfone.common.persistence.utils.DtoUtils; + +public class VerifiedYieldSummaryDto extends BaseDto { + + private static final long serialVersionUID = 1L; + + private static final Logger logger = LoggerFactory.getLogger(VerifiedYieldSummaryDto.class); + + private String verifiedYieldSummaryGuid; + private String verifiedYieldContractGuid; + private Integer cropCommodityId; + private Boolean isPedigreeInd; + private Double harvestedYield; + private Double harvestedYieldPerAcre; + private Double appraisedYield; + private Double assessedYield; + private Double yieldToCount; + private Double yieldPercentPy; + private Double productionGuarantee; + private Double probableYield; + + private String createUser; + private Date createDate; + private String updateUser; + private Date updateDate; + + // Extended columns + private String cropCommodityName; + + //comments + private List uwComments = new ArrayList(); + + public VerifiedYieldSummaryDto() { + } + + + public VerifiedYieldSummaryDto(VerifiedYieldSummaryDto dto) { + + this.verifiedYieldSummaryGuid = dto.verifiedYieldSummaryGuid; + this.verifiedYieldContractGuid = dto.verifiedYieldContractGuid; + this.cropCommodityId = dto.cropCommodityId; + this.isPedigreeInd = dto.isPedigreeInd; + this.harvestedYield = dto.harvestedYield; + this.harvestedYieldPerAcre = dto.harvestedYieldPerAcre; + this.appraisedYield = dto.appraisedYield; + this.assessedYield = dto.assessedYield; + this.yieldToCount = dto.yieldToCount; + this.yieldPercentPy = dto.yieldPercentPy; + this.productionGuarantee = dto.productionGuarantee; + this.probableYield = dto.probableYield; + + this.createUser = dto.createUser; + this.createDate = dto.createDate; + this.updateUser = dto.updateUser; + this.updateDate = dto.updateDate; + + this.cropCommodityName = dto.cropCommodityName; + + if ( dto.uwComments != null ) { + this.uwComments = new ArrayList<>(); + + for ( UnderwritingCommentDto ifDto : dto.uwComments) { + this.uwComments.add(ifDto.copy()); + } + } + + } + + + @Override + public boolean equalsBK(VerifiedYieldSummaryDto other) { + throw new UnsupportedOperationException("Not Implemented"); + } + + @Override + public boolean equalsAll(VerifiedYieldSummaryDto other) { + boolean result = false; + + if(other!=null) { + Integer decimalPrecision = 4; + result = true; + DtoUtils dtoUtils = new DtoUtils(getLogger()); + + result = result&&dtoUtils.equals("verifiedYieldSummaryGuid", verifiedYieldSummaryGuid, other.verifiedYieldSummaryGuid); + result = result&&dtoUtils.equals("verifiedYieldContractGuid", verifiedYieldContractGuid, other.verifiedYieldContractGuid); + result = result&&dtoUtils.equals("cropCommodityId", cropCommodityId, other.cropCommodityId); + result = result&&dtoUtils.equals("isPedigreeInd", isPedigreeInd, other.isPedigreeInd); + result = result&&dtoUtils.equals("harvestedYield", harvestedYield, other.harvestedYield, decimalPrecision); + result = result&&dtoUtils.equals("harvestedYieldPerAcre", harvestedYieldPerAcre, other.harvestedYieldPerAcre, decimalPrecision); + result = result&&dtoUtils.equals("appraisedYield", appraisedYield, other.appraisedYield, decimalPrecision); + result = result&&dtoUtils.equals("assessedYield", assessedYield, other.assessedYield, decimalPrecision); + result = result&&dtoUtils.equals("yieldToCount", yieldToCount, other.yieldToCount, decimalPrecision); + result = result&&dtoUtils.equals("yieldPercentPy", yieldPercentPy, other.yieldPercentPy, decimalPrecision); + result = result&&dtoUtils.equals("productionGuarantee", productionGuarantee, other.productionGuarantee, decimalPrecision); + result = result&&dtoUtils.equals("probableYield", probableYield, other.probableYield, decimalPrecision); + } + + return result; + } + + @Override + public Logger getLogger() { + return logger; + } + + @Override + public VerifiedYieldSummaryDto copy() { + return new VerifiedYieldSummaryDto(this); + } + + public String getVerifiedYieldSummaryGuid() { + return verifiedYieldSummaryGuid; + } + + public void setVerifiedYieldSummaryGuid(String verifiedYieldSummaryGuid) { + this.verifiedYieldSummaryGuid = verifiedYieldSummaryGuid; + } + + public String getVerifiedYieldContractGuid() { + return verifiedYieldContractGuid; + } + + public void setVerifiedYieldContractGuid(String verifiedYieldContractGuid) { + this.verifiedYieldContractGuid = verifiedYieldContractGuid; + } + + public Integer getCropCommodityId() { + return cropCommodityId; + } + + public void setCropCommodityId(Integer cropCommodityId) { + this.cropCommodityId = cropCommodityId; + } + + public Boolean getIsPedigreeInd() { + return isPedigreeInd; + } + + public void setIsPedigreeInd(Boolean isPedigreeInd) { + this.isPedigreeInd = isPedigreeInd; + } + + public Double getHarvestedYield() { + return harvestedYield; + } + + public void setHarvestedYield(Double harvestedYield) { + this.harvestedYield = harvestedYield; + } + + public Double getHarvestedYieldPerAcre() { + return harvestedYieldPerAcre; + } + + public void setHarvestedYieldPerAcre(Double harvestedYieldPerAcre) { + this.harvestedYieldPerAcre = harvestedYieldPerAcre; + } + + public Double getAppraisedYield() { + return appraisedYield; + } + + public void setAppraisedYield(Double appraisedYield) { + this.appraisedYield = appraisedYield; + } + + public Double getAssessedYield() { + return assessedYield; + } + + public void setAssessedYield(Double assessedYield) { + this.assessedYield = assessedYield; + } + + public Double getYieldToCount() { + return yieldToCount; + } + + public void setYieldToCount(Double yieldToCount) { + this.yieldToCount = yieldToCount; + } + + public Double getYieldPercentPy() { + return yieldPercentPy; + } + + public void setYieldPercentPy(Double yieldPercentPy) { + this.yieldPercentPy = yieldPercentPy; + } + + public Double getProductionGuarantee() { + return productionGuarantee; + } + + public void setProductionGuarantee(Double productionGuarantee) { + this.productionGuarantee = productionGuarantee; + } + + public Double getProbableYield() { + return probableYield; + } + + public void setProbableYield(Double probableYield) { + this.probableYield = probableYield; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public String getUpdateUser() { + return updateUser; + } + + public void setUpdateUser(String updateUser) { + this.updateUser = updateUser; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public String getCropCommodityName() { + return cropCommodityName; + } + + public void setCropCommodityName(String cropCommodityName) { + this.cropCommodityName = cropCommodityName; + } + + public List getUwComments() { + return uwComments; + } + public void setUwComments(List uwComments) { + this.uwComments = uwComments; + } +} diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/spring/PersistenceSpringConfig.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/spring/PersistenceSpringConfig.java index e6e12a4e..0c7964f2 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/spring/PersistenceSpringConfig.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/spring/PersistenceSpringConfig.java @@ -66,6 +66,7 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldAmendmentDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldContractCommodityDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldContractDao; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldSummaryDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.YieldMeasUnitConversionDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.YieldMeasUnitPlanXrefDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.YieldMeasUnitTypeCodeDao; @@ -115,6 +116,7 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.VerifiedYieldAmendmentDaoImpl; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.VerifiedYieldContractCommodityDaoImpl; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.VerifiedYieldContractDaoImpl; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.VerifiedYieldSummaryDaoImpl; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.YieldMeasUnitConversionDaoImpl; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.YieldMeasUnitPlanXrefDaoImpl; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.mybatis.YieldMeasUnitTypeCodeDaoImpl; @@ -420,5 +422,10 @@ public ProductDao productDao() { public VerifiedYieldAmendmentDao verifiedYieldAmendmentDao() { return new VerifiedYieldAmendmentDaoImpl(); } + + @Bean + public VerifiedYieldSummaryDao verifiedYieldSummaryDao() { + return new VerifiedYieldSummaryDaoImpl(); + } } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.xml b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.xml index 6db6b683..f7809a19 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.xml +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/UnderwritingCommentMapper.xml @@ -19,6 +19,7 @@ + @@ -36,7 +37,8 @@ uc.update_user, uc.update_date, uc.grower_contract_year_id, - uc.declared_yield_contract_guid + uc.declared_yield_contract_guid, + uc.verified_yield_summary_guid @@ -59,6 +61,7 @@ underwriting_comment, grower_contract_year_id, declared_yield_contract_guid, + verified_yield_summary_guid, create_user, create_date, update_user, @@ -70,6 +73,7 @@ #{dto.underwritingComment, javaType=java.lang.String , jdbcType=VARCHAR, mode=IN}, #{dto.growerContractYearId, javaType=java.lang.Integer , jdbcType=NUMERIC, mode=IN}, #{dto.declaredYieldContractGuid, javaType=java.lang.String , jdbcType=VARCHAR, mode=IN}, + #{dto.verifiedYieldSummaryGuid, javaType=java.lang.String , jdbcType=VARCHAR, mode=IN}, #{userId, javaType=java.lang.String, jdbcType=VARCHAR, mode=IN}, now(), #{userId, javaType=java.lang.String, jdbcType=VARCHAR, mode=IN}, @@ -103,6 +107,15 @@ delete from underwriting_comment where annual_field_detail_id in (select afd.annual_field_detail_id from annual_field_detail afd where afd.field_id = #{fieldId}) + + + delete from underwriting_comment where verified_yield_summary_guid = #{verifiedYieldSummaryGuid} + + + + delete from underwriting_comment + where verified_yield_summary_guid in (select verified_yield_summary_guid from verified_yield_summary where verified_yield_contract_guid = #{verifiedYieldContractGuid}) + + diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.xml b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.xml new file mode 100644 index 00000000..6430e649 --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/main/resources/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/mybatis/mapper/VerifiedYieldSummaryMapper.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select t.verified_yield_summary_guid, + t.verified_yield_contract_guid, + t.crop_commodity_id, + t.is_pedigree_ind, + t.harvested_yield, + t.harvested_yield_per_acre, + t.appraised_yield, + t.assessed_yield, + t.yield_to_count, + t.yield_percent_py, + t.production_guarantee, + t.probable_yield, + t.create_user, + t.create_date, + t.update_user, + t.update_date + + + + + + + select replace(cast(gen_random_uuid() as text), '-', '') + + + insert into verified_yield_summary( + verified_yield_summary_guid, + verified_yield_contract_guid, + crop_commodity_id, + is_pedigree_ind, + harvested_yield, + harvested_yield_per_acre, + appraised_yield, + assessed_yield, + yield_to_count, + yield_percent_py, + production_guarantee, + probable_yield, + create_user, + create_date, + update_user, + update_date + ) values ( + #{verifiedYieldSummaryGuid}, + #{dto.verifiedYieldContractGuid, javaType=java.lang.String , jdbcType=VARCHAR, mode=IN}, + #{dto.cropCommodityId, javaType=java.lang.Integer , jdbcType=NUMERIC, mode=IN}, + #{dto.isPedigreeInd, javaType=java.lang.Boolean , jdbcType=VARCHAR, mode=IN}, + #{dto.harvestedYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.harvestedYieldPerAcre, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.appraisedYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.assessedYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.yieldToCount, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.yieldPercentPy, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.productionGuarantee, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{dto.probableYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + #{userId, javaType=java.lang.String, jdbcType=VARCHAR, mode=IN}, + now(), + #{userId, javaType=java.lang.String, jdbcType=VARCHAR, mode=IN}, + now() + ) + + + + update verified_yield_summary + set crop_commodity_id = #{dto.cropCommodityId, javaType=java.lang.Integer , jdbcType=NUMERIC, mode=IN}, + is_pedigree_ind = #{dto.isPedigreeInd, javaType=java.lang.Boolean , jdbcType=VARCHAR, mode=IN}, + harvested_yield = #{dto.harvestedYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + harvested_yield_per_acre = #{dto.harvestedYieldPerAcre, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + appraised_yield = #{dto.appraisedYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + assessed_yield = #{dto.assessedYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + yield_to_count = #{dto.yieldToCount, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + yield_percent_py = #{dto.yieldPercentPy, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + production_guarantee = #{dto.productionGuarantee, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + probable_yield = #{dto.probableYield, javaType=java.lang.Double , jdbcType=NUMERIC, mode=IN}, + update_user = #{userId, javaType=java.lang.String, jdbcType=VARCHAR, mode=IN}, + update_date = now() + where verified_yield_summary_guid = #{dto.verifiedYieldSummaryGuid, javaType=java.lang.String , jdbcType=VARCHAR, mode=IN} + + + + delete from verified_yield_summary where verified_yield_summary_guid = #{verifiedYieldSummaryGuid} + + + + delete from verified_yield_summary where verified_yield_contract_guid = #{verifiedYieldContractGuid} + + + + + diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDaoTest.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDaoTest.java index ff5b7917..6117e675 100644 --- a/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDaoTest.java +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/UnderwritingCommentDaoTest.java @@ -17,11 +17,15 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.UnderwritingCommentDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.AnnualFieldDetailDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContractedFieldDetailDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.DeclaredYieldContractDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.FieldDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.GrowerContractYearDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventoryContractDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventoryFieldDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.LegalLandDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.UnderwritingCommentDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.spring.PersistenceSpringConfig; import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; @@ -75,12 +79,46 @@ private void deleteUwCommentDetail() throws NotFoundDaoException, DaoException{ fieldDao.delete(fieldId); } + //Delete Verified Yield Summary Comments + underwritingCommentDao.deleteForVerifiedYieldContract(verifiedYieldContractGuid); + + // Delete VerifiedYieldSummary + VerifiedYieldSummaryDao vyaDao = persistenceSpringConfig.verifiedYieldSummaryDao(); + List vyaDtos = vyaDao.selectForVerifiedYieldContract(verifiedYieldContractGuid); + if ( vyaDtos != null && !vyaDtos.isEmpty() ) { + vyaDao.deleteForVerifiedYieldContract(verifiedYieldContractGuid); + } + + // Delete VerifiedYieldContract + VerifiedYieldContractDao vycDao = persistenceSpringConfig.verifiedYieldContractDao(); + VerifiedYieldContractDto vycDto = vycDao.fetch(verifiedYieldContractGuid); + if (vycDto != null) { + vycDao.delete(verifiedYieldContractGuid); + } + + // Delete DeclaredYieldContract + DeclaredYieldContractDao dycDao = persistenceSpringConfig.declaredYieldContractDao(); + DeclaredYieldContractDto dycDto = dycDao.fetch(declaredYieldContractGuid); + if (dycDto != null) { + dycDao.delete(declaredYieldContractGuid); + } + + GrowerContractYearDao gcyDao = persistenceSpringConfig.growerContractYearDao(); + GrowerContractYearDto gcyDto = gcyDao.fetch(growerContractYearId); + if (gcyDto != null) { + gcyDao.delete(growerContractYearId); + } + } private Integer fieldId = 99999999;; private Integer legalLandId = 99999999; private Integer annualFieldDetailId = 99999999; - + private Integer growerContractYearId = 90000001; + private Integer contractId = 90000002; + private Integer cropYear = 2020; + private String verifiedYieldContractGuid; + private String declaredYieldContractGuid; @Test public void testUnderwritingComment() throws Exception { @@ -294,6 +332,76 @@ public void testDeleteForField() throws Exception { } + @Test + public void testVerifiedYieldSummaryComments() throws Exception { + + String userId = "UNITTEST"; + + createGrowerContractYear(); + createDeclaredYieldContract(userId); + createVerifiedYieldContract(userId); + + String verifiedYieldSummaryGuid1 = createVerifiedYieldSummary(userId, 16); + String verifiedYieldSummaryGuid2 = createVerifiedYieldSummary(userId, 18); + + createVerifiedYieldSummaryComment(verifiedYieldSummaryGuid1, "test comment 1"); + createVerifiedYieldSummaryComment(verifiedYieldSummaryGuid1, "test comment 2"); + + createVerifiedYieldSummaryComment(verifiedYieldSummaryGuid2, "test comment 3"); + + UnderwritingCommentDao dao = persistenceSpringConfig.underwritingCommentDao(); + + //Select for first verified yield summary + List fetchedDtos = dao.selectForVerifiedYieldSummary(verifiedYieldSummaryGuid1); + Assert.assertNotNull(fetchedDtos); + Assert.assertEquals(2, fetchedDtos.size()); + + //Select for second verified yield summary + fetchedDtos = dao.selectForVerifiedYieldSummary(verifiedYieldSummaryGuid2); + Assert.assertNotNull(fetchedDtos); + Assert.assertEquals(1, fetchedDtos.size()); + + //DELETE for second verified yield summary + dao.deleteForVerifiedYieldSummaryGuid(verifiedYieldSummaryGuid2); + fetchedDtos = dao.selectForVerifiedYieldSummary(verifiedYieldSummaryGuid2); + Assert.assertNotNull(fetchedDtos); + Assert.assertEquals(0, fetchedDtos.size()); + + //Select for first verified yield summary again + fetchedDtos = dao.selectForVerifiedYieldSummary(verifiedYieldSummaryGuid1); + Assert.assertNotNull(fetchedDtos); + Assert.assertEquals(2, fetchedDtos.size()); + + //DELETE for verified yield contract + dao.deleteForVerifiedYieldContract(verifiedYieldContractGuid); + fetchedDtos = dao.selectForVerifiedYieldSummary(verifiedYieldSummaryGuid1); + Assert.assertNotNull(fetchedDtos); + Assert.assertEquals(0, fetchedDtos.size()); + + //clean up + deleteUwCommentDetail(); + + } + + + private String createVerifiedYieldSummaryComment(String verifiedYieldSummaryGuid, String comment) throws DaoException { + String userId = "UNITTEST"; + + UnderwritingCommentDao dao = persistenceSpringConfig.underwritingCommentDao(); + UnderwritingCommentDto newDto = new UnderwritingCommentDto(); + + newDto.setVerifiedYieldSummaryGuid(verifiedYieldSummaryGuid); + newDto.setUnderwritingComment(comment); + newDto.setUnderwritingCommentTypeCode("VY"); + newDto.setUnderwritingCommentTypeDesc("Verified Yield"); + + dao.insert(newDto, userId); + Assert.assertNotNull(newDto.getUnderwritingCommentGuid()); + return newDto.getUnderwritingCommentGuid(); + + + } + private String createUwComment() throws DaoException { String userId = "UNITTEST"; @@ -344,4 +452,96 @@ private void createAnnualField() throws DaoException { dao.insertDataSync(newDto, userId); } + + private void createGrowerContractYear() throws DaoException { + GrowerContractYearDao dao = persistenceSpringConfig.growerContractYearDao(); + GrowerContractYearDto newDto = new GrowerContractYearDto(); + + //Date and Time without millisecond + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.MILLISECOND, 0); //Set milliseconds to 0 becauce they are not set in the database + Date dateTime = cal.getTime(); + + String userId = "JUNIT_TEST"; + + //INSERT + newDto.setGrowerContractYearId(growerContractYearId); + newDto.setContractId(contractId); + newDto.setGrowerId(null); + newDto.setInsurancePlanId(4); + newDto.setCropYear(cropYear); + newDto.setDataSyncTransDate(dateTime); + + dao.insert(newDto, userId); + } + + private void createDeclaredYieldContract(String userId) throws DaoException { + + // Create parent Declared Yield Contract. + Calendar cal = Calendar.getInstance(); + cal.clear(); + cal.set(2020, Calendar.JANUARY, 15); + Date dopDate = cal.getTime(); + + DeclaredYieldContractDao dao = persistenceSpringConfig.declaredYieldContractDao(); + + DeclaredYieldContractDto newDto = new DeclaredYieldContractDto(); + + newDto.setContractId(contractId); + newDto.setCropYear(cropYear); + newDto.setDeclarationOfProductionDate(dopDate); + newDto.setDefaultYieldMeasUnitTypeCode("TONNE"); + newDto.setEnteredYieldMeasUnitTypeCode("BUSHEL"); + newDto.setGrainFromOtherSourceInd(true); + newDto.setBalerWagonInfo(null); + newDto.setTotalLivestock(null); + + //INSERT + dao.insert(newDto, userId); + declaredYieldContractGuid = newDto.getDeclaredYieldContractGuid(); + + } + + private void createVerifiedYieldContract(String userId) throws DaoException { + + VerifiedYieldContractDao dao = persistenceSpringConfig.verifiedYieldContractDao(); + + VerifiedYieldContractDto newDto = new VerifiedYieldContractDto(); + + newDto.setContractId(contractId); + newDto.setCropYear(cropYear); + newDto.setDeclaredYieldContractGuid(declaredYieldContractGuid); + newDto.setDefaultYieldMeasUnitTypeCode("TONNE"); + newDto.setInsurancePlanId(4); + + //INSERT + dao.insert(newDto, userId); + verifiedYieldContractGuid = newDto.getVerifiedYieldContractGuid(); + } + + private String createVerifiedYieldSummary(String userId, Integer cropCommodityId) throws DaoException { + + VerifiedYieldSummaryDao dao = persistenceSpringConfig.verifiedYieldSummaryDao(); + + VerifiedYieldSummaryDto newDto = new VerifiedYieldSummaryDto(); + + newDto.setVerifiedYieldContractGuid(verifiedYieldContractGuid); + newDto.setCropCommodityId(cropCommodityId); + //newDto.setCropCommodityName("BARLEY"); + newDto.setIsPedigreeInd(false); + newDto.setHarvestedYield(100.0); + newDto.setHarvestedYieldPerAcre(10.0); + newDto.setAppraisedYield(1.5); + newDto.setAssessedYield(0.5); + newDto.setYieldToCount(15.5); + newDto.setYieldPercentPy(75.5); + newDto.setProductionGuarantee(20.5); + newDto.setProbableYield(17.5); + + dao.insert(newDto, userId); + Assert.assertNotNull(newDto.getVerifiedYieldSummaryGuid()); + + return newDto.getVerifiedYieldSummaryGuid(); + } + } diff --git a/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDaoTest.java b/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDaoTest.java new file mode 100644 index 00000000..52267ccc --- /dev/null +++ b/cirras-underwriting-api/cirras-underwriting-persistence/src/test/java/ca/bc/gov/mal/cirras/underwriting/persistence/v1/dao/VerifiedYieldSummaryDaoTest.java @@ -0,0 +1,350 @@ +package ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.GrowerContractYearDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.DeclaredYieldContractDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.FieldDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventoryContractDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.UnderwritingCommentDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.spring.PersistenceSpringConfig; +import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; +import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes= {TestConfig.class, PersistenceSpringConfig.class}) +public class VerifiedYieldSummaryDaoTest { + + @Autowired + private PersistenceSpringConfig persistenceSpringConfig; + + private Integer growerContractYearId = 90000001; + private Integer contractId = 90000002; + private Integer cropYear = 2020; + private String verifiedYieldContractGuid; + private String declaredYieldContractGuid; + private String inventoryContractGuid; + private Integer fieldId = 90000003; + + + @Before + public void prepareTests() throws NotFoundDaoException, DaoException{ + delete(); + } + + @After + public void cleanUp() throws NotFoundDaoException, DaoException{ + delete(); + } + + private void delete() throws NotFoundDaoException, DaoException{ + + // Delete VerifiedYieldSummary + VerifiedYieldSummaryDao vyaDao = persistenceSpringConfig.verifiedYieldSummaryDao(); + List vyaDtos = vyaDao.selectForVerifiedYieldContract(verifiedYieldContractGuid); + if ( vyaDtos != null && !vyaDtos.isEmpty() ) { + vyaDao.deleteForVerifiedYieldContract(verifiedYieldContractGuid); + } + + // Delete VerifiedYieldContract + VerifiedYieldContractDao vycDao = persistenceSpringConfig.verifiedYieldContractDao(); + VerifiedYieldContractDto vycDto = vycDao.fetch(verifiedYieldContractGuid); + if (vycDto != null) { + vycDao.delete(verifiedYieldContractGuid); + } + + // Delete DeclaredYieldContract + DeclaredYieldContractDao dycDao = persistenceSpringConfig.declaredYieldContractDao(); + DeclaredYieldContractDto dycDto = dycDao.fetch(declaredYieldContractGuid); + if (dycDto != null) { + dycDao.delete(declaredYieldContractGuid); + } + + // Delete InventoryContract + InventoryContractDao icDao = persistenceSpringConfig.inventoryContractDao(); + InventoryContractDto icDto = icDao.fetch(inventoryContractGuid); + if (icDto != null) { + icDao.delete(inventoryContractGuid); + } + + GrowerContractYearDao gcyDao = persistenceSpringConfig.growerContractYearDao(); + GrowerContractYearDto gcyDto = gcyDao.fetch(growerContractYearId); + if (gcyDto != null) { + gcyDao.delete(growerContractYearId); + } + + FieldDao fldDao = persistenceSpringConfig.fieldDao(); + FieldDto fldDto = fldDao.fetch(fieldId); + if (fldDto != null) { + fldDao.delete(fieldId); + } + + } + + + @Test + public void testVerifiedYieldSummary() throws Exception { + + String verifiedYieldSummaryGuid; + String userId = "UNITTEST"; + + createField("Test Field Label", userId); + createGrowerContractYear(); + createInventoryContract(userId); + createDeclaredYieldContract(userId); + createVerifiedYieldContract(userId); + + VerifiedYieldSummaryDao dao = persistenceSpringConfig.verifiedYieldSummaryDao(); + + // INSERT + VerifiedYieldSummaryDto newDto = new VerifiedYieldSummaryDto(); + + newDto.setVerifiedYieldContractGuid(verifiedYieldContractGuid); + newDto.setCropCommodityId(16); + newDto.setCropCommodityName("BARLEY"); + newDto.setIsPedigreeInd(false); + newDto.setHarvestedYield(100.0); + newDto.setHarvestedYieldPerAcre(10.0); + newDto.setAppraisedYield(1.5); + newDto.setAssessedYield(0.5); + newDto.setYieldToCount(15.5); + newDto.setYieldPercentPy(75.5); + newDto.setProductionGuarantee(20.5); + newDto.setProbableYield(17.5); + + dao.insert(newDto, userId); + Assert.assertNotNull(newDto.getVerifiedYieldSummaryGuid()); + verifiedYieldSummaryGuid = newDto.getVerifiedYieldSummaryGuid(); + + //SELECT + List dtos = dao.selectForVerifiedYieldContract(verifiedYieldContractGuid); + Assert.assertNotNull(dtos); + Assert.assertEquals(1, dtos.size()); + + VerifiedYieldSummaryDto fetchedDto = dtos.get(0); + + Assert.assertEquals("VerifiedYieldSummaryGuid", newDto.getVerifiedYieldSummaryGuid(), fetchedDto.getVerifiedYieldSummaryGuid()); + Assert.assertEquals("VerifiedYieldContractGuid", newDto.getVerifiedYieldContractGuid(), fetchedDto.getVerifiedYieldContractGuid()); + Assert.assertEquals("CropCommodityId", newDto.getCropCommodityId(), fetchedDto.getCropCommodityId()); + Assert.assertEquals("CropCommodityName", newDto.getCropCommodityName(), fetchedDto.getCropCommodityName()); + Assert.assertEquals("IsPedigreeInd", newDto.getIsPedigreeInd(), fetchedDto.getIsPedigreeInd()); + Assert.assertEquals("HarvestedYield", newDto.getHarvestedYield(), fetchedDto.getHarvestedYield()); + Assert.assertEquals("HarvestedYieldPerAcre", newDto.getHarvestedYieldPerAcre(), fetchedDto.getHarvestedYieldPerAcre()); + Assert.assertEquals("AppraisedYield", newDto.getAppraisedYield(), fetchedDto.getAppraisedYield()); + Assert.assertEquals("AssessedYield", newDto.getAssessedYield(), fetchedDto.getAssessedYield()); + Assert.assertEquals("YieldToCount", newDto.getYieldToCount(), fetchedDto.getYieldToCount()); + Assert.assertEquals("YieldPercentPy", newDto.getYieldPercentPy(), fetchedDto.getYieldPercentPy()); + Assert.assertEquals("ProductionGuarantee", newDto.getProductionGuarantee(), fetchedDto.getProductionGuarantee()); + Assert.assertEquals("ProbableYield", newDto.getProbableYield(), fetchedDto.getProbableYield()); + + //FETCH + fetchedDto = dao.fetch(verifiedYieldSummaryGuid); + + Assert.assertEquals("VerifiedYieldSummaryGuid", newDto.getVerifiedYieldSummaryGuid(), fetchedDto.getVerifiedYieldSummaryGuid()); + Assert.assertEquals("VerifiedYieldContractGuid", newDto.getVerifiedYieldContractGuid(), fetchedDto.getVerifiedYieldContractGuid()); + Assert.assertEquals("CropCommodityId", newDto.getCropCommodityId(), fetchedDto.getCropCommodityId()); + Assert.assertEquals("CropCommodityName", newDto.getCropCommodityName(), fetchedDto.getCropCommodityName()); + Assert.assertEquals("IsPedigreeInd", newDto.getIsPedigreeInd(), fetchedDto.getIsPedigreeInd()); + Assert.assertEquals("HarvestedYield", newDto.getHarvestedYield(), fetchedDto.getHarvestedYield()); + Assert.assertEquals("HarvestedYieldPerAcre", newDto.getHarvestedYieldPerAcre(), fetchedDto.getHarvestedYieldPerAcre()); + Assert.assertEquals("AppraisedYield", newDto.getAppraisedYield(), fetchedDto.getAppraisedYield()); + Assert.assertEquals("AssessedYield", newDto.getAssessedYield(), fetchedDto.getAssessedYield()); + Assert.assertEquals("YieldToCount", newDto.getYieldToCount(), fetchedDto.getYieldToCount()); + Assert.assertEquals("YieldPercentPy", newDto.getYieldPercentPy(), fetchedDto.getYieldPercentPy()); + Assert.assertEquals("ProductionGuarantee", newDto.getProductionGuarantee(), fetchedDto.getProductionGuarantee()); + Assert.assertEquals("ProbableYield", newDto.getProbableYield(), fetchedDto.getProbableYield()); + + //UPDATE + fetchedDto.setCropCommodityId(18); + fetchedDto.setCropCommodityName("CANOLA"); + fetchedDto.setIsPedigreeInd(true); + fetchedDto.setHarvestedYield(120.0); + fetchedDto.setHarvestedYieldPerAcre(15.0); + fetchedDto.setAppraisedYield(2.5); + fetchedDto.setAssessedYield(1.5); + fetchedDto.setYieldToCount(10.5); + fetchedDto.setYieldPercentPy(85.5); + fetchedDto.setProductionGuarantee(11.5); + fetchedDto.setProbableYield(27.8); + + dao.update(fetchedDto, userId); + + //FETCH + VerifiedYieldSummaryDto updatedDto = dao.fetch(verifiedYieldSummaryGuid); + + Assert.assertEquals("VerifiedYieldSummaryGuid", fetchedDto.getVerifiedYieldSummaryGuid(), updatedDto.getVerifiedYieldSummaryGuid()); + Assert.assertEquals("VerifiedYieldContractGuid", fetchedDto.getVerifiedYieldContractGuid(), updatedDto.getVerifiedYieldContractGuid()); + Assert.assertEquals("CropCommodityId", fetchedDto.getCropCommodityId(), updatedDto.getCropCommodityId()); + Assert.assertEquals("CropCommodityName", fetchedDto.getCropCommodityName(), updatedDto.getCropCommodityName()); + Assert.assertEquals("IsPedigreeInd", fetchedDto.getIsPedigreeInd(), updatedDto.getIsPedigreeInd()); + Assert.assertEquals("HarvestedYield", fetchedDto.getHarvestedYield(), updatedDto.getHarvestedYield()); + Assert.assertEquals("HarvestedYieldPerAcre", fetchedDto.getHarvestedYieldPerAcre(), updatedDto.getHarvestedYieldPerAcre()); + Assert.assertEquals("AppraisedYield", fetchedDto.getAppraisedYield(), updatedDto.getAppraisedYield()); + Assert.assertEquals("AssessedYield", fetchedDto.getAssessedYield(), updatedDto.getAssessedYield()); + Assert.assertEquals("YieldToCount", fetchedDto.getYieldToCount(), updatedDto.getYieldToCount()); + Assert.assertEquals("YieldPercentPy", fetchedDto.getYieldPercentPy(), updatedDto.getYieldPercentPy()); + Assert.assertEquals("ProductionGuarantee", fetchedDto.getProductionGuarantee(), updatedDto.getProductionGuarantee()); + Assert.assertEquals("ProbableYield", fetchedDto.getProbableYield(), updatedDto.getProbableYield()); + + //INSERT second record + VerifiedYieldSummaryDto newDto2 = new VerifiedYieldSummaryDto(); + + newDto2.setVerifiedYieldContractGuid(verifiedYieldContractGuid); + newDto2.setCropCommodityId(16); + newDto2.setCropCommodityName("BARLEY"); + newDto2.setIsPedigreeInd(false); + newDto2.setHarvestedYield(100.0); + newDto2.setHarvestedYieldPerAcre(10.0); + newDto2.setAppraisedYield(1.5); + newDto2.setAssessedYield(0.5); + newDto2.setYieldToCount(15.5); + newDto2.setYieldPercentPy(75.5); + newDto2.setProductionGuarantee(20.5); + newDto2.setProbableYield(17.5); + + dao.insert(newDto2, userId); + + //SELECT + dtos = dao.selectForVerifiedYieldContract(verifiedYieldContractGuid); + Assert.assertNotNull(dtos); + Assert.assertEquals(2, dtos.size()); + + //DELETE + dao.delete(verifiedYieldSummaryGuid); + VerifiedYieldSummaryDto deletedDto = dao.fetch(verifiedYieldSummaryGuid); + Assert.assertNull(deletedDto); + + dao.deleteForVerifiedYieldContract(verifiedYieldContractGuid); + deletedDto = dao.fetch(newDto2.getVerifiedYieldSummaryGuid()); + Assert.assertNull(deletedDto); + + dtos = dao.selectForVerifiedYieldContract(verifiedYieldContractGuid); + Assert.assertNotNull(dtos); + Assert.assertEquals(0, dtos.size()); + } + + private void createVerifiedYieldContract(String userId) throws DaoException { + + VerifiedYieldContractDao dao = persistenceSpringConfig.verifiedYieldContractDao(); + + VerifiedYieldContractDto newDto = new VerifiedYieldContractDto(); + + newDto.setContractId(contractId); + newDto.setCropYear(cropYear); + newDto.setDeclaredYieldContractGuid(declaredYieldContractGuid); + newDto.setDefaultYieldMeasUnitTypeCode("TONNE"); + newDto.setInsurancePlanId(4); + + //INSERT + dao.insert(newDto, userId); + verifiedYieldContractGuid = newDto.getVerifiedYieldContractGuid(); + } + + private void createDeclaredYieldContract(String userId) throws DaoException { + + // Create parent Declared Yield Contract. + Calendar cal = Calendar.getInstance(); + cal.clear(); + cal.set(2020, Calendar.JANUARY, 15); + Date dopDate = cal.getTime(); + + DeclaredYieldContractDao dao = persistenceSpringConfig.declaredYieldContractDao(); + + DeclaredYieldContractDto newDto = new DeclaredYieldContractDto(); + + newDto.setContractId(contractId); + newDto.setCropYear(cropYear); + newDto.setDeclarationOfProductionDate(dopDate); + newDto.setDefaultYieldMeasUnitTypeCode("TONNE"); + newDto.setEnteredYieldMeasUnitTypeCode("BUSHEL"); + newDto.setGrainFromOtherSourceInd(true); + newDto.setBalerWagonInfo(null); + newDto.setTotalLivestock(null); + + //INSERT + dao.insert(newDto, userId); + declaredYieldContractGuid = newDto.getDeclaredYieldContractGuid(); + + } + + private void createInventoryContract(String userId) throws DaoException { + + //Date without time + Date date = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant()); + + InventoryContractDao invContractDao = persistenceSpringConfig.inventoryContractDao(); + + // Create parent InventoryContract. + InventoryContractDto invContractDto = new InventoryContractDto(); + + invContractDto.setContractId(contractId); + invContractDto.setCropYear(cropYear); + invContractDto.setFertilizerInd(false); + invContractDto.setGrainFromPrevYearInd(true); + invContractDto.setHerbicideInd(true); + invContractDto.setOtherChangesComment("Other changes comment"); + invContractDto.setOtherChangesInd(true); + invContractDto.setSeededCropReportSubmittedInd(false); + invContractDto.setTilliageInd(false); + invContractDto.setUnseededIntentionsSubmittedInd(false); + invContractDto.setInvUpdateTimestamp(date); + invContractDto.setInvUpdateUser(userId); + + invContractDao.insert(invContractDto, userId); + inventoryContractGuid = invContractDto.getInventoryContractGuid(); + } + + private void createGrowerContractYear() throws DaoException { + GrowerContractYearDao dao = persistenceSpringConfig.growerContractYearDao(); + GrowerContractYearDto newDto = new GrowerContractYearDto(); + + //Date and Time without millisecond + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.MILLISECOND, 0); //Set milliseconds to 0 becauce they are not set in the database + Date dateTime = cal.getTime(); + + String userId = "JUNIT_TEST"; + + //INSERT + newDto.setGrowerContractYearId(growerContractYearId); + newDto.setContractId(contractId); + newDto.setGrowerId(null); + newDto.setInsurancePlanId(4); + newDto.setCropYear(cropYear); + newDto.setDataSyncTransDate(dateTime); + + dao.insert(newDto, userId); + } + + private void createField(String fieldLabel, String userId) throws DaoException { + // INSERT FIELD + + Integer activeFromCropYear = 1980; + + FieldDao fieldDao = persistenceSpringConfig.fieldDao(); + FieldDto newFieldDto = new FieldDto(); + newFieldDto.setFieldId(fieldId); + newFieldDto.setFieldLabel(fieldLabel); + newFieldDto.setActiveFromCropYear(activeFromCropYear); + newFieldDto.setActiveToCropYear(null); + + fieldDao.insertDataSync(newFieldDto, userId); + } + +} diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasVerifiedYieldServiceImpl.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasVerifiedYieldServiceImpl.java index 06eb5ec4..f3e62480 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasVerifiedYieldServiceImpl.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/impl/CirrasVerifiedYieldServiceImpl.java @@ -18,9 +18,11 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.InventorySeededGrainDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.PolicyDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.ProductDao; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.UnderwritingCommentDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldAmendmentDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldContractCommodityDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldContractDao; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dao.VerifiedYieldSummaryDao; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContractedFieldDetailDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.DeclaredYieldContractCommodityDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.DeclaredYieldContractDto; @@ -28,9 +30,11 @@ import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventorySeededGrainDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.PolicyDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ProductDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.UnderwritingCommentDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldAmendmentDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractCommodityDto; import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractDto; +import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto; import ca.bc.gov.nrs.wfone.common.model.Message; import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; import ca.bc.gov.nrs.wfone.common.service.api.ConflictException; @@ -70,7 +74,9 @@ public class CirrasVerifiedYieldServiceImpl implements CirrasVerifiedYieldServic private VerifiedYieldContractDao verifiedYieldContractDao; private VerifiedYieldContractCommodityDao verifiedYieldContractCommodityDao; private VerifiedYieldAmendmentDao verifiedYieldAmendmentDao; + private VerifiedYieldSummaryDao verifiedYieldSummaryDao; private ProductDao productDao; + private UnderwritingCommentDao underwritingCommentDao; public void setApplicationProperties(Properties applicationProperties) { this.applicationProperties = applicationProperties; @@ -119,11 +125,18 @@ public void setVerifiedYieldContractCommodityDao(VerifiedYieldContractCommodityD public void setVerifiedYieldAmendmentDao(VerifiedYieldAmendmentDao verifiedYieldAmendmentDao) { this.verifiedYieldAmendmentDao = verifiedYieldAmendmentDao; } + + public void setVerifiedYieldSummaryDao(VerifiedYieldSummaryDao verifiedYieldSummaryDao) { + this.verifiedYieldSummaryDao = verifiedYieldSummaryDao; + } public void setProductDao(ProductDao productDao) { this.productDao = productDao; } - + + public void setUnderwritingCommentDao(UnderwritingCommentDao underwritingCommentDao) { + this.underwritingCommentDao = underwritingCommentDao; + } @Override public VerifiedYieldContract rolloverVerifiedYieldContract(Integer policyId, @@ -283,6 +296,7 @@ private void loadSeededGrains(InventoryFieldDto ifDto) throws DaoException { loadVerifiedYieldContractCommodities(dto); loadVerifiedYieldAmendments(dto); loadFields(dto); + loadVerifiedYieldSummaries(dto); return verifiedYieldContractFactory.getVerifiedYieldContract(dto, productDtos, factoryContext, authentication); } @@ -301,6 +315,22 @@ private void loadVerifiedYieldAmendments(VerifiedYieldContractDto dto) throws Da dto.setVerifiedYieldAmendments(verifiedAmendments); } + private void loadVerifiedYieldSummaries(VerifiedYieldContractDto dto) throws DaoException { + List verifiedSummaries = verifiedYieldSummaryDao.selectForVerifiedYieldContract(dto.getVerifiedYieldContractGuid()); + dto.setVerifiedYieldSummaries(verifiedSummaries); + + //Get comments + for (VerifiedYieldSummaryDto vyDto : dto.getVerifiedYieldSummaries()) { + loadUwComments(vyDto); + } + } + + private void loadUwComments(VerifiedYieldSummaryDto vyDto) throws DaoException { + //Returning all comments of a verified yield summary record + List uwComments = underwritingCommentDao.selectForVerifiedYieldSummary(vyDto.getVerifiedYieldSummaryGuid()); + vyDto.setUwComments(uwComments); + } + @Override public VerifiedYieldContract createVerifiedYieldContract( VerifiedYieldContract verifiedYieldContract, FactoryContext factoryContext, diff --git a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/spring/ServiceApiSpringConfig.java b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/spring/ServiceApiSpringConfig.java index 966e3fdb..37b9d83f 100644 --- a/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/spring/ServiceApiSpringConfig.java +++ b/cirras-underwriting-api/cirras-underwriting-service-api/src/main/java/ca/bc/gov/mal/cirras/underwriting/service/api/v1/spring/ServiceApiSpringConfig.java @@ -403,7 +403,9 @@ public CirrasVerifiedYieldService cirrasVerifiedYieldService() { result.setVerifiedYieldContractDao(persistenceSpringConfig.verifiedYieldContractDao()); result.setVerifiedYieldContractCommodityDao(persistenceSpringConfig.verifiedYieldContractCommodityDao()); result.setVerifiedYieldAmendmentDao(persistenceSpringConfig.verifiedYieldAmendmentDao()); + result.setVerifiedYieldSummaryDao(persistenceSpringConfig.verifiedYieldSummaryDao()); result.setProductDao(persistenceSpringConfig.productDao()); + result.setUnderwritingCommentDao(persistenceSpringConfig.underwritingCommentDao()); return result; } diff --git a/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/cirras.cuws.03_06_00_00.dml.json b/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/cirras.cuws.03_06_00_00.dml.json index 51e07773..7c5deba6 100644 --- a/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/cirras.cuws.03_06_00_00.dml.json +++ b/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/cirras.cuws.03_06_00_00.dml.json @@ -3,5 +3,6 @@ "databaseChangeLog": [ { "changeSet": {"author":"mhostettler","id":"88","changes": [ {"sqlFile": {"relativeToChangelogFile": "true", "path": "dml/cuws.insert.verified_yield_amendment_code.sql"}}, - {"sqlFile": {"relativeToChangelogFile": "true", "path": "dml/cuws.insert.crop_commodity_pedigree_xref.sql"}} + {"sqlFile": {"relativeToChangelogFile": "true", "path": "dml/cuws.insert.crop_commodity_pedigree_xref.sql"}}, + {"sqlFile": {"relativeToChangelogFile": "true", "path": "dml/cuws.insert.underwriting_comment_type_code.sql"}} ] } }]} diff --git a/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/dml/cuws.insert.underwriting_comment_type_code.sql b/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/dml/cuws.insert.underwriting_comment_type_code.sql new file mode 100644 index 00000000..cd1e9c59 --- /dev/null +++ b/cirras-underwriting-liquibase/scripts/03_00_xx/03_06_00/00/dml/cuws.insert.underwriting_comment_type_code.sql @@ -0,0 +1,21 @@ +\qecho Insert UW Comment Type Code Record; + +INSERT INTO cuws.underwriting_comment_type_code( + underwriting_comment_type_code, + description, + effective_date, + expiry_date, + create_user, + create_date, + update_user, + update_date +) +SELECT 'VY', + 'Verified Yield', + current_date, + '9999-12-31', + 'CUWS_01_00_00', + now(), + 'CUWS_01_00_00', + now() +WHERE NOT EXISTS (SELECT underwriting_comment_type_code FROM underwriting_comment_type_code WHERE underwriting_comment_type_code = 'VY'); From f7e949d6101d277c0a499894553ebe45652e8133 Mon Sep 17 00:00:00 2001 From: David Pitkin Date: Thu, 19 Dec 2024 10:41:07 -0800 Subject: [PATCH 09/11] PIM-1839: Unit tests. --- .../v1/endpoints/UwContractEndpointTest.java | 408 +++++++++++++++++- 1 file changed, 405 insertions(+), 3 deletions(-) diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java index 3bb0e4b0..b3fc69d0 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/UwContractEndpointTest.java @@ -1,5 +1,6 @@ package ca.bc.gov.mal.cirras.underwriting.api.rest.v1.endpoints; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -12,20 +13,29 @@ import org.slf4j.LoggerFactory; import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.LandManagementEventTypes; +import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.InventoryServiceEnums.ScreenType; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.PoliciesSyncEventTypes; import ca.bc.gov.mal.cirras.underwriting.api.rest.client.v1.CirrasUnderwritingService; import ca.bc.gov.mal.cirras.underwriting.api.rest.client.v1.CirrasUnderwritingServiceException; import ca.bc.gov.mal.cirras.underwriting.api.rest.client.v1.ValidationException; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.endpoints.security.Scopes; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.AnnualFieldDetailRsrc; +import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.AnnualFieldRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.ContractedFieldDetailRsrc; +import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.DopYieldContractRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.EndpointsRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.FieldRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.GrowerContractYearSyncRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.GrowerRsrc; +import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.InventoryContractRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.PolicyRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.UwContractListRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.UwContractRsrc; +import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.VerifiedYieldContractRsrc; +import ca.bc.gov.mal.cirras.underwriting.model.v1.InventoryContractCommodity; +import ca.bc.gov.mal.cirras.underwriting.model.v1.InventoryField; +import ca.bc.gov.mal.cirras.underwriting.model.v1.InventorySeededGrain; +import ca.bc.gov.mal.cirras.underwriting.model.v1.OtherYearPolicy; import ca.bc.gov.mal.cirras.underwriting.api.rest.test.EndpointsTest; import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; @@ -39,7 +49,18 @@ public class UwContractEndpointTest extends EndpointsTest { Scopes.GET_TOP_LEVEL, Scopes.SEARCH_UWCONTRACTS, Scopes.GET_UWCONTRACT, + Scopes.CREATE_INVENTORY_CONTRACT, + Scopes.DELETE_INVENTORY_CONTRACT, + Scopes.GET_INVENTORY_CONTRACT, + Scopes.UPDATE_INVENTORY_CONTRACT, + Scopes.CREATE_DOP_YIELD_CONTRACT, + Scopes.DELETE_DOP_YIELD_CONTRACT, Scopes.GET_DOP_YIELD_CONTRACT, + Scopes.UPDATE_DOP_YIELD_CONTRACT, + Scopes.GET_VERIFIED_YIELD_CONTRACT, + Scopes.CREATE_VERIFIED_YIELD_CONTRACT, + Scopes.UPDATE_VERIFIED_YIELD_CONTRACT, + Scopes.DELETE_VERIFIED_YIELD_CONTRACT, Scopes.CREATE_SYNC_UNDERWRITING, Scopes.UPDATE_SYNC_UNDERWRITING, Scopes.DELETE_SYNC_UNDERWRITING, @@ -65,6 +86,16 @@ public class UwContractEndpointTest extends EndpointsTest { private String policyNumber2 = "998899-20"; private String contractNumber2 = "998899"; private Integer growerContractYearId2 = 90000008; + private Integer cropYear2 = 2020; + + // Note that policy 3 is deliberately meant to have the same contract as policy 2. + private Integer contractId3 = 90000006; + private Integer policyId3 = 90000013; + private String policyNumber3 = "998899-19"; + private String contractNumber3 = "998899"; + private Integer growerContractYearId3 = 90000014; + private Integer cropYear3 = 2019; + // Field private Integer fieldId1 = 90000009; @@ -88,12 +119,17 @@ public void cleanUp() throws CirrasUnderwritingServiceException, NotFoundDaoExce } private void delete() throws NotFoundDaoException, DaoException, CirrasUnderwritingServiceException { - + + deleteVerifiedYieldContract(policyNumber3); + deleteDopYieldContract(policyNumber3); + deleteInventoryContract(policyNumber3); + service.deleteContractedFieldDetail(topLevelEndpoints, contractedFieldDetailId1.toString()); service.deleteContractedFieldDetail(topLevelEndpoints, contractedFieldDetailId2.toString()); service.deleteGrowerContractYear(topLevelEndpoints, growerContractYearId1.toString()); service.deleteGrowerContractYear(topLevelEndpoints, growerContractYearId2.toString()); + service.deleteGrowerContractYear(topLevelEndpoints, growerContractYearId3.toString()); service.deleteAnnualFieldDetail(topLevelEndpoints, annualFieldDetailId1.toString()); @@ -101,10 +137,98 @@ private void delete() throws NotFoundDaoException, DaoException, CirrasUnderwrit service.deletePolicy(topLevelEndpoints, policyId1.toString()); service.deletePolicy(topLevelEndpoints, policyId2.toString()); + service.deletePolicy(topLevelEndpoints, policyId3.toString()); service.deleteGrower(topLevelEndpoints, growerId1.toString()); service.deleteGrower(topLevelEndpoints, growerId2.toString()); } + + private void deleteVerifiedYieldContract(String policyNumber) throws NotFoundDaoException, DaoException, CirrasUnderwritingServiceException { + + Integer pageNumber = 1; + Integer pageRowCount = 20; + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, pageRowCount); + + if ( searchResults.getCollection() != null && searchResults.getCollection().size() == 1 ) { + UwContractRsrc referrer = searchResults.getCollection().get(0); + + if ( referrer.getVerifiedYieldContractGuid() != null ) { + VerifiedYieldContractRsrc verifiedContract = service.getVerifiedYieldContract(referrer); + service.deleteVerifiedYieldContract(verifiedContract); + } + } + } + + private void deleteDopYieldContract(String policyNumber) throws NotFoundDaoException, DaoException, CirrasUnderwritingServiceException { + + Integer pageNumber = 1; + Integer pageRowCount = 20; + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, pageRowCount); + + if ( searchResults.getCollection() != null && searchResults.getCollection().size() == 1 ) { + UwContractRsrc referrer = searchResults.getCollection().get(0); + + if ( referrer.getDeclaredYieldContractGuid() != null ) { + DopYieldContractRsrc dopContract = service.getDopYieldContract(referrer); + service.deleteDopYieldContract(dopContract); + } + } + } + + public void deleteInventoryContract(String policyNumber) + throws CirrasUnderwritingServiceException { + + Integer pageNumber = 1; + Integer pageRowCount = 20; + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, + pageRowCount); + + if ( searchResults.getCollection() != null && searchResults.getCollection().size() == 1 ) { + UwContractRsrc referrer = searchResults.getCollection().get(0); + + if ( referrer.getInventoryContractGuid() != null ) { + InventoryContractRsrc invContract = service.getInventoryContract(referrer); + service.deleteInventoryContract(invContract); + } + } + } + private void createField(Integer fieldId, String fieldLabel, Integer activeFromCropYear, Integer activeToCropYear) throws CirrasUnderwritingServiceException, ValidationException { @@ -168,7 +292,7 @@ private void createGrowerContractYear( resource.setCropYear(cropYear); resource.setDataSyncTransDate(createTransactionDate); resource.setTransactionType(PoliciesSyncEventTypes.GrowerContractYearCreated); - + service.synchronizeGrowerContractYear(resource); } @@ -228,8 +352,169 @@ private void createGrower(Integer growerId, Integer growerNumber, String growerN service.synchronizeGrower(resource); } + private String createInventoryContract(String policyNumber) throws ValidationException, CirrasUnderwritingServiceException { + + boolean addedSeededGrain = false; + + Integer pageNumber = 1; + Integer pageRowCount = 20; + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, pageRowCount); + + Assert.assertNotNull(searchResults); + Assert.assertEquals(1, searchResults.getCollection().size()); + + UwContractRsrc referrer = searchResults.getCollection().get(0); + Assert.assertNull(referrer.getInventoryContractGuid()); + + InventoryContractRsrc resource = service.rolloverInventoryContract(referrer); + + for ( AnnualFieldRsrc field : resource.getFields() ) { + for ( InventoryField planting : field.getPlantings() ) { + List seededGrains = new ArrayList(); + seededGrains.add(createInventorySeededGrain(16, "BARLEY", false, 23.45)); + + planting.setInventorySeededGrains(seededGrains); + + addedSeededGrain = true; + } + } + + InventoryContractCommodity icc = createInventoryContractCommodity(16, "BARLEY", false, 23.45, 23.45, 0.0); + resource.getCommodities().add(icc); + + Assert.assertTrue(addedSeededGrain); + + return service.createInventoryContract(topLevelEndpoints, resource).getInventoryContractGuid(); + } + + private InventorySeededGrain createInventorySeededGrain(Integer cropCommodityId, String cropCommodityName, Boolean isPedigreeInd, Double seededAcres) { + Calendar cal = Calendar.getInstance(); + cal.clear(); + cal.set(2020, Calendar.JANUARY, 15); + Date seededDate = cal.getTime(); + + InventorySeededGrain invSeededGrain = new InventorySeededGrain(); + + invSeededGrain.setCommodityTypeCode("Two Row"); + invSeededGrain.setCommodityTypeDesc("Two Row Standard"); + invSeededGrain.setCropCommodityId(cropCommodityId); + invSeededGrain.setCropCommodityName(cropCommodityName); + invSeededGrain.setCropVarietyId(1010430); + invSeededGrain.setCropVarietyName("CHAMPION"); + invSeededGrain.setInventoryFieldGuid(null); + invSeededGrain.setInventorySeededGrainGuid(null); + invSeededGrain.setIsPedigreeInd(isPedigreeInd); + invSeededGrain.setIsSpotLossInsurableInd(true); + invSeededGrain.setIsQuantityInsurableInd(true); + invSeededGrain.setIsReplacedInd(false); + invSeededGrain.setSeededAcres(seededAcres); + invSeededGrain.setSeededDate(seededDate); + return invSeededGrain; + } + + private InventoryContractCommodity createInventoryContractCommodity(Integer cropCommodityId, String cropCommodityName, Boolean isPedigreeInd, Double totalSeededAcres, Double totalSpotLossAcres, Double totalUnseededAcres) { + + InventoryContractCommodity icc = new InventoryContractCommodity(); + icc.setCropCommodityId(cropCommodityId); + icc.setCropCommodityName(cropCommodityName); + icc.setInventoryContractCommodityGuid(null); + icc.setInventoryContractGuid(null); + icc.setIsPedigreeInd(isPedigreeInd); + icc.setTotalSeededAcres(totalSeededAcres); + icc.setTotalSpotLossAcres(totalSpotLossAcres); + icc.setTotalUnseededAcres(totalUnseededAcres); + icc.setTotalUnseededAcresOverride(null); + + return icc; + } + private String createDopYieldContract(String policyNumber) throws ValidationException, CirrasUnderwritingServiceException { + + // Dop Date + Calendar cal = Calendar.getInstance(); + cal.clear(); + cal.set(2020, Calendar.JANUARY, 15); + Date dopDate = cal.getTime(); + + Integer pageNumber = 1; + Integer pageRowCount = 20; + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, pageRowCount); + + Assert.assertNotNull(searchResults); + Assert.assertEquals(1, searchResults.getCollection().size()); + + UwContractRsrc referrer = searchResults.getCollection().get(0); + Assert.assertNotNull(referrer.getInventoryContractGuid()); + Assert.assertNull(referrer.getDeclaredYieldContractGuid()); + + DopYieldContractRsrc resource = service.rolloverDopYieldContract(referrer); + + resource.setDeclarationOfProductionDate(dopDate); + resource.setDefaultYieldMeasUnitTypeCode("TONNE"); + resource.setEnteredYieldMeasUnitTypeCode("TONNE"); + resource.setGrainFromOtherSourceInd(true); + + return service.createDopYieldContract(topLevelEndpoints, resource).getDeclaredYieldContractGuid(); + } + + private String createVerifiedYieldContract(String policyNumber) throws ValidationException, CirrasUnderwritingServiceException { + + Integer pageNumber = 1; + Integer pageRowCount = 20; + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, pageRowCount); + + Assert.assertNotNull(searchResults); + Assert.assertEquals(1, searchResults.getCollection().size()); + + UwContractRsrc referrer = searchResults.getCollection().get(0); + Assert.assertNotNull(referrer.getInventoryContractGuid()); + Assert.assertNotNull(referrer.getDeclaredYieldContractGuid()); + Assert.assertNull(referrer.getVerifiedYieldContractGuid()); + + VerifiedYieldContractRsrc resource = service.rolloverVerifiedYieldContract(referrer); + + resource.setDefaultYieldMeasUnitTypeCode("TONNE"); + + return service.createVerifiedYieldContract(topLevelEndpoints, resource).getVerifiedYieldContractGuid(); + } + @Test public void testGetUwContract() throws CirrasUnderwritingServiceException, Oauth2ClientException { @@ -413,7 +698,124 @@ private void checkUwContractList(List uwContracts, Integer... ex Assert.assertEquals(expectedPolicyIds[i], uwContracts.get(i).getPolicyId()); } } - + + @Test + public void testGetUwContractLoadOtherYearPolicies() throws CirrasUnderwritingServiceException, Oauth2ClientException, ValidationException, DaoException { + logger.debug("testGetUwContractLoadOtherYearPolicies"); + } + @Test public void testUwContractDopEligibleInventory() throws CirrasUnderwritingServiceException, Oauth2ClientException { From e476b494e85c46b7812cc7c519220bdcdb1e72ed Mon Sep 17 00:00:00 2001 From: Michael Hostettler Date: Thu, 19 Dec 2024 11:02:09 -0800 Subject: [PATCH 10/11] PIM-1807: Implementing data load of verified yield summary, unit tests --- .../factory/InventoryContractRsrcFactory.java | 1 + ...erifiedYieldContractEndpointGrainTest.java | 1 + .../VerifiedYieldContractEndpointTest.java | 251 ++++++++++++++++++ .../model/v1/UnderwritingComment.java | 9 + 4 files changed, 262 insertions(+) diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/InventoryContractRsrcFactory.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/InventoryContractRsrcFactory.java index cb63792b..02fb75de 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/InventoryContractRsrcFactory.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/main/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/resource/factory/InventoryContractRsrcFactory.java @@ -421,6 +421,7 @@ static UnderwritingComment createUnderwritingComment(UnderwritingCommentDto dto, model.setUnderwritingCommentTypeCode(dto.getUnderwritingCommentTypeCode()); model.setUnderwritingCommentTypeDesc(dto.getUnderwritingCommentTypeDesc()); model.setDeclaredYieldContractGuid(dto.getDeclaredYieldContractGuid()); + model.setVerifiedYieldSummaryGuid(dto.getVerifiedYieldSummaryGuid()); model.setGrowerContractYearId(dto.getGrowerContractYearId()); model.setUpdateDate(dto.getUpdateDate()); model.setUpdateUser(dto.getUpdateUser()); diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointGrainTest.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointGrainTest.java index 17385423..774e1b1d 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointGrainTest.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointGrainTest.java @@ -1359,6 +1359,7 @@ VerifiedYieldAmendment createVerifiedYieldAmendment( return vya; } + private static Date addSeconds(Date date, Integer seconds) { Calendar cal = Calendar.getInstance(); diff --git a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointTest.java b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointTest.java index 0dee2074..812f308b 100644 --- a/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointTest.java +++ b/cirras-underwriting-api/cirras-underwriting-api-rest-endpoints/src/test/java/ca/bc/gov/mal/cirras/underwriting/api/rest/v1/endpoints/VerifiedYieldContractEndpointTest.java @@ -18,8 +18,10 @@ import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.UwContractListRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.UwContractRsrc; import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.VerifiedYieldContractRsrc; +import ca.bc.gov.mal.cirras.underwriting.model.v1.UnderwritingComment; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldAmendment; import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContractCommodity; +import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldSummary; import ca.bc.gov.mal.cirras.underwriting.api.rest.test.EndpointsTest; import ca.bc.gov.nrs.wfone.common.persistence.dao.DaoException; import ca.bc.gov.nrs.wfone.common.persistence.dao.NotFoundDaoException; @@ -475,6 +477,197 @@ insert into verified_yield_contract_commodity( */ } + @Test + public void testGetVerifiedYieldSummeries() throws CirrasUnderwritingServiceException, Oauth2ClientException { + logger.debug(" expectedVys = new ArrayList(); + VerifiedYieldSummary vys = new VerifiedYieldSummary(); + + vys.setVerifiedYieldSummaryGuid("vys-guid-1"); + vys.setVerifiedYieldContractGuid("vyc-guid"); + vys.setCropCommodityId(16); + vys.setCropCommodityName("BARLEY"); + vys.setIsPedigreeInd(true); + vys.setHarvestedYield(100.5); + vys.setHarvestedYieldPerAcre(11.5); + vys.setAppraisedYield(1.3); + vys.setAssessedYield(2.0); + vys.setYieldToCount(111.5); + vys.setYieldPercentPy(75.5); + vys.setProductionGuarantee(55.5); + vys.setProbableYield(17.5); + + List expectedComments = new ArrayList(); + UnderwritingComment uw = new UnderwritingComment(); + uw.setUnderwritingCommentGuid("uw-guid-1"); + uw.setUnderwritingCommentTypeCode("VY"); + uw.setUnderwritingComment("comment 1"); + uw.setVerifiedYieldSummaryGuid(vys.getVerifiedYieldSummaryGuid()); + + expectedComments.add(uw); + vys.setUwComments(expectedComments); + + expectedVys.add(vys); + + vys = new VerifiedYieldSummary(); + vys.setVerifiedYieldSummaryGuid("vys-guid-2"); + vys.setVerifiedYieldContractGuid("vyc-guid"); + vys.setCropCommodityId(18); + vys.setCropCommodityName("CANOLA"); + vys.setIsPedigreeInd(false); + vys.setHarvestedYield(101.5); + vys.setHarvestedYieldPerAcre(12.5); + vys.setAppraisedYield(2.3); + vys.setAssessedYield(3.0); + vys.setYieldToCount(112.5); + vys.setYieldPercentPy(76.5); + vys.setProductionGuarantee(56.5); + vys.setProbableYield(18.5); + + expectedVys.add(vys); + + + Integer pageNumber = (1); + Integer pageRowCount = (20); + + UwContractListRsrc searchResults = service.getUwContractList( + topLevelEndpoints, + null, + null, + null, + null, + policyNumber, + null, + null, + null, + null, + pageNumber, pageRowCount); + + Assert.assertNotNull(searchResults); + Assert.assertEquals(1, searchResults.getCollection().size()); + + UwContractRsrc referrer = searchResults.getCollection().get(0); + Assert.assertNotNull(referrer.getDeclaredYieldContractGuid()); + Assert.assertNotNull(referrer.getVerifiedYieldContractGuid()); + + VerifiedYieldContractRsrc verifiedYldContract = service.getVerifiedYieldContract(referrer); + Assert.assertNotNull(verifiedYldContract); + + checkVerifiedYieldSummaries(expectedVys, verifiedYldContract.getVerifiedYieldSummaries()); + + //***************************************************************** + //AFTER TESTS: DELETE LAND, INVENTORY AND YIELD BY RUNNING THE DELETE SCRIPTS BELOW + //***************************************************************** + + logger.debug(">testGetVerifiedYieldSummeries"); + + /* + * + ***************** + INSERT STATEMENTS + ***************** + -- Declared Yield Contract + INSERT INTO cuws.declared_yield_contract( + declared_yield_contract_guid, + contract_id, crop_year, + declaration_of_production_date, + dop_update_timestamp, + dop_update_user, + entered_yield_meas_unit_type_code, + default_yield_meas_unit_type_code, + grain_from_other_source_ind, + create_user, + create_date, + update_user, + update_date, + baler_wagon_info, + total_livestock) + VALUES ('dyc-guid', + 3939, + 2023, + now(), + now(), + 'admin', + 'BUSHEL', + 'TONNE', + 'N', + 'admin', + now(), + 'admin', + now(), + null, + null); + + -- Verified Yield Contract + insert into verified_yield_contract( + verified_yield_contract_guid, + contract_id, + crop_year, + declared_yield_contract_guid, + default_yield_meas_unit_type_code, + verified_yield_update_timestamp, + verified_yield_update_user, + create_user, + create_date, + update_user, + update_date + ) values ( + 'vyc-guid', + 3939, + 2023, + 'dyc-guid', + 'TONNE', + now(), + 'admin', + 'admin', + now(), + 'admin', + now() + ); + + --Verified Yield Summary + INSERT INTO cuws.verified_yield_summary( + verified_yield_summary_guid, verified_yield_contract_guid, crop_commodity_id, is_pedigree_ind, harvested_yield, harvested_yield_per_acre, appraised_yield, assessed_yield, yield_to_count, yield_percent_py, production_guarantee, probable_yield, create_user, create_date, update_user, update_date) + VALUES ('vys-guid-1', 'vyc-guid', 16, 'Y', 100.5, 11.5, 1.3, 2.0, 111.5, 75.5, 55.5, 17.5, 'admin', now(), 'admin', now()); + + INSERT INTO cuws.verified_yield_summary( + verified_yield_summary_guid, verified_yield_contract_guid, crop_commodity_id, is_pedigree_ind, harvested_yield, harvested_yield_per_acre, appraised_yield, assessed_yield, yield_to_count, yield_percent_py, production_guarantee, probable_yield, create_user, create_date, update_user, update_date) + VALUES ('vys-guid-2', 'vyc-guid', 18, 'N', 101.5, 12.5, 2.3, 3.0, 112.5, 76.5, 56.5, 18.5, 'admin', now(), 'admin', now()); + + --Comment + INSERT INTO cuws.underwriting_comment(underwriting_comment_guid, underwriting_comment_type_code, underwriting_comment, verified_yield_summary_guid, create_user, create_date, update_user, update_date) + VALUES ('uw-guid-1', 'VY', 'comment 1', 'vys-guid-1', 'admin', now(), 'admin', now()); + + delete from underwriting_comment where verified_yield_summary_guid = 'vys-guid-1'; + delete from verified_yield_summary where verified_yield_contract_guid = 'vyc-guid'; + delete from verified_yield_contract where verified_yield_contract_guid = 'vyc-guid'; + delete from declared_yield_contract where declared_yield_contract_guid = 'dyc-guid'; + + + ***************** + SELECT STATEMENTS + ***************** + select * from declared_yield_contract where declared_yield_contract_guid = 'dyc-guid'; + select * from verified_yield_contract vyc where vyc.verified_yield_contract_guid = 'vyc-guid'; + select * from verified_yield_summary vycc where vycc.verified_yield_contract_guid = 'vyc-guid'; + select * from underwriting_comment where verified_yield_summary_guid = 'vys-guid-1'; + + +*/ + } + private void checkVerifiedYieldContract(VerifiedYieldContractRsrc expected, VerifiedYieldContractRsrc actual) { @@ -488,6 +681,64 @@ private void checkVerifiedYieldContract(VerifiedYieldContractRsrc expected, Veri Assert.assertNotNull(actual.getVerifiedYieldUpdateUser()); Assert.assertNotNull(actual.getVerifiedYieldUpdateTimestamp()); } + + private void checkVerifiedYieldSummaries(List expected, List actual) { + if ( expected == null && actual != null || expected != null && actual == null ) { + Assert.fail(); + } else if ( expected != null && actual != null ) { + Assert.assertEquals(expected.size(), actual.size()); + for (VerifiedYieldSummary expectedVys : expected) { + VerifiedYieldSummary actualVys = getVerifiedYieldSummary(expectedVys.getCropCommodityId(), expectedVys.getIsPedigreeInd(), actual); + Assert.assertNotNull(actualVys); + checkVerifiedYieldSummary(expectedVys, actualVys); + } + } + + } + + private VerifiedYieldSummary getVerifiedYieldSummary(Integer cropCommodityId, Boolean isPedigree, List vysList) { + + VerifiedYieldSummary vys = null; + + List vysFiltered = vysList.stream() + .filter(x -> x.getCropCommodityId().equals(cropCommodityId) && x.getIsPedigreeInd().equals(isPedigree) ) + .collect(Collectors.toList()); + + if (vysFiltered != null && vysFiltered.size() > 0) { + vys = vysFiltered.get(0); + } + return vys; + } + + private void checkVerifiedYieldSummary(VerifiedYieldSummary expected, VerifiedYieldSummary actual) { + Assert.assertEquals(expected.getVerifiedYieldSummaryGuid(), actual.getVerifiedYieldSummaryGuid()); + Assert.assertEquals(expected.getVerifiedYieldContractGuid(), actual.getVerifiedYieldContractGuid()); + Assert.assertEquals(expected.getCropCommodityId(), actual.getCropCommodityId()); + Assert.assertEquals(expected.getCropCommodityName(), actual.getCropCommodityName()); + Assert.assertEquals(expected.getIsPedigreeInd(), actual.getIsPedigreeInd()); + Assert.assertEquals(expected.getHarvestedYield(), actual.getHarvestedYield()); + Assert.assertEquals(expected.getHarvestedYieldPerAcre(), actual.getHarvestedYieldPerAcre()); + Assert.assertEquals(expected.getAppraisedYield(), actual.getAppraisedYield()); + Assert.assertEquals(expected.getAssessedYield(), actual.getAssessedYield()); + Assert.assertEquals(expected.getYieldToCount(), actual.getYieldToCount()); + Assert.assertEquals(expected.getYieldPercentPy(), actual.getYieldPercentPy()); + Assert.assertEquals(expected.getProductionGuarantee(), actual.getProductionGuarantee()); + Assert.assertEquals(expected.getProbableYield(), actual.getProbableYield()); + + if (expected.getUwComments() != null && expected.getUwComments().size() > 0) { + Assert.assertNotNull(actual.getUwComments()); + Assert.assertEquals(1, actual.getUwComments().size()); + UnderwritingComment expectedComment = expected.getUwComments().get(0); + UnderwritingComment actualComment = actual.getUwComments().get(0); + + Assert.assertEquals(expectedComment.getUnderwritingCommentGuid(), actualComment.getUnderwritingCommentGuid()); + Assert.assertEquals(expectedComment.getUnderwritingCommentTypeCode(), actualComment.getUnderwritingCommentTypeCode()); + Assert.assertEquals(expectedComment.getUnderwritingComment(), actualComment.getUnderwritingComment()); + Assert.assertEquals(expectedComment.getVerifiedYieldSummaryGuid(), actualComment.getVerifiedYieldSummaryGuid()); + } + + } + private void checkVerifiedYieldAmendments(List expected, List actual) { if ( expected == null && actual != null || expected != null && actual == null ) { diff --git a/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UnderwritingComment.java b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UnderwritingComment.java index aefe4287..07f14a6c 100644 --- a/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UnderwritingComment.java +++ b/cirras-underwriting-api/cirras-underwriting-model/src/main/java/ca/bc/gov/mal/cirras/underwriting/model/v1/UnderwritingComment.java @@ -17,6 +17,7 @@ public class UnderwritingComment implements Serializable { private String underwritingComment; private Integer growerContractYearId; private String declaredYieldContractGuid; + private String verifiedYieldSummaryGuid; private String createUser; private Date createDate; private String updateUser; @@ -75,6 +76,14 @@ public String getDeclaredYieldContractGuid() { public void setDeclaredYieldContractGuid(String declaredYieldContractGuid) { this.declaredYieldContractGuid = declaredYieldContractGuid; } + + public String getVerifiedYieldSummaryGuid() { + return verifiedYieldSummaryGuid; + } + + public void setVerifiedYieldSummaryGuid(String verifiedYieldSummaryGuid) { + this.verifiedYieldSummaryGuid = verifiedYieldSummaryGuid; + } public String getCreateUser() { return createUser; From 7049028c211ba6e9b7068c0492c9075cc17e0868 Mon Sep 17 00:00:00 2001 From: Vividsolutions/esnauffer Date: Thu, 19 Dec 2024 19:04:01 -0800 Subject: [PATCH 11/11] PIM-1831: Create Dropdown to select another year while in a specific policy - Frontend --- .../src/main/angular/src/app/app.module.ts | 2 + .../dop/forage/forage-dop.component.ts | 7 +- .../dop/grain/grain-dop.component.ts | 7 +- .../grower-contract-header.component.html | 5 +- .../grower-contract-header.component.ts | 1 - .../other-year-policy.component.html | 6 +- .../other-year-policy.component.scss | 14 +-- .../other-year-policy.component.ts | 114 ++++++++++++++---- .../inventory-selector.component.ts | 4 +- .../link-planting/link-planting.component.ts | 4 +- .../verified-yield.component.ts | 4 +- .../angular/src/app/store/dop/dop.actions.ts | 11 +- .../angular/src/app/store/dop/dop.effects.ts | 10 +- .../grower-contract.actions.ts | 6 +- .../grower-contract.effects.ts | 9 +- .../app/store/inventory/inventory.effects.ts | 8 +- .../verified-yield/verified-yield.effects.ts | 10 +- .../main/angular/src/app/utils/constants.ts | 5 + 18 files changed, 158 insertions(+), 69 deletions(-) diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/app.module.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/app.module.ts index 876b17b4..cdf2ec18 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/app.module.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/app.module.ts @@ -140,6 +140,7 @@ import { VerifiedYieldCommodityListComponent } from './components/verified-yield import { VerifiedYieldCommodityComponent } from './components/verified-yield/commodity/verified-yield-commodity.component'; import { VerifiedYieldAmendmentListComponent } from "./components/verified-yield/amendment-list/verified-yield-amendment-list.component"; import { VerifiedYieldAmendmentComponent } from "./components/verified-yield/amendment/verified-yield-amendment.component"; +import { OtherYearPolicyComponent } from "./components/grower-contract-header/other-year-policy/other-year-policy.component"; /** * Function that initializes the Configuration injector with the application base url from the app config service. @@ -225,6 +226,7 @@ if (!environment.production || !environment.restrict_imports) { YieldConversionUnitsComponent, YieldConversionUnitsContainer, RelatedPoliciesComponent, + OtherYearPolicyComponent, UnsavedDialogComponent, ForageDopComponent, ForageDopFieldListComponent, diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/forage/forage-dop.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/forage/forage-dop.component.ts index e444b3b9..99feea18 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/forage/forage-dop.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/forage/forage-dop.component.ts @@ -24,6 +24,7 @@ import { setFormStateUnsaved } from 'src/app/store/application/application.actio import {ViewEncapsulation } from '@angular/core'; import { displaySuccessSnackbar } from 'src/app/utils/user-feedback-utils'; import { UnderwritingComment } from '@cirras/cirras-underwriting-api'; +import { SCREEN_TYPE } from 'src/app/utils/constants'; @Component({ selector: 'forage-dop', @@ -71,7 +72,7 @@ export class ForageDopComponent extends BaseComponent { this.store.dispatch(ClearDopYieldContract()); - this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId)) + this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId, SCREEN_TYPE.DOP)) this.store.dispatch( LoadYieldMeasUnitList(this.componentId, this.insurancePlanId) ) @@ -301,10 +302,10 @@ export class ForageDopComponent extends BaseComponent { } if (this.dopYieldContract.declaredYieldContractGuid) { - this.store.dispatch(UpdateDopYieldContract(DOP_COMPONENT_ID, this.dopYieldContract)) + this.store.dispatch(UpdateDopYieldContract(DOP_COMPONENT_ID, this.dopYieldContract, this.policyId)) } else { // add new - this.store.dispatch(AddNewDopYieldContract(DOP_COMPONENT_ID, this.dopYieldContract)) + this.store.dispatch(AddNewDopYieldContract(DOP_COMPONENT_ID, this.dopYieldContract, this.policyId)) } this.store.dispatch(setFormStateUnsaved(DOP_COMPONENT_ID, false )); diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/grain/grain-dop.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/grain/grain-dop.component.ts index 58f917a1..6d0dd0fd 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/grain/grain-dop.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/dop/grain/grain-dop.component.ts @@ -24,6 +24,7 @@ import {ViewEncapsulation } from '@angular/core'; import { GradeModifierOptionsType } from '../dop-common'; import { displaySuccessSnackbar } from 'src/app/utils/user-feedback-utils'; import { roundUpDecimalYield } from '../../inventory/inventory-common'; +import { SCREEN_TYPE } from 'src/app/utils/constants'; @Component({ selector: 'grain-dop', @@ -82,7 +83,7 @@ export class GrainDopComponent extends BaseComponent{ this.store.dispatch(ClearDopYieldContract()); - this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId)) + this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId, SCREEN_TYPE.DOP)) this.store.dispatch( LoadYieldMeasUnitList(this.componentId, this.insurancePlanId) ) @@ -714,10 +715,10 @@ export class GrainDopComponent extends BaseComponent{ const newDopYieldContract: DopYieldContract = this.getUpdatedDopYieldContract() if (this.dopYieldContract.declaredYieldContractGuid) { - this.store.dispatch(UpdateDopYieldContract(DOP_COMPONENT_ID, newDopYieldContract)) + this.store.dispatch(UpdateDopYieldContract(DOP_COMPONENT_ID, newDopYieldContract, this.policyId)) } else { // add new - this.store.dispatch(AddNewDopYieldContract(DOP_COMPONENT_ID, newDopYieldContract)) + this.store.dispatch(AddNewDopYieldContract(DOP_COMPONENT_ID, newDopYieldContract, this.policyId)) } this.hasDataChanged = false diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html index 35cf53d3..b3a384dd 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.html @@ -102,7 +102,10 @@
- +
{{ (growerContract && growerContract.growerPrimaryEmail) ? growerContract.growerPrimaryEmail : "" }} diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.ts index d501990c..4415adab 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/grower-contract-header.component.ts @@ -12,7 +12,6 @@ import { Router } from '@angular/router'; changeDetection: ChangeDetectionStrategy.OnPush }) export class GrowerContractHeaderComponent { - @Input() growerContract: UwContract; constructor( diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html index 56562145..99223787 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.html @@ -1,11 +1,11 @@
- + - {{ option.description }} + {{ option }} diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss index 6676edf8..3e1d504a 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.scss @@ -1,10 +1,10 @@ -@import '../../../styles/variables'; +@import '../../../../styles/variables'; .other-year-policy{ .mat-mdc-text-field-wrapper { - width: 100px; - height: 36px; + width: 70px; + height: 30px; padding-left: 6px; border: 0.5px solid rgba(194, 194, 194, 1) !important; border-radius: 5px !important; @@ -12,13 +12,13 @@ .mat-mdc-form-field-flex { width: 50px; - height: 36px; + height: 30px; } .mat-mdc-form-field-infix { - width: 505px !important; - min-height: 36px; + width: 50px !important; + min-height: 30px; } .mat-mdc-select{ @@ -26,7 +26,7 @@ } .mdc-text-field--outlined .mat-mdc-form-field-infix { - padding-top: 7px; + padding-top: 3px; } } \ No newline at end of file diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts index 74a68553..55ce7683 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/grower-contract-header/other-year-policy/other-year-policy.component.ts @@ -1,7 +1,9 @@ -import { ChangeDetectionStrategy, Component, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { Router } from '@angular/router'; +import { OtherYearPolicy } from 'src/app/conversion/models'; import { SecurityUtilService } from 'src/app/services/security-util.service'; +import { ResourcesRoutes } from 'src/app/utils/constants'; @Component({ selector: 'other-year-policy', @@ -12,44 +14,104 @@ import { SecurityUtilService } from 'src/app/services/security-util.service'; }) export class OtherYearPolicyComponent implements OnInit, OnChanges { - // Input() OtherYearPolicy? or growerContract? + // Input otherYearPolicies? or growerContract? + @Input() otherYearPolicies: Array + @Input() currentPolicyCropYear; + cropYearOptions = []; otherYearPoliciesForm: UntypedFormGroup; - + constructor( private fb: UntypedFormBuilder, protected router: Router, public securityUtilService: SecurityUtilService - ) { } + ) { } - ngOnInit(): void { - // initialize the form - this.otherYearPoliciesForm = this.fb.group({ - cropYear: [""], - }) - } - - ngOnChanges(changes: SimpleChanges) { - - // // populate crop year dropdown - // if (changes.growerContract && - // this.growerContract && - // this.growerContract.linkedPolicies - // ) { + ngOnInit(): void { - // this.populateCropYears(); - // } + // initialize the form + this.otherYearPoliciesForm = this.fb.group({ + cropYear: [this.currentPolicyCropYear], + }) + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes.otherYearPolicies && this.otherYearPolicies) { + + this.populateCropYears(); + } + + if (changes.currentPolicyCropYear && this.currentPolicyCropYear) { + if (this.otherYearPoliciesForm) { + this.otherYearPoliciesForm.controls.cropYear.setValue(this.currentPolicyCropYear) + } + } + } + + populateCropYears(){ + + var self = this + + self.cropYearOptions = [] + self.cropYearOptions.push (this.currentPolicyCropYear) + + self.otherYearPolicies.forEach( (el: OtherYearPolicy) => { + self.cropYearOptions.push (el.cropYear) + }); + + self.cropYearOptions.sort() + } + + cropYearChange(event) { + + let otherYearPolicy = this.otherYearPolicies.find( x => x.cropYear == event.value ) + + if (otherYearPolicy) { + + const resourceRoute = this.getCurrentResourceRoute() + + if (resourceRoute.length > 0 ) { + this.router.navigate([resourceRoute, + otherYearPolicy.insurancePlanId.toString(), + otherYearPolicy.cropYear.toString(), + otherYearPolicy.policyId.toString(), + (otherYearPolicy.screenRecordGuid ) ? otherYearPolicy.screenRecordGuid.toString() : '' + ]); + } } + } - populateCropYears(){ + getCurrentResourceRoute() { - // add a general info choice - this.cropYearOptions.push ({ - description: "2024", - value: "2024" - }) + const routerUrl = this.router.url.toString() + let newRoute = "" + if (routerUrl.lastIndexOf(ResourcesRoutes.INVENTORY_GRAIN_UNSEEDED) > -1 ) { + return ResourcesRoutes.INVENTORY_GRAIN_UNSEEDED + } + + if (routerUrl.lastIndexOf(ResourcesRoutes.INVENTORY_GRAIN_SEEDED) > -1 ) { + return ResourcesRoutes.INVENTORY_GRAIN_SEEDED + } + + if (routerUrl.lastIndexOf(ResourcesRoutes.INVENTORY_FORAGE) > -1 ) { + return ResourcesRoutes.INVENTORY_FORAGE + } + + if (routerUrl.lastIndexOf(ResourcesRoutes.DOP_GRAIN) > -1 ) { + return ResourcesRoutes.DOP_GRAIN + } + + if (routerUrl.lastIndexOf(ResourcesRoutes.DOP_FORAGE) > -1 ) { + return ResourcesRoutes.DOP_FORAGE } + if (routerUrl.lastIndexOf(ResourcesRoutes.VERIFIED_YIELD_GRAIN) > -1 ) { + return ResourcesRoutes.VERIFIED_YIELD_GRAIN + } + + return newRoute + } + } diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/inventory-selector/inventory-selector.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/inventory-selector/inventory-selector.component.ts index 6e4584bf..d19440da 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/inventory-selector/inventory-selector.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/inventory-selector/inventory-selector.component.ts @@ -7,7 +7,7 @@ import { LoadCropCommodityList, LoadUnderSeededCropCommodityList } from 'src/app import { LoadGrowerContract } from 'src/app/store/grower-contract/grower-contract.actions'; import { ClearInventoryContract, LoadInventoryContract, RolloverInventoryContract } from 'src/app/store/inventory/inventory.actions'; import { INVENTORY_COMPONENT_ID } from 'src/app/store/inventory/inventory.state'; -import { CROP_COMMODITY_TYPE_CONST, INSURANCE_PLAN, ResourcesRoutes } from 'src/app/utils/constants'; +import { CROP_COMMODITY_TYPE_CONST, INSURANCE_PLAN, ResourcesRoutes, SCREEN_TYPE } from 'src/app/utils/constants'; import { RootState } from "src/app/store"; import { ErrorState, LoadState } from "src/app/store/application/application.state"; @@ -55,7 +55,7 @@ export class InventorySelectorComponent implements OnInit{ this.store.dispatch(ClearInventoryContract()); - this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId)) + this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId, SCREEN_TYPE.INVENTORY )) if (this.inventoryContractGuid.length > 0) { this.store.dispatch(LoadInventoryContract(this.componentId, this.inventoryContractGuid )) diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/link-planting/link-planting.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/link-planting/link-planting.component.ts index 3131e8de..558219a8 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/link-planting/link-planting.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/inventory/link-planting/link-planting.component.ts @@ -6,7 +6,7 @@ import { AddFieldValidationRsrc, AnnualFieldRsrc, LinkedPlanting, UwContractList import { AppConfigService, TokenService } from '@wf1/wfcc-core-lib'; import { InventoryContract, UwContract } from 'src/app/conversion/models'; import { makeTitleCase, setHttpHeaders } from 'src/app/utils'; -import { INSURANCE_PLAN, LAND_UPDATE_TYPE, LINK_PLANTING_TYPE, PLANT_INSURABILITY_TYPE_CODE } from 'src/app/utils/constants'; +import { INSURANCE_PLAN, LAND_UPDATE_TYPE, LINK_PLANTING_TYPE, PLANT_INSURABILITY_TYPE_CODE, SCREEN_TYPE } from 'src/app/utils/constants'; import { getInventorySeededForagesObjForSave } from '../inventory-common'; import { LoadGrowerContract } from 'src/app/store/grower-contract/grower-contract.actions'; import { INVENTORY_COMPONENT_ID } from 'src/app/store/inventory/inventory.state'; @@ -430,7 +430,7 @@ export class LinkPlantingComponent implements OnInit { next: data => { // update left menu side navigation links - this.store.dispatch(LoadGrowerContract(INVENTORY_COMPONENT_ID, this.dataReceived.policyId)) + this.store.dispatch(LoadGrowerContract(INVENTORY_COMPONENT_ID, this.dataReceived.policyId, SCREEN_TYPE.INVENTORY)) if (operationType == 'LinkPlanting') { alert ("A new planting was successfully added to the field on the forage policy and linked to this grain planting.") diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/verified-yield/verified-yield.component.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/verified-yield/verified-yield.component.ts index 4124f951..aeb19117 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/verified-yield/verified-yield.component.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/components/verified-yield/verified-yield.component.ts @@ -12,7 +12,7 @@ import { AddNewVerifiedYieldContract, DeleteVerifiedYieldContract, LoadVerifiedY import { VERIFIED_YIELD_COMPONENT_ID } from 'src/app/store/verified-yield/verified-yield.state'; import { displaySuccessSnackbar } from 'src/app/utils/user-feedback-utils'; import { ClearCropCommodity, LoadCropCommodityList } from 'src/app/store/crop-commodity/crop-commodity.actions'; -import { CROP_COMMODITY_TYPE_CONST, INSURANCE_PLAN } from 'src/app/utils/constants'; +import { CROP_COMMODITY_TYPE_CONST, INSURANCE_PLAN, SCREEN_TYPE } from 'src/app/utils/constants'; @Component({ selector: 'verified-yield', @@ -52,7 +52,7 @@ export class VerifiedYieldComponent extends BaseComponent { this.cropYear = params.get("cropYear") ? params.get("cropYear") : ""; this.insurancePlanId = params.get("insurancePlanId") ? params.get("insurancePlanId") : ""; - this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId)) + this.store.dispatch(LoadGrowerContract(this.componentId, this.policyId, SCREEN_TYPE.VERIFIED)) if (this.verifiedYieldContractGuid.length > 0) { // get the already existing verified yield contract diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.actions.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.actions.ts index e28353f7..c19efacc 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.actions.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.actions.ts @@ -225,6 +225,7 @@ export interface DopYieldContractAction extends Action { componentId: string; payload: { dopYieldContract: DopYieldContract; + policyId: string; }; } @@ -236,24 +237,26 @@ export interface DeleteDopYieldContractAction extends Action { }; } -export function AddNewDopYieldContract(componentId: string, dopYieldContract: DopYieldContract): DopYieldContractAction { +export function AddNewDopYieldContract(componentId: string, dopYieldContract: DopYieldContract, policyId: string): DopYieldContractAction { return { type: ADD_NEW_DOP, componentId: componentId, payload: { - dopYieldContract + dopYieldContract, + policyId } }; } -export function UpdateDopYieldContract(componentId: string, dopYieldContract: DopYieldContract): DopYieldContractAction { +export function UpdateDopYieldContract(componentId: string, dopYieldContract: DopYieldContract, policyId: string): DopYieldContractAction { return { type: UPDATE_DOP, componentId: componentId, payload: { - dopYieldContract + dopYieldContract, + policyId } }; } diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.effects.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.effects.ts index d9a99bcf..0ace4b64 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.effects.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/dop/dop.effects.ts @@ -10,7 +10,7 @@ import { convertToErrorState} from "../../conversion/conversion-from-rest"; import {RootState} from "../index"; import { MatSnackBar } from "@angular/material/snack-bar"; -import { REST_VERSION } from "src/app/utils/constants"; +import { REST_VERSION, SCREEN_TYPE } from "src/app/utils/constants"; import { LoadDopYieldContractAction, LoadDopYieldContractError, @@ -39,6 +39,7 @@ import { convertToDopYieldContractRsrc } from "src/app/conversion/conversion-to- import { displayDeleteSuccessSnackbar, displaySaveSuccessSnackbar, displayErrorMessage } from "src/app/utils/user-feedback-utils"; import { HttpClient } from '@angular/common/http'; +import { LoadGrowerContract } from "../grower-contract/grower-contract.actions"; @Injectable() export class DopEffects { @@ -174,7 +175,6 @@ addNewDopYield: Observable = createEffect (() => this.actions.pipe( let typedAction = action; let requestId = `CUWS${UUID.UUID().toUpperCase()}`.replace(/-/g, ""); let authToken = this.tokenService.getOauthToken(); - let payload = typedAction.payload.dopYieldContract; const dopYieldContract = typedAction.payload.dopYieldContract const body: DopYieldContractRsrc = convertToDopYieldContractRsrc(dopYieldContract) @@ -194,6 +194,8 @@ addNewDopYield: Observable = createEffect (() => this.actions.pipe( let newdopYieldContract: DopYieldContract = convertToDopContract(response.body, response.headers ? response.headers.get("ETag") : null) + this.store.dispatch(LoadGrowerContract(typedAction.componentId, typedAction.payload.policyId, SCREEN_TYPE.DOP)) // to update the side navigation links + return [ LoadDopYieldContractSuccess(typedAction.componentId, newdopYieldContract) ] @@ -238,6 +240,8 @@ updateDopYield: Observable = createEffect (() => this.actions.pipe( let newInventoryContract: DopYieldContract = convertToDopContract(response.body, response.headers ? response.headers.get("ETag") : null) + // For now, there is no need to update the navigation links, or the related policies or other crop years on update DOP. May be for future use? + // this.store.dispatch(LoadGrowerContract(typedAction.componentId, typedAction.payload.policyId, SCREEN_TYPE.DOP)) return [ LoadDopYieldContractSuccess(typedAction.componentId, newInventoryContract) ] @@ -280,6 +284,8 @@ deleteDopYield: Observable = createEffect (() => this.actions.pipe( displayDeleteSuccessSnackbar(this.snackbarService, "DOP Yield "); + this.store.dispatch(LoadGrowerContract(typedAction.componentId, typedAction.payload.policyId, SCREEN_TYPE.DOP)) // to update the side navigation links + return RolloverDopYieldContract(typedAction.componentId, typedAction.payload.policyId); }), diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.actions.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.actions.ts index f8b886b9..6e2c543a 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.actions.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.actions.ts @@ -14,6 +14,7 @@ export interface LoadGrowerContractAction extends Action { componentId: string; payload: { value: string; + screenType: string; }; } @@ -32,13 +33,14 @@ export interface LoadGrowerContractAction extends Action { } // add policy Id and inventoryContractGuid - export function LoadGrowerContract(componentId: string, value: string): LoadGrowerContractAction { + export function LoadGrowerContract(componentId: string, value: string, screenType: string): LoadGrowerContractAction { return { type: LOAD_GROWER_CONTRACT, componentId: componentId, payload: { - value + value, + screenType } }; } diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.effects.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.effects.ts index 2233a824..a15dc3d6 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.effects.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/grower-contract/grower-contract.effects.ts @@ -34,10 +34,11 @@ export class GrowerContractInfoEffects { let typedAction = action; let authToken = this.tokenService.getOauthToken(); - let requestId = `cirras-underwritingE${UUID.UUID().toUpperCase()}`.replace(/-/g, ""); + let requestId = `cirras-underwriting${UUID.UUID().toUpperCase()}`.replace(/-/g, ""); const policyId = typedAction.payload.value; - + let screenType = typedAction.payload.screenType; + return this.CirrasUnderwritingAPIService.getTheUwContract( policyId, requestId, @@ -45,7 +46,9 @@ export class GrowerContractInfoEffects { "no-cache", "no-cache", `Bearer ${authToken}`, - "true" + "true", + "true", + screenType ).pipe( map((response: UwContractRsrc) => { return LoadGrowerContractSuccess(typedAction.componentId, convertToUwContract(response ) ); diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/inventory/inventory.effects.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/inventory/inventory.effects.ts index 37112e58..7e259332 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/inventory/inventory.effects.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/inventory/inventory.effects.ts @@ -14,7 +14,7 @@ import { convertToInventoryContractRsrc } from "src/app/conversion/conversion-to import { InventoryContract } from "src/app/conversion/models"; import { displayErrorMessage, displaySaveSuccessSnackbar, displayDeleteSuccessSnackbar, displaySuccessSnackbar } from "src/app/utils/user-feedback-utils"; import { MatSnackBar } from "@angular/material/snack-bar"; -import { REST_VERSION } from "src/app/utils/constants"; +import { REST_VERSION, SCREEN_TYPE } from "src/app/utils/constants"; import { HttpClient } from '@angular/common/http'; import { GetReportError, GetReportSuccess } from "../dop/dop.actions"; import { LoadGrowerContract } from "../grower-contract/grower-contract.actions"; @@ -140,7 +140,7 @@ addNewInventory: Observable = createEffect(() => this.actions.pipe( let newInventoryContract: InventoryContract = convertToInventoryContract(response.body, response.headers ? response.headers.get("ETag") : null) - this.store.dispatch(LoadGrowerContract(INVENTORY_COMPONENT_ID, policyId)) // to update the side navigation links + this.store.dispatch(LoadGrowerContract(INVENTORY_COMPONENT_ID, policyId, SCREEN_TYPE.INVENTORY)) // to update the side navigation links return [ LoadInventoryContractSuccess(typedAction.componentId, newInventoryContract) @@ -189,7 +189,7 @@ updateInventory: Observable = createEffect(() => this.actions.pipe( let newInventoryContract: InventoryContract = convertToInventoryContract(response.body, response.headers ? response.headers.get("ETag") : null) - this.store.dispatch(LoadGrowerContract(INVENTORY_COMPONENT_ID, policyId)) // to update the side navigation links + this.store.dispatch(LoadGrowerContract(INVENTORY_COMPONENT_ID, policyId, SCREEN_TYPE.INVENTORY)) // to update the side navigation links return [ LoadInventoryContractSuccess(typedAction.componentId, newInventoryContract) ] @@ -291,7 +291,7 @@ deleteInventory: Observable = createEffect(() => this.actions.pipe( displayDeleteSuccessSnackbar(this.snackbarService, "Inventory "); - this.store.dispatch(LoadGrowerContract(typedAction.componentId, payload.policyId)) // to update the side navigation links + this.store.dispatch(LoadGrowerContract(typedAction.componentId, payload.policyId, SCREEN_TYPE.INVENTORY)) // to update the side navigation links return [ RolloverInventoryContract(typedAction.componentId, payload.policyId) diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/verified-yield/verified-yield.effects.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/verified-yield/verified-yield.effects.ts index d6b64be8..8941e361 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/verified-yield/verified-yield.effects.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/store/verified-yield/verified-yield.effects.ts @@ -9,7 +9,7 @@ import { catchError, concatMap, debounceTime, map, switchMap, withLatestFrom } f import { convertToErrorState } from "../../conversion/conversion-from-rest"; import { RootState } from "../index"; import { MatSnackBar } from "@angular/material/snack-bar"; -import { REST_VERSION } from "src/app/utils/constants"; +import { REST_VERSION, SCREEN_TYPE } from "src/app/utils/constants"; import { convertToVerifiedYieldContract } from "src/app/conversion/conversion-from-rest-yield"; import { HttpClient } from '@angular/common/http'; import { ADD_NEW_VERIFIED_YIELD, DELETE_VERIFIED_YIELD, DeleteVerifiedYieldContractAction, DeleteVerifiedYieldContractError, LOAD_VERIFIED_YIELD, LoadVerifiedYieldContractAction, LoadVerifiedYieldContractError, LoadVerifiedYieldContractSuccess, ROLLOVER_VERIFIED_YIELD, RolloverVerifiedYieldContract, RolloverVerifiedYieldContractAction, UPDATE_VERIFIED_YIELD, VerifiedYieldContractAction } from "./verified-yield.actions"; @@ -138,7 +138,7 @@ addNewVerifiedYield: Observable = createEffect (() => this.actions.pipe( let newVerifiedYieldContract: VerifiedYieldContract = convertToVerifiedYieldContract(response.body, response.headers ? response.headers.get("ETag") : null) - this.store.dispatch(LoadGrowerContract(VERIFIED_YIELD_COMPONENT_ID, policyId)) // to update the side navigation links + this.store.dispatch(LoadGrowerContract(VERIFIED_YIELD_COMPONENT_ID, policyId, SCREEN_TYPE.VERIFIED)) // to update the side navigation links return [ LoadVerifiedYieldContractSuccess(typedAction.componentId, newVerifiedYieldContract) ] @@ -184,7 +184,9 @@ updateDopYield: Observable = createEffect (() => this.actions.pipe( let newVerifiedYieldContract: VerifiedYieldContract = convertToVerifiedYieldContract(response.body, response.headers ? response.headers.get("ETag") : null) - this.store.dispatch(LoadGrowerContract(VERIFIED_YIELD_COMPONENT_ID, policyId)) // to update the side navigation links + // for now, there is no need to update the navigation links, or related policies, or other crop years when updating the verified yield + // may be in the future? + // this.store.dispatch(LoadGrowerContract(VERIFIED_YIELD_COMPONENT_ID, policyId, SCREEN_TYPE.VERIFIED)) return [ LoadVerifiedYieldContractSuccess(typedAction.componentId, newVerifiedYieldContract) @@ -228,7 +230,7 @@ deleteVerifiedYield: Observable = createEffect (() => this.actions.pipe( displayDeleteSuccessSnackbar(this.snackbarService, "Verified Yield "); - this.store.dispatch(LoadGrowerContract(typedAction.componentId, typedAction.payload.policyId)) // to update the side navigation links + this.store.dispatch(LoadGrowerContract(typedAction.componentId, typedAction.payload.policyId, SCREEN_TYPE.VERIFIED)) // to update the side navigation links return RolloverVerifiedYieldContract(typedAction.componentId, typedAction.payload.policyId); diff --git a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/utils/constants.ts b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/utils/constants.ts index e14bc3e7..5b2f6670 100644 --- a/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/utils/constants.ts +++ b/cirras-underwriting-war/cirras-underwriting-war/src/main/angular/src/app/utils/constants.ts @@ -157,4 +157,9 @@ export const PLANT_INSURABILITY_TYPE_CODE ={ export const VERIFIED_YIELD_AMENDMENT_CODE = { "APPRAISAL" : "Appraisal", "ASSESSMENT" : "Assessment" +} +export const SCREEN_TYPE = { + INVENTORY: "INVENTORY", + DOP: "DOP", + VERIFIED: "VERIFIED" } \ No newline at end of file