use of org.folio.models.CompositeOrderRetrieveHolder in project mod-orders by folio-org.
the class CompositeOrderRetrieveHolderBuilderTest method shouldNotPopulateFiscalYearWhenThereAreNoFundDistributions.
@Test
void shouldNotPopulateFiscalYearWhenThereAreNoFundDistributions() {
CompositePurchaseOrder order = new CompositePurchaseOrder().withId(UUID.randomUUID().toString());
CompositeOrderRetrieveHolder holder = new CompositeOrderRetrieveHolder(order);
CompositeOrderRetrieveHolder resultHolder = holderBuilder.withCurrentFiscalYear(holder, requestContext).join();
assertNull(resultHolder.getFiscalYear());
}
use of org.folio.models.CompositeOrderRetrieveHolder in project mod-orders by folio-org.
the class CompositeOrderRetrieveHolderBuilderTest method shouldNotFailWhenRetrieveFiscalYearReturns404Status.
@Test
void shouldNotFailWhenRetrieveFiscalYearReturns404Status() {
FundDistribution fundDistribution = new FundDistribution().withFundId(UUID.randomUUID().toString());
CompositePoLine poLine = new CompositePoLine().withFundDistribution(List.of(fundDistribution));
CompositePurchaseOrder order = new CompositePurchaseOrder().withId(UUID.randomUUID().toString()).withCompositePoLines(Collections.singletonList(poLine));
CompositeOrderRetrieveHolder holder = new CompositeOrderRetrieveHolder(order);
CompletableFuture<FiscalYear> failedFuture = new CompletableFuture<>();
failedFuture.completeExceptionally(new HttpException(404, ErrorCodes.CURRENT_FISCAL_YEAR_NOT_FOUND));
when(fiscalYearService.getCurrentFiscalYearByFundId(anyString(), any())).thenReturn(failedFuture);
CompositeOrderRetrieveHolder resultHolder = holderBuilder.withCurrentFiscalYear(holder, requestContext).join();
assertNull(resultHolder.getFiscalYear());
}
use of org.folio.models.CompositeOrderRetrieveHolder in project mod-orders by folio-org.
the class TransactionsTotalFieldsPopulateServiceTest method shouldPopulateTotalEncumberedFieldWithZeroWhenFiscalYearIsEmpty.
@Test
void shouldPopulateTotalEncumberedFieldWithZeroWhenFiscalYearIsEmpty() {
CompositePurchaseOrder order = new CompositePurchaseOrder().withId(UUID.randomUUID().toString());
CompositeOrderRetrieveHolder holder = new CompositeOrderRetrieveHolder(order);
CompositeOrderRetrieveHolder resultHolder = populateService.populate(holder, requestContext).join();
assertEquals(0d, resultHolder.getOrder().getTotalExpended());
assertEquals(0d, resultHolder.getOrder().getTotalEncumbered());
}
use of org.folio.models.CompositeOrderRetrieveHolder 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());
}
Aggregations