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);
}
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));
}
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));
}
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));
}
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);
}
}
Aggregations