Search in sources :

Example 1 with ObjectUtils.max

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;
}
Also used : ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) java.util(java.util) PER(gov.nysenate.ess.core.model.transaction.TransactionType.PER) Logger(org.slf4j.Logger) SAL(gov.nysenate.ess.core.model.transaction.TransactionCode.SAL) PayType(gov.nysenate.ess.core.model.payroll.PayType) Predicate(java.util.function.Predicate) LoggerFactory(org.slf4j.LoggerFactory) RangeUtils(gov.nysenate.ess.core.util.RangeUtils) SortOrder(gov.nysenate.ess.core.util.SortOrder) PersonnelStatus(gov.nysenate.ess.core.model.personnel.PersonnelStatus) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) SalaryRec(gov.nysenate.ess.core.model.payroll.SalaryRec) BigDecimal(java.math.BigDecimal) Agency(gov.nysenate.ess.core.model.personnel.Agency) Pair(org.apache.commons.lang3.tuple.Pair) ObjectUtils(org.apache.commons.lang3.ObjectUtils) LocalDate(java.time.LocalDate) DateUtils(gov.nysenate.ess.core.util.DateUtils) com.google.common.collect(com.google.common.collect) APP(gov.nysenate.ess.core.model.transaction.TransactionCode.APP) PAY(gov.nysenate.ess.core.model.transaction.TransactionType.PAY) SalaryRec(gov.nysenate.ess.core.model.payroll.SalaryRec) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal)

Aggregations

com.google.common.collect (com.google.common.collect)1 PayType (gov.nysenate.ess.core.model.payroll.PayType)1 SalaryRec (gov.nysenate.ess.core.model.payroll.SalaryRec)1 Agency (gov.nysenate.ess.core.model.personnel.Agency)1 PersonnelStatus (gov.nysenate.ess.core.model.personnel.PersonnelStatus)1 APP (gov.nysenate.ess.core.model.transaction.TransactionCode.APP)1 SAL (gov.nysenate.ess.core.model.transaction.TransactionCode.SAL)1 PAY (gov.nysenate.ess.core.model.transaction.TransactionType.PAY)1 PER (gov.nysenate.ess.core.model.transaction.TransactionType.PER)1 DateUtils (gov.nysenate.ess.core.util.DateUtils)1 RangeUtils (gov.nysenate.ess.core.util.RangeUtils)1 SortOrder (gov.nysenate.ess.core.util.SortOrder)1 BigDecimal (java.math.BigDecimal)1 LocalDate (java.time.LocalDate)1 java.util (java.util)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 ObjectUtils (org.apache.commons.lang3.ObjectUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1