use of org.openlmis.stockmanagement.domain.card.StockCardLineItem 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.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockCardSummariesServiceTest method createStockCard.
private StockCard createStockCard(UUID orderableId, UUID cardId) {
StockCard stockCard = new StockCard();
stockCard.setOrderableId(orderableId);
stockCard.setId(cardId);
Map<String, String> oldExtraData = new HashMap<>();
oldExtraData.put("vvmStatus", "STAGE_1");
Map<String, String> newExtraData = new HashMap<>();
newExtraData.put("vvmStatus", "STAGE_2");
StockCardLineItem lineItem1 = StockCardLineItem.builder().occurredDate(LocalDate.of(2017, 3, 17)).processedDate(of(2017, 3, 17, 15, 10, 31, 100, UTC)).quantity(1).extraData(oldExtraData).build();
StockCardLineItem lineItem2 = StockCardLineItem.builder().occurredDate(LocalDate.of(2017, 3, 18)).processedDate(of(2017, 3, 18, 15, 10, 31, 100, UTC)).quantity(1).extraData(newExtraData).build();
stockCard.setLineItems(asList(lineItem1, lineItem2, lineItem1));
return stockCard;
}
use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class QuantityValidatorTest method shouldNotRejectWhenStockOnHandWithAdjustmentsMatchesQuantity.
@Test
public void shouldNotRejectWhenStockOnHandWithAdjustmentsMatchesQuantity() throws Exception {
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 10);
StockCard card = new StockCard();
card.setLineItems(newArrayList(lineItem));
StockEventDto event = spy(createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, singletonList(createDebitAdjustment(5))));
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 shouldNotRejectWhenStockOnHandDoesNotMatchQuantityAndNoAdjustmentsProvided.
@Test
public void shouldNotRejectWhenStockOnHandDoesNotMatchQuantityAndNoAdjustmentsProvided() {
// given
LocalDate firstDate = dateFromYear(2015);
StockCardLineItem lineItem = createCreditLineItem(firstDate.plusDays(1), 15);
StockCard card = new StockCard();
card.setLineItems(newArrayList(lineItem));
StockEventDto event = createPhysicalInventoryEventDto(firstDate.plusDays(2), 5, null);
mockCardFound(event, card);
// when
quantityValidator.validate(event);
}
use of org.openlmis.stockmanagement.domain.card.StockCardLineItem in project openlmis-stockmanagement by OpenLMIS.
the class StockCardLineItemDataBuilder method build.
/**
* Creates new instance of {@link StockCardLineItem} with properties.
*
* @return created line item.
*/
public StockCardLineItem build() {
StockCardLineItem lineItem = new StockCardLineItem(stockCard, originEvent, quantity, extraData, reason, sourceFreeText, destinationFreeText, documentNumber, reasonFreeText, signature, source, destination, occurredDate, processedDateTime, userId, stockOnHand, stockAdjustments);
lineItem.setId(id);
return lineItem;
}
Aggregations