use of org.folio.rest.acq.model.orders.PurchaseOrder in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupUnreleaseEncumbrances.
private void setupUnreleaseEncumbrances(boolean withError) {
String orderId1 = UUID.randomUUID().toString();
String orderId2 = UUID.randomUUID().toString();
List<PurchaseOrder> orders = List.of(new PurchaseOrder().withId(orderId1).withWorkflowStatus(WorkflowStatus.PENDING), new PurchaseOrder().withId(orderId2).withWorkflowStatus(WorkflowStatus.OPEN));
List<PoLine> poLines = List.of(new PoLine().withId("2bafc9e1-9dd3-4ede-9f23-c4a03f8bb2d5").withPurchaseOrderId(orderId1), new PoLine().withId("5a34ae0e-5a11-4337-be95-1a20cfdc3161").withPurchaseOrderId(orderId2), new PoLine().withId("0610be6d-0ddd-494b-b867-19f63d8b5d6d").withPurchaseOrderId(orderId2));
List<Transaction> transactions = List.of(new Transaction().withId(UUID.randomUUID().toString()).withTransactionType(TransactionType.ENCUMBRANCE).withEncumbrance(new Encumbrance().withStatus(PENDING).withSourcePurchaseOrderId(orderId2)), new Transaction().withId(UUID.randomUUID().toString()).withTransactionType(TransactionType.ENCUMBRANCE).withEncumbrance(new Encumbrance().withStatus(RELEASED).withSourcePurchaseOrderId(orderId2)), new Transaction().withId(UUID.randomUUID().toString()).withTransactionType(TransactionType.ENCUMBRANCE).withEncumbrance(new Encumbrance().withStatus(UNRELEASED).withSourcePurchaseOrderId(orderId2)));
setupPoLineQuery(poLines);
setupOrderQuery(orders);
setupEncumbranceQuery(orders, poLines, transactions);
setupUpdateOrderTransactionSummary(orders.get(1));
if (withError)
setupEncumbrancePutWithError(transactions.get(1));
else
setupEncumbrancePut(transactions.get(1));
}
use of org.folio.rest.acq.model.orders.PurchaseOrder in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupOrderQuery.
private void setupOrderQuery(List<PurchaseOrder> orders) {
List<String> orderIds = orders.stream().map(PurchaseOrder::getId).collect(toList());
List<PurchaseOrder> openOrders = List.of(orders.get(1));
String orderIdsQuery = String.join(" or ", orderIds);
String orderQuery = "workflowStatus==\"Open\" AND id==(" + orderIdsQuery + ")";
PurchaseOrderCollection orderCollection = new PurchaseOrderCollection().withPurchaseOrders(openOrders).withTotalRecords(openOrders.size());
RequestEntry requestEntry = new RequestEntry("/orders/composite-orders").withQuery(orderQuery).withOffset(0).withLimit(Integer.MAX_VALUE);
doReturn(completedFuture(orderCollection)).when(restClient).get(argThat(re -> sameRequestEntry(requestEntry, re)), eq(requestContextMock), eq(PurchaseOrderCollection.class));
}
use of org.folio.rest.acq.model.orders.PurchaseOrder in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupUpdateOrderTransactionSummary.
private void setupUpdateOrderTransactionSummary(PurchaseOrder order) {
RequestEntry requestEntry = new RequestEntry(ORDER_TRANSACTION_SUMMARIES_BY_ID_ENDPOINT).withPathParameter("id", order.getId());
OrderTransactionSummary summary = new OrderTransactionSummary().withId(order.getId()).withNumTransactions(1);
doReturn(completedFuture(null)).when(restClient).put(argThat(re -> sameRequestEntry(requestEntry, re)), eq(summary), eq(requestContextMock));
}
use of org.folio.rest.acq.model.orders.PurchaseOrder in project mod-invoice by folio-org.
the class InvoiceCancelServiceTest method setupEncumbranceQuery.
private void setupEncumbranceQuery(List<PurchaseOrder> orders, List<PoLine> poLines, List<Transaction> transactions) {
List<PoLine> selectedPoLines = poLines.stream().filter(line -> orders.stream().anyMatch(order -> order.getId().equals(line.getPurchaseOrderId()) && order.getWorkflowStatus().equals(WorkflowStatus.OPEN))).collect(toList());
String poLineIdsQuery = selectedPoLines.stream().map(PoLine::getId).collect(joining(" or "));
String transactionQuery = "transactionType==Encumbrance and encumbrance.sourcePoLineId==(" + poLineIdsQuery + ")";
TransactionCollection transactionCollection = new TransactionCollection().withTransactions(transactions).withTotalRecords(transactions.size());
RequestEntry requestEntry = new RequestEntry(TRANSACTIONS_ENDPOINT).withQuery(transactionQuery).withOffset(0).withLimit(selectedPoLines.size());
doReturn(completedFuture(transactionCollection)).when(restClient).get(argThat(re -> sameRequestEntry(requestEntry, re)), eq(requestContextMock), eq(TransactionCollection.class));
}
Aggregations