Search in sources :

Example 1 with Delinquents

use of com.github.robozonky.app.portfolio.Delinquents in project robozonky by RoboZonky.

the class Delinquency method getOlderThan.

/**
 * Returns all loans that are presently delinquent.
 * @param days Minimum number of days a loan is in delinquency in order to be reported. 0 returns all delinquents.
 * @return All loans that are delinquent for more than the given number of days.
 */
private SortedMap<Integer, LocalDate> getOlderThan(final int days) {
    final ZoneId zone = Defaults.ZONE_ID;
    final ZonedDateTime now = LocalDate.now().atStartOfDay(zone);
    return source.get().flatMap(d -> d.getActiveDelinquency().map(Stream::of).orElse(Stream.empty())).filter(d -> d.getPaymentMissedDate().atStartOfDay(zone).plusDays(days).isBefore(now)).collect(Collectors.toMap(d -> d.getParent().getLoanId(), d -> d.getPaymentMissedDate(), (a, b) -> a, TreeMap::new));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Delinquent(com.github.robozonky.app.portfolio.Delinquent) Delinquents(com.github.robozonky.app.portfolio.Delinquents) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) OffsetDateTime(java.time.OffsetDateTime) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) LocalDate(java.time.LocalDate) Map(java.util.Map) Defaults(com.github.robozonky.internal.api.Defaults) SortedMap(java.util.SortedMap) ZoneId(java.time.ZoneId) ZonedDateTime(java.time.ZonedDateTime) Stream(java.util.stream.Stream)

Aggregations

Delinquent (com.github.robozonky.app.portfolio.Delinquent)1 Delinquents (com.github.robozonky.app.portfolio.Delinquents)1 Defaults (com.github.robozonky.internal.api.Defaults)1 LocalDate (java.time.LocalDate)1 OffsetDateTime (java.time.OffsetDateTime)1 ZoneId (java.time.ZoneId)1 ZonedDateTime (java.time.ZonedDateTime)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1