Search in sources :

Example 11 with PoLine

use of org.folio.rest.jaxrs.model.PoLine in project mod-orders by folio-org.

the class PieceCreateFlowPoLineServiceTest method shouldIncreaseQuantityTo3ForCostAndLocationIfInitiallyWas2AndLocationIdInPieceAndMixedPOLWithLocationId.

@Test
@DisplayName("Add 1 electronic piece with location id to mixed pol with 1 location with location id and electronic and physical qty")
void shouldIncreaseQuantityTo3ForCostAndLocationIfInitiallyWas2AndLocationIdInPieceAndMixedPOLWithLocationId() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    Piece pieceToCreate = new Piece().withPoLineId(lineId).withLocationId(locationId).withFormat(Piece.Format.ELECTRONIC);
    Location loc = new Location().withLocationId(locationId).withQuantityElectronic(1).withQuantityPhysical(1).withQuantity(2);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(OPEN);
    Eresource eresource = new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE);
    Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE);
    PoLine originPoLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withId(lineId).withEresource(eresource).withPhysical(physical).withLocations(List.of(loc)).withCost(cost);
    PieceCreationHolder incomingUpdateHolder = new PieceCreationHolder().withPieceToCreate(pieceToCreate).withCreateItem(true);
    incomingUpdateHolder.withOrderInformation(purchaseOrder, originPoLine);
    doReturn(completedFuture(null)).when(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
    // When
    pieceCreateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToSave = incomingUpdateHolder.getPoLineToSave();
    assertEquals(1, poLineToSave.getLocations().size());
    assertEquals(3, poLineToSave.getLocations().get(0).getQuantity());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantityPhysical());
    assertEquals(2, poLineToSave.getLocations().get(0).getQuantityElectronic());
    assertEquals(1, poLineToSave.getCost().getQuantityPhysical());
    assertEquals(2, poLineToSave.getCost().getQuantityElectronic());
    verify(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : PieceCreationHolder(org.folio.models.pieces.PieceCreationHolder) Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with PoLine

use of org.folio.rest.jaxrs.model.PoLine in project mod-orders by folio-org.

the class PieceCreateFlowPoLineServiceTest method shouldNotUpdateLocationIfCreateInventoryNoneForPhysicalAndNoLocationInTheLineButUpdateCostQty.

@Test
@DisplayName("Add 1 physical piece without location id to physical pol without location and physical qty and create inventory NONE")
void shouldNotUpdateLocationIfCreateInventoryNoneForPhysicalAndNoLocationInTheLineButUpdateCostQty() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    Piece pieceToCreate = new Piece().withPoLineId(lineId).withFormat(Piece.Format.PHYSICAL);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(OPEN);
    Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.NONE);
    Eresource eresource = new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE);
    PoLine originPoLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withOrderFormat(PoLine.OrderFormat.PHYSICAL_RESOURCE).withId(lineId).withEresource(eresource).withPhysical(physical).withCost(cost);
    PieceCreationHolder incomingUpdateHolder = new PieceCreationHolder().withPieceToCreate(pieceToCreate).withCreateItem(true);
    incomingUpdateHolder.withOrderInformation(purchaseOrder, originPoLine);
    doReturn(completedFuture(null)).when(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
    // When
    pieceCreateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToSave = incomingUpdateHolder.getPoLineToSave();
    assertEquals(0, poLineToSave.getLocations().size());
    assertEquals(2, poLineToSave.getCost().getQuantityPhysical());
    assertEquals(1, poLineToSave.getCost().getQuantityElectronic());
    verify(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : PieceCreationHolder(org.folio.models.pieces.PieceCreationHolder) Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with PoLine

use of org.folio.rest.jaxrs.model.PoLine in project mod-orders by folio-org.

the class PieceCreateFlowPoLineServiceTest method shouldNotUpdateLocationIfCreateInventoryNoneForElectronicButUpdateCostQty.

@Test
@DisplayName("Add 1 electronic piece without location id to mixed pol with 1 location with location id and physical qty and create inventory NONE")
void shouldNotUpdateLocationIfCreateInventoryNoneForElectronicButUpdateCostQty() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    Piece pieceToCreate = new Piece().withPoLineId(lineId).withFormat(Piece.Format.ELECTRONIC);
    Location loc = new Location().withLocationId(locationId).withQuantityPhysical(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(OPEN);
    Eresource eresource = new Eresource().withCreateInventory(Eresource.CreateInventory.NONE);
    Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE);
    PoLine originPoLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withId(lineId).withEresource(eresource).withPhysical(physical).withLocations(List.of(loc)).withCost(cost);
    PieceCreationHolder incomingUpdateHolder = new PieceCreationHolder().withPieceToCreate(pieceToCreate).withCreateItem(true);
    incomingUpdateHolder.withOrderInformation(purchaseOrder, originPoLine);
    doReturn(completedFuture(null)).when(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
    // When
    pieceCreateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToSave = incomingUpdateHolder.getPoLineToSave();
    assertEquals(1, poLineToSave.getLocations().size());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantity());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantityPhysical());
    assertNull(poLineToSave.getLocations().get(0).getQuantityElectronic());
    assertEquals(1, poLineToSave.getCost().getQuantityPhysical());
    assertEquals(2, poLineToSave.getCost().getQuantityElectronic());
    verify(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : PieceCreationHolder(org.folio.models.pieces.PieceCreationHolder) Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 14 with PoLine

use of org.folio.rest.jaxrs.model.PoLine in project mod-orders by folio-org.

the class PieceCreateFlowPoLineServiceTest method elecAddStrategyShouldIncreaseQuantityTo2ForCostAndLocationIfInitiallyWas1AndLocationIdInPieceAndPOLWithHoldingId.

@Test
@DisplayName("Add 1 electronic piece with location to electronic pol with 1 location with holding id")
void elecAddStrategyShouldIncreaseQuantityTo2ForCostAndLocationIfInitiallyWas1AndLocationIdInPieceAndPOLWithHoldingId() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    String holdingId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    Piece piece = new Piece().withPoLineId(lineId).withLocationId(locationId).withFormat(Piece.Format.ELECTRONIC);
    Location loc = new Location().withHoldingId(holdingId).withQuantityElectronic(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1).withListUnitPrice(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    List<Location> locations = new ArrayList<>();
    locations.add(loc);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(OPEN);
    Eresource eresource = new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE);
    PoLine originPoLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withOrderFormat(PoLine.OrderFormat.ELECTRONIC_RESOURCE).withId(lineId).withEresource(eresource).withLocations(List.of(loc)).withCost(cost);
    PieceCreationHolder incomingUpdateHolder = new PieceCreationHolder().withPieceToCreate(piece).withCreateItem(true);
    incomingUpdateHolder.withOrderInformation(purchaseOrder, originPoLine);
    doReturn(completedFuture(null)).when(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
    // When
    pieceCreateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToSave = incomingUpdateHolder.getPoLineToSave();
    assertNull(poLineToSave.getCost().getQuantityPhysical());
    assertEquals(2, poLineToSave.getCost().getQuantityElectronic());
    assertEquals(2, poLineToSave.getLocations().size());
    assertNull(poLineToSave.getLocations().get(0).getQuantityPhysical());
    assertNull(poLineToSave.getLocations().get(1).getQuantityPhysical());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantityElectronic());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantity());
    verify(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : PieceCreationHolder(org.folio.models.pieces.PieceCreationHolder) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) ArrayList(java.util.ArrayList) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with PoLine

use of org.folio.rest.jaxrs.model.PoLine in project mod-orders by folio-org.

the class PieceCreateFlowPoLineServiceTest method shouldNotUpdateLocationIfCreateInventoryNoneForPhysicalButUpdateCostQty.

@Test
@DisplayName("Add 1 physical piece without location id to mixed pol with 1 location with location id and physical qty and create inventory NONE")
void shouldNotUpdateLocationIfCreateInventoryNoneForPhysicalButUpdateCostQty() throws ExecutionException, InterruptedException {
    String orderId = UUID.randomUUID().toString();
    String locationId = UUID.randomUUID().toString();
    String lineId = UUID.randomUUID().toString();
    Piece pieceToCreate = new Piece().withPoLineId(lineId).withFormat(Piece.Format.PHYSICAL);
    Location loc = new Location().withLocationId(locationId).withQuantityElectronic(1).withQuantity(1);
    Cost cost = new Cost().withQuantityElectronic(1).withQuantityPhysical(1).withListUnitPrice(1d).withExchangeRate(1d).withCurrency("USD").withPoLineEstimatedPrice(1d);
    PurchaseOrder purchaseOrder = new PurchaseOrder().withId(orderId).withWorkflowStatus(OPEN);
    Eresource eresource = new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE);
    Physical physical = new Physical().withCreateInventory(Physical.CreateInventory.NONE);
    PoLine originPoLine = new PoLine().withIsPackage(false).withPurchaseOrderId(orderId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withId(lineId).withEresource(eresource).withPhysical(physical).withLocations(List.of(loc)).withCost(cost);
    PieceCreationHolder incomingUpdateHolder = new PieceCreationHolder().withPieceToCreate(pieceToCreate).withCreateItem(true);
    incomingUpdateHolder.withOrderInformation(purchaseOrder, originPoLine);
    doReturn(completedFuture(null)).when(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    doReturn(completedFuture(null)).when(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
    // When
    pieceCreateFlowPoLineService.updatePoLine(incomingUpdateHolder, requestContext).get();
    // Then
    CompositePoLine poLineToSave = incomingUpdateHolder.getPoLineToSave();
    assertEquals(1, poLineToSave.getLocations().size());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantity());
    assertEquals(1, poLineToSave.getLocations().get(0).getQuantityElectronic());
    assertNull(poLineToSave.getLocations().get(0).getQuantityPhysical());
    assertEquals(2, poLineToSave.getCost().getQuantityPhysical());
    assertEquals(1, poLineToSave.getCost().getQuantityElectronic());
    verify(receivingEncumbranceStrategy).processEncumbrances(incomingUpdateHolder.getPurchaseOrderToSave(), incomingUpdateHolder.getPurchaseOrderToSave(), requestContext);
    verify(purchaseOrderLineService).saveOrderLine(incomingUpdateHolder.getPoLineToSave(), requestContext);
}
Also used : PieceCreationHolder(org.folio.models.pieces.PieceCreationHolder) Physical(org.folio.rest.jaxrs.model.Physical) Piece(org.folio.rest.jaxrs.model.Piece) PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrder(org.folio.rest.jaxrs.model.PurchaseOrder) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) Cost(org.folio.rest.jaxrs.model.Cost) Eresource(org.folio.rest.jaxrs.model.Eresource) Location(org.folio.rest.jaxrs.model.Location) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

PoLine (org.folio.rest.jaxrs.model.PoLine)91 Test (org.junit.jupiter.api.Test)65 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)56 PurchaseOrder (org.folio.rest.jaxrs.model.PurchaseOrder)53 Cost (org.folio.rest.jaxrs.model.Cost)52 Piece (org.folio.rest.jaxrs.model.Piece)51 Location (org.folio.rest.jaxrs.model.Location)49 JsonObject (io.vertx.core.json.JsonObject)45 ArrayList (java.util.ArrayList)38 Eresource (org.folio.rest.jaxrs.model.Eresource)35 Physical (org.folio.rest.jaxrs.model.Physical)31 List (java.util.List)23 DisplayName (org.junit.jupiter.api.DisplayName)23 Map (java.util.Map)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 RequestContext (org.folio.rest.core.models.RequestContext)19 CompletableFuture (java.util.concurrent.CompletableFuture)17 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)17 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)15 Context (io.vertx.core.Context)14