use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockCardRepositoryIntegrationTest method generateInstance.
private StockCard generateInstance(UUID facility, UUID program, UUID product, UUID lot) {
StockEvent event = new StockEventDataBuilder().withoutId().withFacility(facility).withProgram(program).build();
event = stockEventsRepository.save(event);
StockCardLineItem lineItem = new StockCardLineItemDataBuilder().withoutId().withOriginEvent(event).build();
StockCard stockCard = new StockCardDataBuilder(event).withoutId().withOrderable(product).withLot(lot).withLineItem(lineItem).build();
lineItem.setStockCard(stockCard);
return stockCard;
}
use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldRejectWhenAnyAdjustmentHasNegativeQuantity.
@Test
public void shouldRejectWhenAnyAdjustmentHasNegativeQuantity() throws Exception {
// expect
expectedException.expect(ValidationMessageException.class);
expectedException.expectMessage(ERROR_EVENT_ADJUSTMENT_QUANITITY_INVALID);
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 15);
StockCard card = new StockCard();
card.setLineItems(singletonList(lineItem));
StockEventDto event = spy(createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, singletonList(createCreditAdjustment(-2))));
mockCardFound(event, card);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenStockOnHandWithAdjustmentsDoesNotMatchQuantity.
@Test
public void shouldNotRejectWhenStockOnHandWithAdjustmentsDoesNotMatchQuantity() {
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 15);
StockCard card = new StockCard();
card.setLineItems(newArrayList(lineItem));
StockEventDto event = spy(createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, singletonList(createCreditAdjustment(5))));
mockCardFound(event, card);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockCardDtoDataBuilder method createStockCardDto.
/**
* Create stock card dto.
*
* @return stock card dto
*/
public static StockCardDto createStockCardDto() {
StockCardLineItemReason reason = StockCardLineItemReason.builder().name("Transfer In").reasonCategory(ReasonCategory.ADJUSTMENT).reasonType(ReasonType.CREDIT).build();
StockCardLineItem lineItem = StockCardLineItem.builder().stockOnHand(1).quantity(1).occurredDate(LocalDate.of(2017, 2, 13)).reason(reason).build();
StockCardLineItemDto lineItemDto = StockCardLineItemDto.builder().lineItem(lineItem).source(FacilityDto.builder().name("HF1").build()).build();
return StockCardDto.builder().stockOnHand(1).facility(FacilityDto.builder().name("HC01").build()).program(ProgramDto.builder().name("HIV").build()).orderable(OrderableDto.builder().productCode("ABC01").build()).lineItems(Arrays.asList(lineItemDto)).build();
}
use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockCardLineItemDataBuilder method buildMock.
/**
* Creates new mock instance of {@link StockCardLineItem} with properties.
*
* @return created mock.
*/
public StockCardLineItem buildMock() {
StockCardLineItem lineItem = mock(StockCardLineItem.class);
when(lineItem.getId()).thenReturn(id);
when(lineItem.getStockCard()).thenReturn(stockCard);
when(lineItem.getOriginEvent()).thenReturn(originEvent);
when(lineItem.getQuantity()).thenReturn(quantity);
when(lineItem.getExtraData()).thenReturn(extraData);
when(lineItem.getReason()).thenReturn(reason);
when(lineItem.getSourceFreeText()).thenReturn(sourceFreeText);
when(lineItem.getDestinationFreeText()).thenReturn(destinationFreeText);
when(lineItem.getDocumentNumber()).thenReturn(documentNumber);
when(lineItem.getReasonFreeText()).thenReturn(reasonFreeText);
when(lineItem.getSignature()).thenReturn(signature);
when(lineItem.getSource()).thenReturn(source);
when(lineItem.getDestination()).thenReturn(destination);
when(lineItem.getOccurredDate()).thenReturn(occurredDate);
when(lineItem.getProcessedDate()).thenReturn(processedDateTime);
when(lineItem.getUserId()).thenReturn(userId);
when(lineItem.getStockOnHand()).thenReturn(stockOnHand);
when(lineItem.getStockAdjustments()).thenReturn(stockAdjustments);
return lineItem;
}
Aggregations