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

Commit

Permalink
ISTE-179: Added chnages to get latest demand created date and penalty…
Browse files Browse the repository at this point in the history
… created date
  • Loading branch information
debasishchakraborty-egovt committed Jul 1, 2024
1 parent 5743079 commit 8b0f42a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ public class AggregatedDemandDetailResponse {
private BigDecimal netDueWithPenalty;

private BigDecimal totalApplicablePenalty;

private long latestDemandCreatedTime;

private long latestDemandPenaltyCreatedtime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<User> payers = null;
Expand Down Expand Up @@ -618,6 +621,46 @@ public AggregatedDemandDetailResponse getAllDemands(DemandCriteria demandCriteri
}).collect(Collectors.toList());
List<Map<Long, List<DemandDetail>>> demandDetailsList = new ArrayList<>();

List<Demand> demandsTogetDemandGeneratedDate= demands;

// Filter demands where demandDetails have taxHeadMasterCode as 10101
List<Demand> filteredDemands = demandsTogetDemandGeneratedDate.stream()
.filter(demand -> demand.getDemandDetails().stream()
.anyMatch(detail -> "10101".equals(detail.getTaxHeadMasterCode())))
.collect(Collectors.toList());

Collections.sort(filteredDemands, new Comparator<Demand>() {
@Override
public int compare(Demand d1, Demand d2) {
return Long.compare(d2.getTaxPeriodFrom(), d1.getTaxPeriodFrom());
}
});



if (!filteredDemands.isEmpty()) {
Demand latestDemand = filteredDemands.get(0);

Optional<DemandDetail> detail10101 = latestDemand.getDemandDetails().stream()
.filter(detail -> "10101".equals(detail.getTaxHeadMasterCode()))
.findFirst();

Optional<DemandDetail> 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<Long, List<DemandDetail>> demandMap = new HashMap<>();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8b0f42a

Please sign in to comment.