public boolean isSelloffStarted() { if (exitProperties == null) { return false; } else { return exitProperties.getSelloffStart().isBefore(DateUtil.localNow().toLocalDate()); } }
public boolean isSelloffStarted() { if (exitProperties == null) { return false; } else { return exitProperties.getSelloffStart().isBefore(DateUtil.localNow().toLocalDate()); } }
public long getMonthsBeforeExit() { if (exitProperties == null) { return -1; } else { return Math.max(0, Period.between(DateUtil.localNow().toLocalDate(), exitProperties.getAccountTermination()).toTotalMonths()); } }
public long getMonthsBeforeExit() { if (exitProperties == null) { return -1; } else { return Math.max(0, Period.between(DateUtil.localNow().toLocalDate(), exitProperties.getAccountTermination()).toTotalMonths()); } }
/** * @return When added to the current time, will result in some random time shortly after midnight tomorrow. */ @Override public Duration startIn() { final Duration random = TenantJob.super.startIn(); final ZonedDateTime triggerOn = DateUtil.localNow().toLocalDate() .plusDays(1) .atStartOfDay(Defaults.ZONE_ID) .plus(random); return Duration.between(DateUtil.zonedNow(), triggerOn); }
/** * @return When added to the current time, will result in some random time shortly after midnight tomorrow. */ @Override public Duration startIn() { final Duration random = TenantJob.super.startIn(); final ZonedDateTime triggerOn = DateUtil.localNow().toLocalDate() .plusDays(1) .atStartOfDay(Defaults.ZONE_ID) .plus(random); return Duration.between(DateUtil.zonedNow(), triggerOn); }
private static long getMonthsElapsed(final Investment i) { return Period.between(i.getInvestmentDate().toLocalDate(), DateUtil.localNow().toLocalDate()).toTotalMonths(); }
private static long getMonthsElapsed(final Investment i) { return Period.between(i.getInvestmentDate().toLocalDate(), DateUtil.localNow().toLocalDate()).toTotalMonths(); }
private static SessionEvent supplyEvent(final Tenant tenant, final Investment investment, final int threshold) { LOGGER.trace("Retrieving event for investment #{}.", investment.getId()); final LocalDate since = DateUtil.localNow().toLocalDate().minusDays(investment.getDaysPastDue()); final int loanId = investment.getLoanId(); final Collection<Development> developments = getDevelopments(tenant, loanId, since); final Loan loan = tenant.getLoan(loanId); final SessionEvent e = getEventSupplierConstructor(threshold) .apply(investment, loan, since, developments); LOGGER.trace("Done."); return e; }
.orElse(DateUtil.localNow().toLocalDate()).minusDays(i.getDaysPastDue()); final LocalDate lastPayment = getTransactions(i) .filter(t -> t.getCategory() == TransactionCategory.PAYMENT)
.orElse(DateUtil.localNow().toLocalDate()).minusDays(i.getDaysPastDue()); final LocalDate lastPayment = getTransactions(i) .filter(t -> t.getCategory() == TransactionCategory.PAYMENT)
private static LazyEvent<? extends SessionEvent> getEvent(final Tenant tenant, final Investment investment, final int threshold) { LOGGER.trace("Retrieving event for investment #{}.", investment.getId()); final LocalDate since = DateUtil.localNow().toLocalDate().minusDays(investment.getDaysPastDue()); final int loanId = investment.getLoanId(); final Collection<Development> developments = getDevelopments(tenant, loanId, since); final Loan loan = LoanCache.get().getLoan(loanId, tenant); final Supplier<SessionEvent> s = () -> getEventSupplierConstructor(threshold).apply(investment, loan, since, developments); final LazyEvent<? extends SessionEvent> e = getLazyEventSupplier(threshold, s); LOGGER.trace("Done."); return e; }
private static void run(final TransactionalPowerTenant tenant) { final InstanceState<IncomeProcessor> state = tenant.getState(IncomeProcessor.class); final long lastSeenTransactionId = state.getValue(STATE_KEY) .map(Integer::valueOf) .orElse(-1); // transactions from overnight processing have timestamps from the midnight of previous day final LocalDate lastUpdate = state.getLastUpdated() .map(u -> u.minusDays(1).toLocalDate()) .orElse(DateUtil.localNow().toLocalDate().minusWeeks(1)); final Select sinceLastUpdate = new Select().greaterThanOrEquals("transaction.transactionDate", lastUpdate); final Stream<Transaction> transactions = tenant.call(z -> z.getTransactions(sinceLastUpdate)); final long newLastSeenTransactionId = lastSeenTransactionId >= 0 ? processNewTransactions(tenant, transactions, lastSeenTransactionId) : processAllTransactions(transactions); state.update(m -> m.put(STATE_KEY, String.valueOf(newLastSeenTransactionId))); }
private static void run(final TransactionalPowerTenant tenant) { final InstanceState<IncomeProcessor> state = tenant.getState(IncomeProcessor.class); final long lastSeenTransactionId = state.getValue(STATE_KEY) .map(Integer::valueOf) .orElse(-1); // transactions from overnight processing have timestamps from the midnight of previous day final LocalDate lastUpdate = state.getLastUpdated() .map(u -> u.minusDays(1).toLocalDate()) .orElse(DateUtil.localNow().toLocalDate().minusWeeks(1)); final Select sinceLastUpdate = new Select().greaterThanOrEquals("transaction.transactionDate", lastUpdate); final Stream<Transaction> transactions = tenant.call(z -> z.getTransactions(sinceLastUpdate)); final long newLastSeenTransactionId = lastSeenTransactionId >= 0 ? processNewTransactions(tenant, transactions, lastSeenTransactionId) : processAllTransactions(transactions); state.update(m -> m.put(STATE_KEY, String.valueOf(newLastSeenTransactionId))); }
@Test void setExitStrategy() { setClock(Clock.fixed(Instant.EPOCH, Defaults.ZONE_ID)); final ExitProperties p = new ExitProperties(DateUtil.localNow().plusMonths(1).toLocalDate()); final DefaultValues v = new DefaultValues(DefaultPortfolio.EMPTY); assertThat(v.getMonthsBeforeExit()).isEqualTo(-1); v.setExitProperties(p); assertThat(v.getMonthsBeforeExit()).isEqualTo(1); } }
final Instant lastModified = Instant.EPOCH.plus(Duration.ofMillis(s.getModifiedTime().getValue())); final LocalDate d = lastModified.atZone(Defaults.ZONE_ID).toLocalDate(); if (d.isBefore(DateUtil.localNow().toLocalDate())) { Util.copyFile(driveService, s, o.getFolder(), d + " " + s.getName());
final Instant lastModified = Instant.EPOCH.plus(Duration.ofMillis(s.getModifiedTime().getValue())); final LocalDate d = lastModified.atZone(Defaults.ZONE_ID).toLocalDate(); if (d.isBefore(DateUtil.localNow().toLocalDate())) { Util.copyFile(driveService, s, o.getFolder(), d + " " + s.getName());
@Test void replacesWithSynthetic() { SoftAssertions.assertSoftly(softly -> { softly.assertThat(DateUtil.now()).isEqualTo(INSTANT); softly.assertThat(DateUtil.localNow()).isEqualTo(LocalDateTime.ofInstant(INSTANT, Defaults.ZONE_ID)); softly.assertThat(DateUtil.offsetNow()).isEqualTo(OffsetDateTime.ofInstant(INSTANT, Defaults.ZONE_ID)); softly.assertThat(DateUtil.zonedNow()).isEqualTo(ZonedDateTime.ofInstant(INSTANT, Defaults.ZONE_ID)); }); }