Search in sources :

Example 16 with BookingEntry

use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.

the class RoomBean method hasCheckIn.

public boolean hasCheckIn() {
    final List<BookingEntry> filteredBookingEntries = getFilteredBookingEntries();
    if (filteredBookingEntries.size() == 1 && filteredBookingEntries.get(0).isCheckIn()) {
        return true;
    }
    boolean check = false;
    boolean split = false;
    for (final BookingEntry be : filteredBookingEntries) {
        if (be.isCheckIn()) {
            check = true;
        }
        if (be.getElement().isSplitBooking()) {
            split = true;
        }
    }
    // any booking is check-in and any booking is split booking
    return check && !split;
}
Also used : BookingEntry(com.github.drbookings.ui.BookingEntry)

Example 17 with BookingEntry

use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.

the class MainManager method roomBusy.

private boolean roomBusy(final BookingEntry bookingEntry) {
    if (!bookingEntry.isCheckOut()) {
        final Room room = bookingEntry.getElement().getRoom();
        final LocalDate date = bookingEntry.getDate();
        final Collection<BookingEntry> b = bookingEntries.get(date);
        if (b != null) {
            for (final BookingEntry be : b) {
                if (be.isCheckOut()) {
                    continue;
                }
                final Room room2 = be.getElement().getRoom();
                if (room2.equals(room)) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("Room " + room + " busy with " + be);
                    }
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : LocalDate(java.time.LocalDate) BookingEntry(com.github.drbookings.ui.BookingEntry)

Example 18 with BookingEntry

use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.

the class MoneyMonitor method calculateDateToEarnings.

private void calculateDateToEarnings(final ObservableList<? extends RoomBean> list) {
    final List<BookingEntry> selectedBookings = list.stream().flatMap(r -> r.getFilteredBookingEntries().stream()).collect(Collectors.toList());
    dayToNetEarnings.clear();
    for (final BookingEntry rb : selectedBookings) {
        fillDayMap(rb);
        fillMonthYearMap(rb);
    }
    setTotalNetEarnings(dayToNetEarnings.values().stream().mapToDouble(d -> d.doubleValue()).sum());
}
Also used : MapProperty(javafx.beans.property.MapProperty) SimpleMapProperty(javafx.beans.property.SimpleMapProperty) Logger(org.slf4j.Logger) RoomBeanSelectionManager(com.github.drbookings.ui.selection.RoomBeanSelectionManager) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) Collectors(java.util.stream.Collectors) RoomBean(com.github.drbookings.ui.beans.RoomBean) List(java.util.List) TreeMap(java.util.TreeMap) ListChangeListener(javafx.collections.ListChangeListener) LocalDate(java.time.LocalDate) Map(java.util.Map) YearMonth(java.time.YearMonth) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) BookingEntry(com.github.drbookings.ui.BookingEntry) BookingEntry(com.github.drbookings.ui.BookingEntry)

Example 19 with BookingEntry

use of com.github.drbookings.ui.BookingEntry in project drbookings by DrBookings.

the class BookingEntries method getEarningsAirbnb.

public static float getEarningsAirbnb(final Collection<? extends BookingEntry> bookings, boolean netEarnings, boolean paymentDone) {
    final BookingsByOrigin<BookingEntry> bo = new BookingsByOrigin<>(bookings);
    AirbnbEarningsCalculator aec = new AirbnbEarningsCalculator().filterForNetEarnings(netEarnings).filterForPaymentDone(paymentDone);
    return aec.calculateEarnings(BookingEntries.toBookings(bo.getAirbnbBookings()));
}
Also used : AirbnbEarningsCalculator(com.github.drbookings.model.AirbnbEarningsCalculator) BookingsByOrigin(com.github.drbookings.ui.BookingsByOrigin) BookingEntry(com.github.drbookings.ui.BookingEntry)

Aggregations

BookingEntry (com.github.drbookings.ui.BookingEntry)19 LocalDate (java.time.LocalDate)10 Collectors (java.util.stream.Collectors)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 SettingsManager (com.github.drbookings.model.settings.SettingsManager)7 FXCollections (javafx.collections.FXCollections)6 ListChangeListener (javafx.collections.ListChangeListener)6 ObservableList (javafx.collections.ObservableList)6 URL (java.net.URL)5 java.util (java.util)5 Entry (java.util.Map.Entry)5 FXML (javafx.fxml.FXML)5 Initializable (javafx.fxml.Initializable)5 StringUtils (org.apache.commons.lang3.StringUtils)5 CleaningEntry (com.github.drbookings.ui.CleaningEntry)4 Label (javafx.scene.control.Label)4 Guest (com.github.drbookings.model.data.Guest)3 MainManager (com.github.drbookings.model.data.manager.MainManager)3 BookingsByOrigin (com.github.drbookings.ui.BookingsByOrigin)3