use of org.apache.commons.lang3.ObjectUtils.max in project Employee-Self-Service by nysenate.
the class TransactionHistory method getEffectiveSalaryRecs.
public TreeMap<LocalDate, SalaryRec> getEffectiveSalaryRecs(Range<LocalDate> dateRange) {
List<TransactionRecord> salRecs = new ArrayList<>();
appointDocuments.values().stream().filter(trec -> trec.getTransType() == PAY).forEach(salRecs::add);
getRecords(SAL).stream().filter(rec -> !appointDocuments.containsKey(rec.getDocumentId())).forEach(salRecs::add);
salRecs.sort(TransactionRecord::compareTo);
TreeMap<LocalDate, SalaryRec> salaryRecs = new TreeMap<>();
for (TransactionRecord rec : salRecs) {
SalaryRec salaryRec = new SalaryRec(new BigDecimal(rec.getValue("MOSALBIWKLY")), PayType.valueOf(rec.getValue("CDPAYTYPE")), rec.getEffectDate(), rec.getAuditDate());
LocalDate date = ObjectUtils.max(rec.getEffectDate(), DateUtils.startOfDateRange(dateRange));
Optional.ofNullable(salaryRecs.lowerEntry(date)).ifPresent(entry -> entry.getValue().setEndDate(date));
salaryRecs.put(date, salaryRec);
}
return salaryRecs;
}
Aggregations