Search in sources :

Example 31 with StockCard

use of org.openlmis.stockmanagement.domain.card.StockCard 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);
}
Also used : StockCardLineItem(org.openlmis.stockmanagement.domain.card.StockCardLineItem) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 32 with StockCard

use of org.openlmis.stockmanagement.domain.card.StockCard 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);
}
Also used : StockCardLineItem(org.openlmis.stockmanagement.domain.card.StockCardLineItem) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) StockEventDtoDataBuilder.createStockEventDto(org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto) StockEventDto(org.openlmis.stockmanagement.dto.StockEventDto) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 33 with StockCard

use of org.openlmis.stockmanagement.domain.card.StockCard in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummariesV2DtoBuilderTest method shouldBuildStockCardSummaries.

@Test
public void shouldBuildStockCardSummaries() throws Exception {
    List<StockCard> stockCards = asList(stockCard, stockCard1);
    LocalDate asOfDate = LocalDate.now();
    List<StockCardSummaryV2Dto> result = builder.build(asList(orderable1, orderable2, orderable3), stockCards, fulfillMap, asOfDate);
    StockCardSummaryV2Dto summary1 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable1.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
    StockCardSummaryV2Dto summary2 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable2.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
    StockCardSummaryV2Dto summary3 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable3.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate)));
    assertEquals(3, result.size());
    assertThat(result, hasItems(summary1, summary2, summary3));
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) ObjectReferenceDtoDataBuilder(org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 34 with StockCard

use of org.openlmis.stockmanagement.domain.card.StockCard in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummariesV2DtoBuilderTest method shouldBuildStockCardSummariesForCurrentDate.

@Test
public void shouldBuildStockCardSummariesForCurrentDate() throws Exception {
    List<StockCard> stockCards = asList(stockCard, stockCard1);
    LocalDate asOfDate = LocalDate.now();
    List<StockCardSummaryV2Dto> result = builder.build(Collections.singletonList(orderable1), stockCards, fulfillMap, null);
    StockCardSummaryV2Dto summary1 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable1.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
    assertEquals(1, result.size());
    assertThat(result, hasItems(summary1));
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) ObjectReferenceDtoDataBuilder(org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 35 with StockCard

use of org.openlmis.stockmanagement.domain.card.StockCard in project openlmis-stockmanagement by OpenLMIS.

the class StockCardSummariesV2DtoBuilderTest method shouldBuildStockCardSummariesWithMultipleStockCardsForOrderable.

@Test
public void shouldBuildStockCardSummariesWithMultipleStockCardsForOrderable() throws Exception {
    List<StockCard> stockCards = asList(stockCard, stockCard1, stockCard2);
    LocalDate asOfDate = LocalDate.now();
    List<StockCardSummaryV2Dto> result = builder.build(asList(orderable1, orderable2, orderable3), stockCards, fulfillMap, asOfDate);
    StockCardSummaryV2Dto summary1 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable1.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard2, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
    StockCardSummaryV2Dto summary2 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable2.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard, orderable1, asOfDate)));
    StockCardSummaryV2Dto summary3 = new StockCardSummaryV2Dto(new ObjectReferenceDtoDataBuilder().withPath(ORDERABLES).withId(orderable3.getId()).build(), asSet(new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard1, orderable3, asOfDate), new CanFulfillForMeEntryDtoDataBuilder().buildWithStockCardAndOrderable(stockCard2, orderable3, asOfDate)));
    assertEquals(3, result.size());
    assertThat(result, hasItems(summary1, summary2, summary3));
}
Also used : CanFulfillForMeEntryDtoDataBuilder(org.openlmis.stockmanagement.testutils.CanFulfillForMeEntryDtoDataBuilder) ObjectReferenceDtoDataBuilder(org.openlmis.stockmanagement.testutils.ObjectReferenceDtoDataBuilder) StockCard(org.openlmis.stockmanagement.domain.card.StockCard) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

StockCard (org.openlmis.stockmanagement.domain.card.StockCard)35 Test (org.junit.Test)20 StockEventDto (org.openlmis.stockmanagement.dto.StockEventDto)12 UUID (java.util.UUID)11 StockCardLineItem (org.openlmis.stockmanagement.domain.card.StockCardLineItem)11 LocalDate (java.time.LocalDate)10 StockEventDtoDataBuilder.createStockEventDto (org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto)9 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)6 OrderableLotIdentity (org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity)6 StockCardDto (org.openlmis.stockmanagement.dto.StockCardDto)6 List (java.util.List)5 FacilityDto (org.openlmis.stockmanagement.dto.referencedata.FacilityDto)5 OrderableDto (org.openlmis.stockmanagement.dto.referencedata.OrderableDto)5 UUID.randomUUID (java.util.UUID.randomUUID)4 StockEventLineItemDto (org.openlmis.stockmanagement.dto.StockEventLineItemDto)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Node (org.openlmis.stockmanagement.domain.sourcedestination.Node)3 LotDto (org.openlmis.stockmanagement.dto.referencedata.LotDto)3 ProgramDto (org.openlmis.stockmanagement.dto.referencedata.ProgramDto)3