use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.
the class MainManager method removeBookings.
public synchronized boolean removeBookings(final List<BookingBean> bookings) {
this.bookings.removeAll(bookings);
for (final Iterator<BookingEntry> it = bookingEntries.values().iterator(); it.hasNext(); ) {
final BookingEntry be = it.next();
if (bookings.contains(be.getElement())) {
it.remove();
}
}
if (logger.isDebugEnabled()) {
logger.debug("BookingBean entries now " + bookingEntries.size());
}
final boolean result = this.bookings.removeAll(bookings);
if (logger.isDebugEnabled()) {
logger.debug("Bookings now " + this.bookings.size());
}
removeUiDataBooking(bookings);
return result;
}
use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.
the class MainManager method getBefore.
public Optional<BookingEntry> getBefore(BookingEntry e) {
LocalDate plusOneDay = e.getDate().minusDays(1);
Room room = e.getRoom();
Collection<BookingEntry> bookingsThatDay = bookingEntries.get(plusOneDay);
if (bookingsThatDay != null) {
return bookingsThatDay.stream().filter(b -> b.getRoom().equals(room)).findFirst();
}
return Optional.empty();
}
use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.
the class MainManager method getAfter.
public Optional<BookingEntry> getAfter(BookingEntry e) {
LocalDate plusOneDay = e.getDate().plusDays(1);
Room room = e.getRoom();
Collection<BookingEntry> bookingsThatDay = bookingEntries.get(plusOneDay);
if (bookingsThatDay != null) {
return bookingsThatDay.stream().filter(b -> b.getRoom().equals(room)).findFirst();
}
return Optional.empty();
}
use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.
the class BookingEntries method getEarningsAirbnb.
@Deprecated
public static double getEarningsAirbnb(final Collection<? extends BookingEntry> bookings, final Function<EarningsProvider, Number> earningsProvider) {
double result = 0;
final BookingsByOrigin<BookingEntry> bo = new BookingsByOrigin<>(bookings);
final Map<BookingBean, Collection<BookingEntry>> map = new LinkedHashMap<>();
for (final BookingEntry be : bo.getAirbnbBookings()) {
final Collection<BookingEntry> value = map.getOrDefault(be.getElement(), new ArrayList<>());
value.add(be);
map.put(be.getElement(), value);
}
for (final Entry<BookingBean, Collection<BookingEntry>> en : map.entrySet()) {
final LocalDate ci = en.getKey().getCheckIn();
if (en.getKey().isSplitBooking()) {
final int daysCurrentMonth = YearMonth.from(ci).lengthOfMonth();
final double earnings = getEarningsGeneral(en.getValue(), earningsProvider);
if (logger.isInfoEnabled()) {
logger.info("Split-payment (" + String.format("%5.2f", earnings) + ") for " + en.getKey() + ", days of month " + daysCurrentMonth);
}
result += earnings;
} else {
result += getEarningsGeneral(en.getValue(), earningsProvider);
}
}
return result;
}
use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.
the class CellContentController method buildEntryCheckIn.
private static Node buildEntryCheckIn(final BookingEntry e) {
final Label l = getNewLabel(e.getElement().getGuest().getName());
if (e.getElement().isSplitBooking()) {
Optional<BookingEntry> next = MainManager.getInstance().getBefore(e);
if (next.isPresent()) {
BookingEntry be = next.get();
if (be.getElement().getGuest().equals(e.getElement().getGuest())) {
// do not apply label for the same guest
return l;
}
}
}
l.getStyleClass().add("check-in");
return l;
}
Aggregations