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