Search in sources :

Example 6 with CleaningEntry

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

the class UpcomingController method update.

private void update() {
    final int lookAheadDays = SettingsManager.getInstance().getUpcomingLookAhead();
    this.box.getChildren().clear();
    for (int i = 0; i < lookAheadDays; i++) {
        final LocalDate date = LocalDate.now().plusDays(i);
        final List<BookingEntry> upcomingBookings = manager.getBookingEntries().stream().filter(b -> b.getDate().equals(date)).collect(Collectors.toList());
        final List<CleaningEntry> upcomingCleanings = manager.getCleaningEntries().stream().filter(c -> c.getDate().equals(date)).collect(Collectors.toList());
        addEvents(date, upcomingBookings, upcomingCleanings);
        if (i != lookAheadDays - 1) {
            this.box.getChildren().add(new Separator());
        }
    }
}
Also used : Initializable(javafx.fxml.Initializable) Logger(org.slf4j.Logger) URL(java.net.URL) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) MainManager(com.github.drbookings.model.data.manager.MainManager) TextFlow(javafx.scene.text.TextFlow) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) DateBean(com.github.drbookings.ui.beans.DateBean) ArrayList(java.util.ArrayList) SettingsManager(com.github.drbookings.model.settings.SettingsManager) FXML(javafx.fxml.FXML) Separator(javafx.scene.control.Separator) Text(javafx.scene.text.Text) List(java.util.List) ResourceBundle(java.util.ResourceBundle) ListChangeListener(javafx.collections.ListChangeListener) LocalDate(java.time.LocalDate) CleaningEntry(com.github.drbookings.ui.CleaningEntry) BookingEntry(com.github.drbookings.ui.BookingEntry) Collections(java.util.Collections) CleaningEntry(com.github.drbookings.ui.CleaningEntry) LocalDate(java.time.LocalDate) BookingEntry(com.github.drbookings.ui.BookingEntry) Separator(javafx.scene.control.Separator)

Example 7 with CleaningEntry

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

the class DefaultNetEarningsCalculatorTest method test.

@Test
public void test() {
    final DefaultNetEarningsCalculator c = new DefaultNetEarningsCalculator();
    final BookingBean b = TestUtils.getTestBooking(LocalDate.now(), LocalDate.now().plusDays(4));
    b.setGrossEarningsExpression("360");
    b.setServiceFee(0);
    b.setServiceFeesPercent(12f);
    b.setCleaningFees(60);
    final CleaningEntry ce = new CleaningEntry(LocalDate.now(), b, new Cleaning("testCleaning"), null);
    ce.setCleaningCosts(40);
    b.setCleaning(ce);
    assertEquals(360 - ((360 - 60) * 0.12), c.apply(b).doubleValue(), 0.001);
}
Also used : CleaningEntry(com.github.drbookings.ui.CleaningEntry) Cleaning(com.github.drbookings.model.data.Cleaning) BookingBean(com.github.drbookings.model.data.BookingBean)

Example 8 with CleaningEntry

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

the class MainManagerTest method testAddCleaning01.

@Test
public void testAddCleaning01() {
    mm = new MainManager();
    final CleaningEntry ce = new CleaningEntry(LocalDate.now(), TestUtils.getTestBooking("tt"), new Cleaning("testCleaning"), null);
    mm.addCleaning(LocalDate.now(), "testCleaning", TestUtils.getTestBooking("tt"));
    assertTrue(mm.getCleaningEntries().contains(ce));
}
Also used : CleaningEntry(com.github.drbookings.ui.CleaningEntry) Cleaning(com.github.drbookings.model.data.Cleaning) Test(org.junit.Test)

Example 9 with CleaningEntry

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

the class MainManager method addCleaning.

public synchronized CleaningEntry addCleaning(final LocalDate date, final String cleaningName, final BookingBean booking) {
    Objects.requireNonNull(date, "Date must not be null");
    Objects.requireNonNull(booking, "BookingBean must not be null");
    if (cleaningName == null || cleaningName.trim().length() == 0) {
        throw new IllegalArgumentException();
    }
    final Cleaning cleaning = cleaningProvider.getOrCreateElement(cleaningName);
    final CleaningEntry cleaningEntry = new CleaningEntry(date, booking, cleaning, this);
    cleaningEntry.setCleaningCosts(SettingsManager.getInstance().getCleaningCosts());
    if (containsCleaningByNameDateRoom(cleaningEntry)) {
        if (logger.isWarnEnabled()) {
            logger.warn("Skip cleaning " + cleaning);
        }
    } else {
        cleaningEntries.put(date, cleaningEntry);
        cleaningEntriesList.add(cleaningEntry);
        addUiDataCleaning(cleaningEntry);
        return cleaningEntry;
    }
    return null;
}
Also used : CleaningEntry(com.github.drbookings.ui.CleaningEntry)

Aggregations

CleaningEntry (com.github.drbookings.ui.CleaningEntry)9 Text (javafx.scene.text.Text)4 TextFlow (javafx.scene.text.TextFlow)4 Cleaning (com.github.drbookings.model.data.Cleaning)3 FXML (javafx.fxml.FXML)3 MainManager (com.github.drbookings.model.data.manager.MainManager)2 SettingsManager (com.github.drbookings.model.settings.SettingsManager)2 BookingEntry (com.github.drbookings.ui.BookingEntry)2 DateBean (com.github.drbookings.ui.beans.DateBean)2 URL (java.net.URL)2 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 ResourceBundle (java.util.ResourceBundle)2 Collectors (java.util.stream.Collectors)2 ListChangeListener (javafx.collections.ListChangeListener)2 Initializable (javafx.fxml.Initializable)2 Separator (javafx.scene.control.Separator)2