Search in sources :

Example 16 with FiscalYear

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

the class ReEncumbranceHoldersBuilderTest method shouldPopulateCurrentFiscalYearDataForReEncumbranceHoldersIfAnyHolderHasFund.

@Test
void shouldPopulateCurrentFiscalYearDataForReEncumbranceHoldersIfAnyHolderHasFund() {
    Fund fund2 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
    Fund fund3 = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString());
    ReEncumbranceHolder holder1 = new ReEncumbranceHolder();
    ReEncumbranceHolder holder2 = new ReEncumbranceHolder().withLedgerId(fund2.getLedgerId());
    ReEncumbranceHolder holder3 = new ReEncumbranceHolder().withLedgerId(fund3.getLedgerId());
    List<ReEncumbranceHolder> holders = Arrays.asList(holder1, holder2, holder3);
    FiscalYear fiscalYear = new FiscalYear().withId(UUID.randomUUID().toString());
    when(fiscalYearService.getCurrentFiscalYear(anyString(), any())).thenReturn(CompletableFuture.completedFuture(fiscalYear));
    List<ReEncumbranceHolder> resultHolders = reEncumbranceHoldersBuilder.withCurrentFiscalYearData(holders, requestContext).join();
    assertThat(resultHolders, everyItem(hasProperty("currentFiscalYearId", is(fiscalYear.getId()))));
    assertThat(resultHolders, everyItem(hasProperty("currency", is(fiscalYear.getCurrency()))));
}
Also used : FiscalYear(org.folio.rest.acq.model.finance.FiscalYear) Fund(org.folio.rest.acq.model.finance.Fund) ReEncumbranceHolder(org.folio.models.ReEncumbranceHolder) Test(org.junit.jupiter.api.Test)

Example 17 with FiscalYear

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

the class TransactionsTotalFieldsPopulateServiceTest method shouldPopulateTotalEncumberedFieldWithSumOfEncumbrancesAmount.

@Test
void shouldPopulateTotalEncumberedFieldWithSumOfEncumbrancesAmount() {
    Transaction transaction1 = new Transaction().withId(UUID.randomUUID().toString());
    Transaction transaction2 = new Transaction().withId(UUID.randomUUID().toString());
    CompositePurchaseOrder order = new CompositePurchaseOrder().withId(UUID.randomUUID().toString());
    CompositeOrderRetrieveHolder holder = new CompositeOrderRetrieveHolder(order).withFiscalYear(new FiscalYear().withId(UUID.randomUUID().toString()));
    Transaction paidEncumbrance = new Transaction().withTransactionType(Transaction.TransactionType.ENCUMBRANCE).withPaymentEncumbranceId(transaction1.getId()).withAmount(14.11d).withCurrency("USD").withEncumbrance(new Encumbrance().withAmountExpended(13.45));
    Transaction notPaidEncumbrance = new Transaction().withTransactionType(Transaction.TransactionType.ENCUMBRANCE).withPaymentEncumbranceId(transaction2.getId()).withAmount(13.43d).withCurrency("USD").withEncumbrance(new Encumbrance().withAmountExpended(0d));
    List<Transaction> transactions = List.of(paidEncumbrance, notPaidEncumbrance);
    TransactionCollection transactionCollection = new TransactionCollection().withTransactions(transactions);
    when(transactionService.getTransactions(anyString(), anyInt(), anyInt(), any())).thenReturn(CompletableFuture.completedFuture(transactionCollection));
    CompositeOrderRetrieveHolder resultHolder = populateService.populate(holder, requestContext).join();
    assertEquals(27.54, resultHolder.getOrder().getTotalEncumbered());
    assertEquals(13.45, resultHolder.getOrder().getTotalExpended());
}
Also used : TransactionCollection(org.folio.rest.acq.model.finance.TransactionCollection) FiscalYear(org.folio.rest.acq.model.finance.FiscalYear) Transaction(org.folio.rest.acq.model.finance.Transaction) Encumbrance(org.folio.rest.acq.model.finance.Encumbrance) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) CompositeOrderRetrieveHolder(org.folio.models.CompositeOrderRetrieveHolder) Test(org.junit.jupiter.api.Test)

Example 18 with FiscalYear

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

the class FiscalYearServiceTest method testShouldReturnCurrentFiscalYearForLedger.

@Test
void testShouldReturnCurrentFiscalYearForLedger() {
    String ledgerId = UUID.randomUUID().toString();
    FiscalYear fy = fiscalYearService.getCurrentFiscalYear(ledgerId, requestContextMock).join();
    assertNotNull(fy);
}
Also used : FiscalYear(org.folio.rest.acq.model.finance.FiscalYear) Test(org.junit.jupiter.api.Test)

Example 19 with FiscalYear

use of org.folio.rest.acq.model.finance.FiscalYear in project mod-invoice by folio-org.

the class MockServer method handleFiscalYear.

private void handleFiscalYear(RoutingContext ctx) {
    logger.info("handleFiscalYear got: GET " + ctx.request().path());
    FiscalYear fiscalYear = new FiscalYear();
    fiscalYear.setId(FISCAL_YEAR_ID);
    fiscalYear.setCode("test2020");
    fiscalYear.setName("test");
    fiscalYear.setCurrency(SYSTEM_CURRENCY);
    fiscalYear.setSeries("FY");
    fiscalYear.setPeriodStart(Date.from(Instant.now().minus(365, DAYS)));
    fiscalYear.setPeriodEnd(Date.from(Instant.now().plus(365, DAYS)));
    FiscalYearCollection fiscalYearCollection = new FiscalYearCollection().withFiscalYears(Collections.singletonList(fiscalYear));
    serverResponse(ctx, 200, APPLICATION_JSON, JsonObject.mapFrom(fiscalYearCollection).encodePrettily());
}
Also used : FiscalYear(org.folio.rest.acq.model.finance.FiscalYear) FiscalYearCollection(org.folio.rest.acq.model.finance.FiscalYearCollection)

Example 20 with FiscalYear

use of org.folio.rest.acq.model.finance.FiscalYear in project mod-invoice by folio-org.

the class MockServer method handleGetCurrentFiscalYearByLedgerId.

private void handleGetCurrentFiscalYearByLedgerId(RoutingContext ctx) {
    logger.info("got: " + ctx.request().path());
    String id = ctx.request().getParam(AbstractHelper.ID);
    logger.info("id: " + id);
    addServerRqRsData(HttpMethod.GET, CURRENT_FISCAL_YEAR, new JsonObject().put(AbstractHelper.ID, id));
    if (ID_FOR_INTERNAL_SERVER_ERROR.equals(id)) {
        serverResponse(ctx, 500, APPLICATION_JSON, INTERNAL_SERVER_ERROR.getReasonPhrase());
    } else if (ID_DOES_NOT_EXIST.equals(id)) {
        serverResponse(ctx, 404, APPLICATION_JSON, id);
    } else {
        FiscalYear fiscalYear = new FiscalYear();
        fiscalYear.setId(FISCAL_YEAR_ID);
        fiscalYear.setCode("test2020");
        fiscalYear.setName("test");
        fiscalYear.setCurrency(SYSTEM_CURRENCY);
        fiscalYear.setSeries("FY");
        fiscalYear.setPeriodStart(Date.from(Instant.now().minus(365, DAYS)));
        fiscalYear.setPeriodEnd(Date.from(Instant.now().plus(365, DAYS)));
        serverResponse(ctx, 200, APPLICATION_JSON, JsonObject.mapFrom(fiscalYear).encodePrettily());
    }
}
Also used : FiscalYear(org.folio.rest.acq.model.finance.FiscalYear) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

FiscalYear (org.folio.rest.acq.model.finance.FiscalYear)26 Test (org.junit.jupiter.api.Test)22 Fund (org.folio.rest.acq.model.finance.Fund)11 ArrayList (java.util.ArrayList)9 Transaction (org.folio.rest.acq.model.finance.Transaction)9 InvoiceWorkflowDataHolder (org.folio.models.InvoiceWorkflowDataHolder)7 Budget (org.folio.rest.acq.model.finance.Budget)7 HttpException (org.folio.invoices.rest.exceptions.HttpException)4 CompositeOrderRetrieveHolder (org.folio.models.CompositeOrderRetrieveHolder)4 ReEncumbranceHolder (org.folio.models.ReEncumbranceHolder)4 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)4 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)4 Error (org.folio.rest.jaxrs.model.Error)4 FundDistribution (org.folio.rest.jaxrs.model.FundDistribution)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 TransactionCollection (org.folio.rest.acq.model.finance.TransactionCollection)3 HttpException (org.folio.rest.core.exceptions.HttpException)3 JsonObject (io.vertx.core.json.JsonObject)2 LocalDate (java.time.LocalDate)2 Date (java.util.Date)2