From 8b0f42a0a29daaf3ebe8cd70b7ecab701e3c8eab Mon Sep 17 00:00:00 2001 From: debasishchakraborty-egovt Date: Mon, 1 Jul 2024 14:58:26 +0530 Subject: [PATCH] ISTE-179: Added chnages to get latest demand created date and penalty created date --- .../model/AggregatedDemandDetailResponse.java | 4 ++ .../egov/demand/service/DemandService.java | 47 ++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/business-services/billing-service/src/main/java/org/egov/demand/model/AggregatedDemandDetailResponse.java b/business-services/billing-service/src/main/java/org/egov/demand/model/AggregatedDemandDetailResponse.java index 1feca1ce4..523548b53 100644 --- a/business-services/billing-service/src/main/java/org/egov/demand/model/AggregatedDemandDetailResponse.java +++ b/business-services/billing-service/src/main/java/org/egov/demand/model/AggregatedDemandDetailResponse.java @@ -38,4 +38,8 @@ public class AggregatedDemandDetailResponse { private BigDecimal netDueWithPenalty; private BigDecimal totalApplicablePenalty; + + private long latestDemandCreatedTime; + + private long latestDemandPenaltyCreatedtime; } \ No newline at end of file diff --git a/business-services/billing-service/src/main/java/org/egov/demand/service/DemandService.java b/business-services/billing-service/src/main/java/org/egov/demand/service/DemandService.java index 743f1db6c..acc049f64 100644 --- a/business-services/billing-service/src/main/java/org/egov/demand/service/DemandService.java +++ b/business-services/billing-service/src/main/java/org/egov/demand/service/DemandService.java @@ -571,6 +571,9 @@ public DemandHistory getDemandHistory(@Valid DemandCriteria demandCriteria, Requ public AggregatedDemandDetailResponse getAllDemands(DemandCriteria demandCriteria, RequestInfo requestInfo) { //demandValidatorV1.validateDemandCriteria(demandCriteria, requestInfo); + long latestDemandCreatedTime = 0l; + + long latestDemandPenaltyCreatedtime=0l; UserSearchRequest userSearchRequest = null; List payers = null; @@ -618,6 +621,46 @@ public AggregatedDemandDetailResponse getAllDemands(DemandCriteria demandCriteri }).collect(Collectors.toList()); List>> demandDetailsList = new ArrayList<>(); + List demandsTogetDemandGeneratedDate= demands; + + // Filter demands where demandDetails have taxHeadMasterCode as 10101 + List filteredDemands = demandsTogetDemandGeneratedDate.stream() + .filter(demand -> demand.getDemandDetails().stream() + .anyMatch(detail -> "10101".equals(detail.getTaxHeadMasterCode()))) + .collect(Collectors.toList()); + + Collections.sort(filteredDemands, new Comparator() { + @Override + public int compare(Demand d1, Demand d2) { + return Long.compare(d2.getTaxPeriodFrom(), d1.getTaxPeriodFrom()); + } + }); + + + + if (!filteredDemands.isEmpty()) { + Demand latestDemand = filteredDemands.get(0); + + Optional detail10101 = latestDemand.getDemandDetails().stream() + .filter(detail -> "10101".equals(detail.getTaxHeadMasterCode())) + .findFirst(); + + Optional detailWSTimePenalty = latestDemand.getDemandDetails().stream() + .filter(detail -> "WS_TIME_PENALTY".equals(detail.getTaxHeadMasterCode())) + .findFirst(); + + if (detail10101.isPresent()) { + latestDemandCreatedTime = detail10101.get().getAuditDetails().getCreatedTime(); + } + + if (detailWSTimePenalty.isPresent()) { + latestDemandPenaltyCreatedtime = detailWSTimePenalty.get().getAuditDetails().getCreatedTime(); + } + } else { + log.info("No demands found with taxHeadMasterCode 10101 or WS_TIME_PENALTY."); + } + + for (Demand demand : demands) { log.info("Inside demand"); Map> demandMap = new HashMap<>(); @@ -772,7 +815,9 @@ public AggregatedDemandDetailResponse getAllDemands(DemandCriteria demandCriteri .advanceAdjusted(advanceAdjusted) .advanceAvailable(advanceAvailable) .remainingAdvance(remainingAdvance) - .totalApplicablePenalty(totalApplicablePenalty).build(); + .totalApplicablePenalty(totalApplicablePenalty) + .latestDemandCreatedTime(latestDemandCreatedTime) + .latestDemandPenaltyCreatedtime(latestDemandPenaltyCreatedtime).build(); return aggregatedDemandDetailResponse;