Search in sources :

Example 21 with DateRange

use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.

the class OrderDatesServiceTest method shouldReturnDateRangeWithCorrectedStartDate2.

@Test
public final void shouldReturnDateRangeWithCorrectedStartDate2() {
    // given
    Date correctedStartDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
    stubDateField(order, OrderFields.CORRECTED_DATE_FROM, correctedStartDate);
    // when
    DateRange dateRange = orderDatesService.getCalculatedDates(order);
    // then
    assertEquals(correctedStartDate, dateRange.getFrom());
    assertNull(dateRange.getTo());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 22 with DateRange

use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.

the class OrderDatesServiceTest method shouldReturnEmptyDateRangeIfDatesIsNotSpecified.

@Test
public final void shouldReturnEmptyDateRangeIfDatesIsNotSpecified() {
    // when
    DateRange dateRange = orderDatesService.getCalculatedDates(order);
    // then
    assertNull(dateRange.getFrom());
    assertNull(dateRange.getTo());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Test(org.junit.Test)

Example 23 with DateRange

use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.

the class OrderDatesServiceTest method shouldReturnDateRangeWithEffectiveEndDate2.

@Test
public final void shouldReturnDateRangeWithEffectiveEndDate2() {
    // given
    Date plannedEndDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
    stubDateField(order, OrderFields.DATE_TO, plannedEndDate);
    Date effectiveEndDate = new DateTime(2013, 2, 8, 0, 0, 0, 0).toDate();
    stubDateField(order, OrderFields.EFFECTIVE_DATE_TO, effectiveEndDate);
    // when
    DateRange dateRange = orderDatesService.getCalculatedDates(order);
    // then
    assertNull(dateRange.getFrom());
    assertEquals(effectiveEndDate, dateRange.getTo());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 24 with DateRange

use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.

the class OrderDatesServiceTest method shouldReturnDateRangeWithCorrectedEndDate.

@Test
public final void shouldReturnDateRangeWithCorrectedEndDate() {
    // given
    Date plannedEndDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
    stubDateField(order, OrderFields.DATE_TO, plannedEndDate);
    Date correctedEndDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
    stubDateField(order, OrderFields.CORRECTED_DATE_TO, correctedEndDate);
    // when
    DateRange dateRange = orderDatesService.getCalculatedDates(order);
    // then
    assertNull(dateRange.getFrom());
    assertEquals(correctedEndDate, dateRange.getTo());
}
Also used : DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 25 with DateRange

use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.

the class OrderStateService method checkOrderDates.

public void checkOrderDates(final StateChangeContext stateChangeContext) {
    final Entity order = stateChangeContext.getOwner();
    DateRange orderDateRange = orderDatesService.getCalculatedDates(order);
    Date dateFrom = orderDateRange.getFrom();
    Date dateTo = orderDateRange.getTo();
    if (dateFrom == null || dateTo == null || dateTo.after(dateFrom)) {
        return;
    }
    stateChangeContext.addValidationError("orders.validate.global.error.datesOrder.overdue");
}
Also used : Entity(com.qcadoo.model.api.Entity) DateRange(com.qcadoo.commons.dateTime.DateRange) Date(java.util.Date)

Aggregations

DateRange (com.qcadoo.commons.dateTime.DateRange)29 Test (org.junit.Test)25 Date (java.util.Date)24 DateTime (org.joda.time.DateTime)20 Entity (com.qcadoo.model.api.Entity)2 Shift (com.qcadoo.mes.basic.shift.Shift)1 EntityList (com.qcadoo.model.api.EntityList)1 LocalTime (org.joda.time.LocalTime)1