Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #819 from egovernments/ISTE-21
Browse files Browse the repository at this point in the history
Iste 21
  • Loading branch information
pradeepkumarcm-egov authored Jun 19, 2024
2 parents 0bba1d2 + bdf05dc commit 72afff5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.egov.waterconnection.service.MeterInfoValidator;
import org.egov.waterconnection.service.PropertyValidator;
import org.egov.waterconnection.service.WaterFieldValidator;
import org.egov.waterconnection.util.WaterServicesUtil;
import org.egov.waterconnection.web.models.Demand;
import org.egov.waterconnection.web.models.DemandDetail;
import org.egov.waterconnection.web.models.DemandRequest;
Expand All @@ -29,6 +30,7 @@
import org.egov.waterconnection.web.models.WaterConnection;
import org.egov.waterconnection.web.models.WaterConnectionRequest;
import org.egov.waterconnection.web.models.Connection.StatusEnum;
import org.egov.waterconnection.web.models.collection.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
Expand Down Expand Up @@ -62,6 +64,11 @@ public class WaterConnectionValidator {
@Autowired
private ObjectMapper mapper;

@Autowired
private WaterServicesUtil waterServiceUtil;

String businessService = "WS.ONE_TIME_FEE";

/**Used strategy pattern for avoiding multiple if else condition
*
* @param waterConnectionRequest
Expand Down Expand Up @@ -176,29 +183,70 @@ public void validateUpdate(WaterConnectionRequest request, WaterConnection searc
}
Boolean isArrear = false;
Boolean isAdvance = false;

Boolean hasPayments=false;

if(!request.getWaterConnection().getStatus().equals(StatusEnum.INACTIVE)) {
hasPayments = checkForPayments(request);
}

if(request.getWaterConnection().getAdvance()!=null && request.getWaterConnection().getAdvance().compareTo(BigDecimal.ZERO) == 0) {
isAdvance = true;
}
if(request.getWaterConnection().getArrears()!=null && request.getWaterConnection().getArrears().compareTo(BigDecimal.ZERO) == 0) {
isArrear = true;
}
if ((request.getWaterConnection().getStatus().equals(StatusEnum.INACTIVE) && demList != null && demList.size() > 0)
if (!hasPayments && ((request.getWaterConnection().getStatus().equals(StatusEnum.INACTIVE) && demList != null && demList.size() > 0)
|| (searchResult.getArrears() != null && request.getWaterConnection().getArrears() == null && demList != null && demList.size() > 0
|| (isArrear && demList != null && demList.size() > 0))|| (request.getWaterConnection().getStatus().equals(StatusEnum.INACTIVE) && demList != null && demList.size() > 0)
|| (searchResult.getAdvance() != null && request.getWaterConnection().getAdvance() == null && demList != null && demList.size() > 0
|| isAdvance)) {
|| isAdvance))) {
for (Demand demand : demList) {
demand.setStatus(org.egov.waterconnection.web.models.Demand.StatusEnum.CANCELLED);
}
updateDemand(request.getRequestInfo(), demList);

}
}


}
/**

private Boolean checkForPayments(WaterConnectionRequest waterConnectionRequest) {
String consumerCode,service;
if(StringUtils.isEmpty(waterConnectionRequest.getWaterConnection().getConnectionNo())){
consumerCode = waterConnectionRequest.getWaterConnection().getApplicationNo();
service = businessService;
}
else{
consumerCode = waterConnectionRequest.getWaterConnection().getConnectionNo();
service = "WS";
}
StringBuilder uri = new StringBuilder();
uri.append(waterServiceUtil.getcollectionURL()).append(service).append("/_search").append("?").
append("tenantId=").append(waterConnectionRequest.getWaterConnection().getTenantId())
.append("&").
append("consumerCodes=").append(consumerCode)
.append("&").
append("businessService").append(service);
RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(waterConnectionRequest.getRequestInfo()).build();
Object response = serviceRequestRepository.fetchResult(uri,requestInfoWrapper);
PaymentResponse paymentResponse=null;
try {
paymentResponse = mapper.convertValue(response, PaymentResponse.class);
}
catch (Exception ex)
{
log.error("Response not found");
}
if(paymentResponse.getPayments()!=null)
{
if(!paymentResponse.getPayments().isEmpty())
{
return true;
}
}
return false;
}

/**
* GPWSC specific validation
* @param request
* @param searchResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ ws.pdfservice.link=pdf-service/v1/_create?tenantId=$tenantId&key=$applicationkey
egov.filestore.host=http://egov-filestore:8080/
ws.fileStore.link=filestore/v1/files/url?tenantId=$tenantId&fileStoreIds=$fileStoreIds
egov.shortener.url=egov-url-shortening/shortener
egov.collection.host=http://collection-services.egov:8080/
egov.collection.host=http://collection-services.mgramseva:8080/

logging.level.org.egov.waterconnection=DEBUG

Expand Down

0 comments on commit 72afff5

Please sign in to comment.