Search in sources :

Example 1 with RoomBean

use of com.github.drbookings.ui.beans.RoomBean in project drbookings by DrBookings.

the class MainManager method applyFilter.

public synchronized void applyFilter(final String guestNameFilterString) {
    uiData.addAll(filteredDates);
    filteredDates.clear();
    for (final Iterator<DateBean> it = uiData.iterator(); it.hasNext(); ) {
        final DateBean db = it.next();
        for (final RoomBean rb : db.getRooms()) {
            rb.setBookingFilterString(guestNameFilterString);
        }
        if (!StringUtils.isBlank(guestNameFilterString) && db.isEmpty()) {
            filteredDates.add(db);
            it.remove();
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Filtered dates: " + filteredDates.size());
    }
}
Also used : DateBean(com.github.drbookings.ui.beans.DateBean) RoomBean(com.github.drbookings.ui.beans.RoomBean)

Example 2 with RoomBean

use of com.github.drbookings.ui.beans.RoomBean in project drbookings by DrBookings.

the class MainController method deleteSelected.

private void deleteSelected() {
    final ObservableList<TablePosition> selectedItems = tableView.getSelectionModel().getSelectedCells();
    if (logger.isDebugEnabled()) {
        logger.debug("Delete " + selectedItems);
    }
    for (final TablePosition<DateBean, ?> tp : selectedItems) {
        final int c = tp.getColumn();
        final int r = tp.getRow();
        final TableColumn<DateBean, ?> tableColumn = tp.getTableColumn();
        final Object cellData = tableColumn.getCellData(r);
        if (logger.isDebugEnabled()) {
            logger.debug("Delete in column " + c + ", " + cellData);
        }
        if (cellData instanceof DateBean) {
            final DateBean db = (DateBean) cellData;
            if (db.getRooms().isEmpty()) {
            } else {
                final RoomBean rb = db.getRoom("" + c);
                if (rb.isEmpty()) {
                    continue;
                }
                final BookingBean booking = rb.getFilteredBookingEntries().get(0).getElement();
                if (logger.isDebugEnabled()) {
                    logger.debug("Deleting " + booking);
                }
                manager.removeBooking(booking);
            }
        }
    }
}
Also used : DateBean(com.github.drbookings.ui.beans.DateBean) RoomBean(com.github.drbookings.ui.beans.RoomBean) BookingBean(com.github.drbookings.model.data.BookingBean)

Example 3 with RoomBean

use of com.github.drbookings.ui.beans.RoomBean in project drbookings by DrBookings.

the class BookingDetailsController method update.

private void update(final Collection<? extends RoomBean> rooms) {
    clearAll();
    final List<BookingBean> bookings = new ArrayList<>(rooms.stream().flatMap(r -> r.getFilteredBookingEntries().stream().map(b -> b.getElement())).collect(Collectors.toSet()));
    Collections.sort(bookings);
    for (final Iterator<BookingBean> it = bookings.iterator(); it.hasNext(); ) {
        final BookingBean be = it.next();
        addBookingEntry(be);
        if (it.hasNext()) {
            addSeparator();
        }
    }
}
Also used : Pos(javafx.geometry.Pos) Initializable(javafx.fxml.Initializable) java.util(java.util) javafx.scene.control(javafx.scene.control) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) MainManager(com.github.drbookings.model.data.manager.MainManager) TextFlow(javafx.scene.text.TextFlow) Payment(com.github.drbookings.model.Payment) VBox(javafx.scene.layout.VBox) Bindings(javafx.beans.binding.Bindings) StringUtils(org.apache.commons.lang3.StringUtils) RoomBean(com.github.drbookings.ui.beans.RoomBean) Insets(javafx.geometry.Insets) ListChangeListener(javafx.collections.ListChangeListener) CleaningEntry(com.github.drbookings.ui.CleaningEntry) LocalDates(com.github.drbookings.LocalDates) Pane(javafx.scene.layout.Pane) BookingBean(com.github.drbookings.model.data.BookingBean) HBox(javafx.scene.layout.HBox) RoomBeanSelectionManager(com.github.drbookings.ui.selection.RoomBeanSelectionManager) Logger(org.slf4j.Logger) DecimalFormat(java.text.DecimalFormat) Collectors(java.util.stream.Collectors) SettingsManager(com.github.drbookings.model.settings.SettingsManager) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) NumberStringConverter(javafx.util.converter.NumberStringConverter) ActionEvent(javafx.event.ActionEvent) ModifyBookingDialogFactory(com.github.drbookings.ui.dialogs.ModifyBookingDialogFactory) LocalDate(java.time.LocalDate) Styles(com.github.drbookings.ui.Styles) Entry(java.util.Map.Entry) BookingBean(com.github.drbookings.model.data.BookingBean)

Example 4 with RoomBean

use of com.github.drbookings.ui.beans.RoomBean in project drbookings by DrBookings.

the class MinimumPriceCalulcator method apply.

@Override
public Number apply(final Collection<RoomBean> rooms) {
    if (rooms.isEmpty()) {
        if (logger.isDebugEnabled()) {
            logger.debug("Nothing selected");
        }
        return Double.NaN;
    }
    final Set<LocalDate> refDays = rooms.stream().map(r -> r.getDate()).collect(Collectors.toSet());
    final Set<YearMonth> months = refDays.stream().map(d -> YearMonth.from(d)).collect(Collectors.toSet());
    final OptionalDouble avDays = months.stream().mapToDouble(ym -> ym.getMonth().maxLength()).average();
    final double or = orc.apply(rooms).doubleValue();
    final double ref2 = refIncome.doubleValue() / avDays.getAsDouble() * refDays.size();
    final double daysBusy = refDays.size() * or;
    final double result = ref2 / daysBusy / SettingsManager.getInstance().getNumberOfRooms();
    return result;
}
Also used : Logger(org.slf4j.Logger) LocalDate(java.time.LocalDate) Collection(java.util.Collection) YearMonth(java.time.YearMonth) OptionalDouble(java.util.OptionalDouble) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) SettingsManager(com.github.drbookings.model.settings.SettingsManager) RoomBean(com.github.drbookings.ui.beans.RoomBean) YearMonth(java.time.YearMonth) LocalDate(java.time.LocalDate) OptionalDouble(java.util.OptionalDouble)

Example 5 with RoomBean

use of com.github.drbookings.ui.beans.RoomBean 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)

Aggregations

RoomBean (com.github.drbookings.ui.beans.RoomBean)5 LocalDate (java.time.LocalDate)3 Collectors (java.util.stream.Collectors)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 BookingBean (com.github.drbookings.model.data.BookingBean)2 SettingsManager (com.github.drbookings.model.settings.SettingsManager)2 DateBean (com.github.drbookings.ui.beans.DateBean)2 RoomBeanSelectionManager (com.github.drbookings.ui.selection.RoomBeanSelectionManager)2 YearMonth (java.time.YearMonth)2 ListChangeListener (javafx.collections.ListChangeListener)2 LocalDates (com.github.drbookings.LocalDates)1 Payment (com.github.drbookings.model.Payment)1 MainManager (com.github.drbookings.model.data.manager.MainManager)1 BookingEntry (com.github.drbookings.ui.BookingEntry)1 CleaningEntry (com.github.drbookings.ui.CleaningEntry)1 Styles (com.github.drbookings.ui.Styles)1 ModifyBookingDialogFactory (com.github.drbookings.ui.dialogs.ModifyBookingDialogFactory)1 URL (java.net.URL)1 DecimalFormat (java.text.DecimalFormat)1