Search in sources :

Example 21 with StockCardLineItemReason

use of org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason in project openlmis-stockmanagement by OpenLMIS.

the class ValidReasonAssignmentRepositoryIntegrationTest method generateInstance.

@Override
ValidReasonAssignment generateInstance() throws Exception {
    int instanceNumber = getNextInstanceNumber();
    StockCardLineItemReason reason = new StockCardLineItemReasonDataBuilder().withoutId().withName("Name" + instanceNumber).withCreditType().build();
    reasonRepository.save(reason);
    return new ValidReasonAssignment(PROGRAM_ID, FACILITY_TYPE_ID, false, reason);
}
Also used : StockCardLineItemReason(org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason) ValidReasonAssignment(org.openlmis.stockmanagement.domain.reason.ValidReasonAssignment) StockCardLineItemReasonDataBuilder(org.openlmis.stockmanagement.testutils.StockCardLineItemReasonDataBuilder)

Example 22 with StockCardLineItemReason

use of org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason in project openlmis-stockmanagement by OpenLMIS.

the class StockCardLineItemReasonRepositoryIntegrationTest method shouldFindByName.

@Test
public void shouldFindByName() throws Exception {
    StockCardLineItemReason reason = reasonRepository.findByName(firstReason.getName());
    assertThat(reason, is(firstReason));
}
Also used : StockCardLineItemReason(org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason) Test(org.junit.Test)

Example 23 with StockCardLineItemReason

use of org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason in project openlmis-stockmanagement by OpenLMIS.

the class StockCardLineItemTest method shouldIncreaseSohOfLineItemWithCreditReason.

@Test
public void shouldIncreaseSohOfLineItemWithCreditReason() throws Exception {
    // given
    StockCardLineItemReason creditReason = StockCardLineItemReason.builder().reasonType(ReasonType.CREDIT).build();
    StockCardLineItem lineItem = StockCardLineItem.builder().reason(creditReason).quantity(10).build();
    // when
    lineItem.calculateStockOnHand(5);
    // then
    assertThat(lineItem.getStockOnHand(), is(15));
}
Also used : StockCardLineItemReason(org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason) Test(org.junit.Test)

Example 24 with StockCardLineItemReason

use of org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason in project openlmis-stockmanagement by OpenLMIS.

the class StockCardLineItemTest method shouldDecreaseSohOfLineItemWithDebitReason.

@Test
public void shouldDecreaseSohOfLineItemWithDebitReason() throws Exception {
    // given
    StockCardLineItemReason debitReason = StockCardLineItemReason.builder().reasonType(ReasonType.DEBIT).build();
    StockCardLineItem lineItem = StockCardLineItem.builder().reason(debitReason).quantity(5).build();
    // when
    lineItem.calculateStockOnHand(15);
    // then
    assertThat(lineItem.getStockOnHand(), is(10));
}
Also used : StockCardLineItemReason(org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason) Test(org.junit.Test)

Example 25 with StockCardLineItemReason

use of org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason in project openlmis-stockmanagement by OpenLMIS.

the class AdjustmentReasonValidator method validateReason.

private void validateReason(StockEventDto event, StockEventLineItemDto lineItem) {
    StockCardLineItemReason foundReason = event.getContext().findEventReason(lineItem.getReasonId());
    // that is handled by other validators
    if (foundReason != null) {
        validReasonType(foundReason);
        validReasonCategory(foundReason);
    }
}
Also used : StockCardLineItemReason(org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason)

Aggregations

StockCardLineItemReason (org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason)28 Test (org.junit.Test)18 StockCardLineItemReasonDataBuilder (org.openlmis.stockmanagement.testutils.StockCardLineItemReasonDataBuilder)8 ResultActions (org.springframework.test.web.servlet.ResultActions)6 UUID (java.util.UUID)4 ValidReasonAssignment (org.openlmis.stockmanagement.domain.reason.ValidReasonAssignment)4 UUID.randomUUID (java.util.UUID.randomUUID)3 StockEventDto (org.openlmis.stockmanagement.dto.StockEventDto)3 BaseIntegrationTest (org.openlmis.stockmanagement.BaseIntegrationTest)2 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)2 StockCardLineItem (org.openlmis.stockmanagement.domain.card.StockCardLineItem)2 OrderableLotIdentity (org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity)2 Node (org.openlmis.stockmanagement.domain.sourcedestination.Node)2 ValidReasonAssignmentDto (org.openlmis.stockmanagement.dto.ValidReasonAssignmentDto)2 Profiler (org.slf4j.profiler.Profiler)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 List (java.util.List)1 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)1 PhysicalInventoryLineItemAdjustment (org.openlmis.stockmanagement.domain.physicalinventory.PhysicalInventoryLineItemAdjustment)1 ValidDestinationAssignment (org.openlmis.stockmanagement.domain.sourcedestination.ValidDestinationAssignment)1