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());
}
}
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);
}
}
}
}
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();
}
}
}
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;
}
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());
}
Aggregations