Search in sources :

Example 1 with OrderTransactionSummary

use of org.folio.rest.acq.model.finance.OrderTransactionSummary in project mod-orders by folio-org.

the class TransactionSummariesService method createOrderTransactionSummary.

public CompletableFuture<OrderTransactionSummary> createOrderTransactionSummary(String id, int number, RequestContext requestContext) {
    OrderTransactionSummary summary = new OrderTransactionSummary().withId(id).withNumTransactions(number);
    RequestEntry requestEntry = new RequestEntry(ENDPOINT);
    return restClient.post(requestEntry, summary, requestContext, OrderTransactionSummary.class);
}
Also used : RequestEntry(org.folio.rest.core.models.RequestEntry) OrderTransactionSummary(org.folio.rest.acq.model.finance.OrderTransactionSummary)

Example 2 with OrderTransactionSummary

use of org.folio.rest.acq.model.finance.OrderTransactionSummary in project mod-orders by folio-org.

the class TransactionSummariesService method updateOrderTransactionSummary.

public CompletableFuture<Void> updateOrderTransactionSummary(String orderId, int number, RequestContext requestContext) {
    if (number > 0) {
        OrderTransactionSummary summary = new OrderTransactionSummary().withId(orderId).withNumTransactions(number);
        RequestEntry requestEntry = new RequestEntry(BY_ID_ENDPOINT).withId(orderId);
        return restClient.put(requestEntry, summary, requestContext);
    } else {
        return CompletableFuture.completedFuture(null);
    }
}
Also used : RequestEntry(org.folio.rest.core.models.RequestEntry) OrderTransactionSummary(org.folio.rest.acq.model.finance.OrderTransactionSummary)

Example 3 with OrderTransactionSummary

use of org.folio.rest.acq.model.finance.OrderTransactionSummary in project mod-orders by folio-org.

the class TransactionSummariesServiceTest method testShouldCreateTransactionSummaryInStorageTransactions.

@Test
void testShouldCreateTransactionSummaryInStorageTransactions() {
    // given
    String uuid = UUID.randomUUID().toString();
    Response response = new Response();
    response.setBody(new JsonObject("{\"id\": \"" + uuid + "\"}"));
    response.setCode(201);
    doReturn(completedFuture(response)).when(restClient).post(any(), any(), any(), any());
    // When
    OrderTransactionSummary summary = transactionSummariesService.createOrderTransactionSummary(uuid, 2, requestContext).join();
    // Then
    assertEquals(uuid, summary.getId());
    verify(restClient).post(any(), any(), any(), any());
}
Also used : Response(org.folio.rest.tools.client.Response) JsonObject(io.vertx.core.json.JsonObject) OrderTransactionSummary(org.folio.rest.acq.model.finance.OrderTransactionSummary) Test(org.junit.jupiter.api.Test)

Example 4 with OrderTransactionSummary

use of org.folio.rest.acq.model.finance.OrderTransactionSummary 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));
}
Also used : INVOICE_MOCK_DATA_PATH(org.folio.TestMockDataConstants.INVOICE_MOCK_DATA_PATH) BeforeEach(org.junit.jupiter.api.BeforeEach) TransactionType(org.folio.rest.acq.model.finance.Transaction.TransactionType) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) PurchaseOrder(org.folio.rest.acq.model.orders.PurchaseOrder) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) PoLine(org.folio.rest.acq.model.orders.PoLine) OrderLineService(org.folio.services.order.OrderLineService) VOUCHERS_STORAGE(org.folio.invoices.utils.ResourcePathResolver.VOUCHERS_STORAGE) INVOICE_TRANSACTION_SUMMARIES(org.folio.invoices.utils.ResourcePathResolver.INVOICE_TRANSACTION_SUMMARIES) Mockito.argThat(org.mockito.Mockito.argThat) TransactionCollection(org.folio.rest.acq.model.finance.TransactionCollection) MOCK_CREDITS_LIST(org.folio.TestMockDataConstants.MOCK_CREDITS_LIST) Collections.singletonList(java.util.Collections.singletonList) VOUCHER_MOCK_DATA_PATH(org.folio.TestMockDataConstants.VOUCHER_MOCK_DATA_PATH) HttpException(org.folio.invoices.rest.exceptions.HttpException) Voucher(org.folio.rest.jaxrs.model.Voucher) InvoiceTransactionSummaryService(org.folio.services.finance.transaction.InvoiceTransactionSummaryService) VoucherCommandService(org.folio.services.voucher.VoucherCommandService) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) InvoiceTransactionSummary(org.folio.rest.acq.model.finance.InvoiceTransactionSummary) JsonObject(io.vertx.core.json.JsonObject) Method(java.lang.reflect.Method) ERROR_UNRELEASING_ENCUMBRANCES(org.folio.invoices.utils.ErrorCodes.ERROR_UNRELEASING_ENCUMBRANCES) Mockito.doReturn(org.mockito.Mockito.doReturn) RELEASED(org.folio.rest.acq.model.finance.Encumbrance.Status.RELEASED) InvoiceLine(org.folio.rest.jaxrs.model.InvoiceLine) ORDER_TRANSACTION_SUMMARIES(org.folio.invoices.utils.ResourcePathResolver.ORDER_TRANSACTION_SUMMARIES) CompletionException(java.util.concurrent.CompletionException) MOCK_ENCUMBRANCES_LIST(org.folio.TestMockDataConstants.MOCK_ENCUMBRANCES_LIST) UUID(java.util.UUID) Collectors.joining(java.util.stream.Collectors.joining) Test(org.junit.jupiter.api.Test) CompletableFuture.failedFuture(java.util.concurrent.CompletableFuture.failedFuture) List(java.util.List) FINANCE_TRANSACTIONS(org.folio.invoices.utils.ResourcePathResolver.FINANCE_TRANSACTIONS) PENDING(org.folio.rest.acq.model.finance.Encumbrance.Status.PENDING) PurchaseOrderCollection(org.folio.rest.acq.model.orders.PurchaseOrderCollection) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) UNRELEASED(org.folio.rest.acq.model.finance.Encumbrance.Status.UNRELEASED) WorkflowStatus(org.folio.rest.acq.model.orders.PurchaseOrder.WorkflowStatus) Invoice(org.folio.rest.jaxrs.model.Invoice) MOCK_PAYMENTS_LIST(org.folio.TestMockDataConstants.MOCK_PAYMENTS_LIST) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) RestClient(org.folio.rest.core.RestClient) EncumbranceService(org.folio.services.finance.transaction.EncumbranceService) CANNOT_CANCEL_INVOICE(org.folio.invoices.utils.ErrorCodes.CANNOT_CANCEL_INVOICE) PoLineCollection(org.folio.rest.acq.model.orders.PoLineCollection) CompletableFuture(java.util.concurrent.CompletableFuture) Transaction(org.folio.rest.acq.model.finance.Transaction) VoucherCollection(org.folio.rest.jaxrs.model.VoucherCollection) InvoiceLineCollection(org.folio.rest.jaxrs.model.InvoiceLineCollection) Answer(org.mockito.stubbing.Answer) OrderTransactionSummary(org.folio.rest.acq.model.finance.OrderTransactionSummary) InvocationOnMock(org.mockito.invocation.InvocationOnMock) RequestContext(org.folio.rest.core.models.RequestContext) Encumbrance(org.folio.rest.acq.model.finance.Encumbrance) BaseTransactionService(org.folio.services.finance.transaction.BaseTransactionService) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MOCK_PENDING_PAYMENTS_LIST(org.folio.TestMockDataConstants.MOCK_PENDING_PAYMENTS_LIST) OrderService(org.folio.services.order.OrderService) ResourcePathResolver.resourcesPath(org.folio.invoices.utils.ResourcePathResolver.resourcesPath) Files(java.nio.file.Files) VoucherRetrieveService(org.folio.services.voucher.VoucherRetrieveService) Vertx(io.vertx.core.Vertx) RequestEntry(org.folio.rest.core.models.RequestEntry) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) Mockito.verify(org.mockito.Mockito.verify) Mockito(org.mockito.Mockito) Collectors.toList(java.util.stream.Collectors.toList) Paths(java.nio.file.Paths) INVOICE_LINES_LIST_PATH(org.folio.TestMockDataConstants.INVOICE_LINES_LIST_PATH) OrderTransactionSummaryService(org.folio.services.finance.transaction.OrderTransactionSummaryService) RequestEntry(org.folio.rest.core.models.RequestEntry) OrderTransactionSummary(org.folio.rest.acq.model.finance.OrderTransactionSummary)

Aggregations

OrderTransactionSummary (org.folio.rest.acq.model.finance.OrderTransactionSummary)4 RequestEntry (org.folio.rest.core.models.RequestEntry)3 JsonObject (io.vertx.core.json.JsonObject)2 Test (org.junit.jupiter.api.Test)2 Vertx (io.vertx.core.Vertx)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 CompletableFuture.failedFuture (java.util.concurrent.CompletableFuture.failedFuture)1 CompletionException (java.util.concurrent.CompletionException)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toList (java.util.stream.Collectors.toList)1 INVOICE_LINES_LIST_PATH (org.folio.TestMockDataConstants.INVOICE_LINES_LIST_PATH)1 INVOICE_MOCK_DATA_PATH (org.folio.TestMockDataConstants.INVOICE_MOCK_DATA_PATH)1