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