use of org.openlmis.stockmanagement.dto.StockEventLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class AdjustmentReasonValidator method validate.
@Override
public void validate(StockEventDto stockEventDto) {
LOGGER.debug("Validate adjustment reason");
boolean hasSourceOrDestination = stockEventDto.hasSource() || stockEventDto.hasDestination();
if (hasSourceOrDestination || !stockEventDto.hasLineItems()) {
return;
}
for (StockEventLineItemDto lineItem : stockEventDto.getLineItems()) {
if (lineItem.hasReasonId()) {
validateReason(stockEventDto, lineItem);
}
}
}
use of org.openlmis.stockmanagement.dto.StockEventLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidator method calculateStockOnHand.
private void calculateStockOnHand(StockEventDto eventDto, List<StockEventLineItemDto> group, StockCard foundCard) {
for (StockEventLineItemDto lineItem : group) {
StockCardLineItem stockCardLineItem = StockCardLineItem.createLineItemFrom(eventDto, lineItem, foundCard, null);
stockCardLineItem.setReason(eventDto.getContext().findEventReason(lineItem.getReasonId()));
}
foundCard.calculateStockOnHand();
}
use of org.openlmis.stockmanagement.dto.StockEventLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenEventReasonIdIsNotFound.
@Test
public void shouldNotRejectWhenEventReasonIdIsNotFound() throws Exception {
// given
StockEventDto event = createStockEventDto();
StockEventLineItemDto invalidItem = event.getLineItems().get(0);
invalidItem.setDestinationId(null);
setContext(event);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.dto.StockEventLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenEventLineItemHasNoReason.
@Test
public void shouldNotRejectWhenEventLineItemHasNoReason() throws Exception {
// given
StockEventDto event = createStockEventDto();
setContext(event);
StockEventLineItemDto invalidItem = event.getLineItems().get(0);
invalidItem.setDestinationId(randomUUID());
invalidItem.setReasonId(null);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.dto.StockEventLineItemDto in project openlmis-stockmanagement by OpenLMIS.
the class StockEventDtoDataBuilder method createStockEventDto.
/**
* Create stock event dto object for testing.
*
* @return created dto object.
*/
public static StockEventDto createStockEventDto() {
StockEventDto stockEventDto = new StockEventDto();
stockEventDto.setDocumentNumber("c");
stockEventDto.setSignature("e");
stockEventDto.setProgramId(UUID.randomUUID());
stockEventDto.setFacilityId(UUID.randomUUID());
StockEventLineItemDto eventLineItemDto = createStockEventLineItem();
stockEventDto.setLineItems(singletonList(eventLineItemDto));
return stockEventDto;
}
Aggregations