Search in sources :

Example 6 with BookingBean

use of com.github.drbookings.model.data.BookingBean in project drbookings by DrBookings.

the class BookingEarningsCalculatorTest method test01.

@Test
public void test01() {
    c = new BookingEarningsCalculator();
    BookingBean b = BookingBeanTest.newInstance(LocalDate.of(2012, 02, 02), LocalDate.of(2012, 2, 5));
    b.setPaymentDone(true);
    float result = c.calculateEarnings(b);
    assertThat(result, is(0f));
}
Also used : BookingBean(com.github.drbookings.model.data.BookingBean) BookingBeanTest(com.github.drbookings.model.data.BookingBeanTest)

Example 7 with BookingBean

use of com.github.drbookings.model.data.BookingBean in project drbookings by DrBookings.

the class BookingEarningsCalculatorTest method test02.

@Test
public void test02() {
    c = new BookingEarningsCalculator();
    BookingBean b = BookingBeanTest.newInstance(LocalDate.of(2012, 02, 02), LocalDate.of(2012, 2, 5));
    b.setPaymentDone(true);
    b.setGrossEarningsExpression("30");
    float result = c.calculateEarnings(b);
    assertThat(result, is(30f));
}
Also used : BookingBean(com.github.drbookings.model.data.BookingBean) BookingBeanTest(com.github.drbookings.model.data.BookingBeanTest)

Example 8 with BookingBean

use of com.github.drbookings.model.data.BookingBean 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 9 with BookingBean

use of com.github.drbookings.model.data.BookingBean 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 10 with BookingBean

use of com.github.drbookings.model.data.BookingBean in project drbookings by DrBookings.

the class AirbnbEarningsCalculatorTest method test01.

@Test
public void test01() {
    BookingBean b = BookingBeanTest.newInstance(LocalDate.of(2012, 02, 02), LocalDate.of(2012, 2, 5));
    b.setPaymentDone(true);
    float result = c.calculateEarnings(b);
    assertThat(result, is(0f));
}
Also used : BookingBean(com.github.drbookings.model.data.BookingBean) BookingBeanTest(com.github.drbookings.model.data.BookingBeanTest)

Aggregations

BookingBean (com.github.drbookings.model.data.BookingBean)14 BookingBeanTest (com.github.drbookings.model.data.BookingBeanTest)6 OverbookingException (com.github.drbookings.OverbookingException)2 CleaningEntry (com.github.drbookings.ui.CleaningEntry)2 RoomBean (com.github.drbookings.ui.beans.RoomBean)2 LocalDate (java.time.LocalDate)2 LinkedHashSet (java.util.LinkedHashSet)2 Collectors (java.util.stream.Collectors)2 FXML (javafx.fxml.FXML)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 DrBookingsApplication (com.github.drbookings.DrBookingsApplication)1 LocalDates (com.github.drbookings.LocalDates)1 Payment (com.github.drbookings.model.Payment)1 BookingOrigin (com.github.drbookings.model.data.BookingOrigin)1 Cleaning (com.github.drbookings.model.data.Cleaning)1 Guest (com.github.drbookings.model.data.Guest)1 Room (com.github.drbookings.model.data.Room)1 MainManager (com.github.drbookings.model.data.manager.MainManager)1 BookingBeanSer (com.github.drbookings.model.ser.BookingBeanSer)1