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