use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class PPSReportXlsHelper method getShiftEndDate.
private Optional<DateTime> getShiftEndDate(final DateTime day, final Entity shiftEntity) {
Shift shift = new Shift(shiftEntity);
com.google.common.base.Optional<DateRange> mayBeWorkTimeAt = shift.findWorkTimeAt(day.toDate());
if (mayBeWorkTimeAt.isPresent()) {
DateRange range = mayBeWorkTimeAt.get();
return Optional.of(new DateTime(range.getTo()));
}
return Optional.empty();
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderHooks method checkOrderDates.
public boolean checkOrderDates(final DataDefinition orderDD, final Entity order) {
DateRange orderDateRange = orderDatesService.getCalculatedDates(order);
Date dateFrom = orderDateRange.getFrom();
Date dateTo = orderDateRange.getTo();
if (Objects.isNull(dateFrom) || Objects.isNull(dateTo) || dateTo.after(dateFrom)) {
return true;
}
order.addError(orderDD.getField(OrderFields.FINISH_DATE), "orders.validate.global.error.datesOrder");
return false;
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithEffectiveStartDate.
@Test
public final void shouldReturnDateRangeWithEffectiveStartDate() {
// given
Date plannedStartDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_FROM, plannedStartDate);
Date correctedStartDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_FROM, correctedStartDate);
Date effectiveStartDate = new DateTime(2013, 2, 8, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.EFFECTIVE_DATE_FROM, effectiveStartDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertEquals(effectiveStartDate, dateRange.getFrom());
assertNull(dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithCorrectedStartAndCorrectedEndDate.
@Test
public final void shouldReturnDateRangeWithCorrectedStartAndCorrectedEndDate() {
// given
Date plannedStartDate = new DateTime(2012, 12, 30, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_FROM, plannedStartDate);
Date plannedEndDate = new DateTime(2013, 1, 1, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.DATE_TO, plannedEndDate);
Date correctedStartDate = new DateTime(2013, 1, 3, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_FROM, correctedStartDate);
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
assertEquals(correctedStartDate, dateRange.getFrom());
assertEquals(correctedEndDate, dateRange.getTo());
}
use of com.qcadoo.commons.dateTime.DateRange in project mes by qcadoo.
the class OrderDatesServiceTest method shouldReturnDateRangeWithEffectiveStartDate2.
@Test
public final void shouldReturnDateRangeWithEffectiveStartDate2() {
// given
Date correctedStartDate = new DateTime(2013, 1, 5, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.CORRECTED_DATE_FROM, correctedStartDate);
Date effectiveStartDate = new DateTime(2013, 2, 8, 0, 0, 0, 0).toDate();
stubDateField(order, OrderFields.EFFECTIVE_DATE_FROM, effectiveStartDate);
// when
DateRange dateRange = orderDatesService.getCalculatedDates(order);
// then
assertEquals(effectiveStartDate, dateRange.getFrom());
assertNull(dateRange.getTo());
}
Aggregations