Пример #1
0
 public Map<LocalDate, BigDecimal> getPlannedOutgoingsPerDay(
     LocalDate dateFrom, LocalDate dateTo, List<Category> categories) {
   Map<LocalDate, BigDecimal> outgoings = new TreeMap<>(Collections.reverseOrder());
   for (LocalDate iterDate = dateTo;
       iterDate.isAfter(dateFrom.minusDays(1));
       iterDate = iterDate.minusDays(1)) {
     BigDecimal value =
         getPlannedTransactions(iterDate, iterDate, categories)
             .stream()
             .filter(a -> a.getValue().compareTo(BigDecimal.ZERO) == 1)
             .map(a -> a.getValue().abs())
             .reduce(BigDecimal.ZERO, BigDecimal::add);
     if ((value.compareTo(BigDecimal.ZERO) > 0)
         || iterDate.isEqual(dateFrom)
         || iterDate.isEqual(dateTo)) outgoings.put(iterDate, value);
   }
   return outgoings;
 }
Пример #2
0
  private int compareDates(org.joda.time.LocalDate checkedDate, LocalDate rangeDate) {
    LocalDate localDateUnified =
        LocalDate.of(
            checkedDate.getYear(), checkedDate.getMonthOfYear(), checkedDate.getDayOfMonth());

    if (localDateUnified.isEqual(rangeDate)) {
      return 0;
    }

    return localDateUnified.isAfter(rangeDate) ? 1 : -1;
  }
Пример #3
0
 @Test
 public void localDateFunctions() throws IOException {
   ServiceLocator locator = container;
   DataContext db = locator.resolve(DataContext.class);
   LocalDate ld = LocalDate.now();
   Clicked cl = new Clicked().setDate(ld);
   db.submit(cl);
   Query<Clicked> query = db.query(Clicked.class);
   String uri = cl.getURI();
   boolean found1 =
       query.anyMatch(it -> it.getURI().equals(uri) && ld.compareTo(it.getDate()) == 0);
   boolean found2 =
       query.anyMatch(
           it -> it.getURI().equals(uri) && ld.equals(it.getDate()) && ld.isEqual(it.getDate()));
   boolean notFound =
       query.anyMatch(it -> it.getURI().equals(uri) && ld.compareTo(it.getDate()) != 0);
   Assert.assertTrue(found1);
   Assert.assertTrue(found2);
   Assert.assertFalse(notFound);
 }
 @Override
 boolean filter(LocalDate itemDate, LocalDate thresholdDate) {
   return itemDate.isAfter(thresholdDate) || itemDate.isEqual(thresholdDate);
 }